mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-21 20:12:37 +01:00
wiphy: Drop wiphy creation logic
This commit is contained in:
parent
530a449337
commit
65109ec46d
142
src/wiphy.c
142
src/wiphy.c
@ -637,39 +637,6 @@ bool wiphy_parse_id_and_name(struct l_genl_attr *attr, uint32_t *out_id,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void wiphy_dump_callback(struct l_genl_msg *msg, void *user_data)
|
||||
{
|
||||
struct wiphy *wiphy;
|
||||
struct l_genl_attr attr;
|
||||
uint32_t id;
|
||||
const char *name;
|
||||
|
||||
l_debug("");
|
||||
|
||||
if (!l_genl_attr_init(&attr, msg))
|
||||
return;
|
||||
|
||||
/*
|
||||
* In most cases multiple of these message will be sent
|
||||
* since the information included can not fit into a single
|
||||
* message.
|
||||
*/
|
||||
if (!wiphy_parse_id_and_name(&attr, &id, &name))
|
||||
return;
|
||||
|
||||
wiphy = l_queue_find(wiphy_list, wiphy_match, L_UINT_TO_PTR(id));
|
||||
if (!wiphy) {
|
||||
if (!wiphy_is_managed(name))
|
||||
return;
|
||||
|
||||
wiphy = wiphy_new(id);
|
||||
l_queue_push_head(wiphy_list, wiphy);
|
||||
}
|
||||
|
||||
l_strlcpy(wiphy->name, name, sizeof(wiphy->name));
|
||||
wiphy_parse_attributes(wiphy, &attr);
|
||||
}
|
||||
|
||||
static void wiphy_register(struct wiphy *wiphy)
|
||||
{
|
||||
struct l_dbus *dbus = dbus_get_bus();
|
||||
@ -722,65 +689,6 @@ static void wiphy_register(struct wiphy *wiphy)
|
||||
wiphy_get_path(wiphy));
|
||||
}
|
||||
|
||||
static void wiphy_dump_done(void *user)
|
||||
{
|
||||
const struct l_queue_entry *wiphy_entry;
|
||||
|
||||
for (wiphy_entry = l_queue_get_entries(wiphy_list); wiphy_entry;
|
||||
wiphy_entry = wiphy_entry->next) {
|
||||
struct wiphy *wiphy = wiphy_entry->data;
|
||||
|
||||
wiphy_register(wiphy);
|
||||
|
||||
wiphy_print_basic_info(wiphy);
|
||||
}
|
||||
}
|
||||
|
||||
static void wiphy_new_wiphy_event(struct l_genl_msg *msg)
|
||||
{
|
||||
struct wiphy *wiphy;
|
||||
struct l_genl_attr attr;
|
||||
uint32_t id;
|
||||
const char *name;
|
||||
|
||||
l_debug("");
|
||||
|
||||
if (!l_genl_attr_init(&attr, msg))
|
||||
return;
|
||||
|
||||
if (!wiphy_parse_id_and_name(&attr, &id, &name))
|
||||
return;
|
||||
|
||||
wiphy = l_queue_find(wiphy_list, wiphy_match, L_UINT_TO_PTR(id));
|
||||
if (wiphy) {
|
||||
/*
|
||||
* WIPHY_NAME is a NLA_NUL_STRING, so the kernel
|
||||
* enforces the data to be null terminated
|
||||
*/
|
||||
if (strcmp(wiphy->name, name)) {
|
||||
struct l_dbus *dbus = dbus_get_bus();
|
||||
|
||||
l_strlcpy(wiphy->name, name, sizeof(wiphy->name));
|
||||
l_dbus_property_changed(dbus, wiphy_get_path(wiphy),
|
||||
IWD_WIPHY_INTERFACE, "Name");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wiphy_is_managed(name))
|
||||
return;
|
||||
|
||||
wiphy = wiphy_new(id);
|
||||
l_strlcpy(wiphy->name, name, sizeof(wiphy->name));
|
||||
l_queue_push_head(wiphy_list, wiphy);
|
||||
|
||||
wiphy_parse_attributes(wiphy, &attr);
|
||||
wiphy_print_basic_info(wiphy);
|
||||
|
||||
wiphy_register(wiphy);
|
||||
}
|
||||
|
||||
struct wiphy *wiphy_create(uint32_t wiphy_id, const char *name)
|
||||
{
|
||||
struct wiphy *wiphy;
|
||||
@ -828,29 +736,6 @@ void wiphy_update_from_genl(struct wiphy *wiphy, struct l_genl_msg *msg)
|
||||
}
|
||||
}
|
||||
|
||||
static void wiphy_del_wiphy_event(struct l_genl_msg *msg)
|
||||
{
|
||||
struct wiphy *wiphy;
|
||||
struct l_genl_attr attr;
|
||||
uint32_t id;
|
||||
|
||||
l_debug("");
|
||||
|
||||
if (!l_genl_attr_init(&attr, msg))
|
||||
return;
|
||||
|
||||
if (!wiphy_parse_id_and_name(&attr, &id, NULL))
|
||||
return;
|
||||
|
||||
wiphy = l_queue_remove_if(wiphy_list, wiphy_match, L_UINT_TO_PTR(id));
|
||||
if (!wiphy)
|
||||
return;
|
||||
|
||||
l_dbus_unregister_object(dbus_get_bus(), wiphy_get_path(wiphy));
|
||||
|
||||
wiphy_free(wiphy);
|
||||
}
|
||||
|
||||
bool wiphy_destroy(struct wiphy *wiphy)
|
||||
{
|
||||
l_debug("");
|
||||
@ -864,24 +749,6 @@ bool wiphy_destroy(struct wiphy *wiphy)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void wiphy_config_notify(struct l_genl_msg *msg, void *user_data)
|
||||
{
|
||||
uint8_t cmd;
|
||||
|
||||
cmd = l_genl_msg_get_command(msg);
|
||||
|
||||
l_debug("Notification of command %u", cmd);
|
||||
|
||||
switch (cmd) {
|
||||
case NL80211_CMD_NEW_WIPHY:
|
||||
wiphy_new_wiphy_event(msg);
|
||||
break;
|
||||
case NL80211_CMD_DEL_WIPHY:
|
||||
wiphy_del_wiphy_event(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void wiphy_regulatory_notify(struct l_genl_msg *msg, void *user_data)
|
||||
{
|
||||
struct l_genl_attr attr;
|
||||
@ -1134,10 +1001,6 @@ bool wiphy_init(struct l_genl_family *in, const char *whitelist,
|
||||
|
||||
nl80211 = in;
|
||||
|
||||
if (!l_genl_family_register(nl80211, "config", wiphy_config_notify,
|
||||
NULL, NULL))
|
||||
l_error("Registering for config notification failed");
|
||||
|
||||
if (!l_genl_family_register(nl80211, "regulatory",
|
||||
wiphy_regulatory_notify, NULL, NULL))
|
||||
l_error("Registering for regulatory notification failed");
|
||||
@ -1154,11 +1017,6 @@ bool wiphy_init(struct l_genl_family *in, const char *whitelist,
|
||||
NULL, NULL))
|
||||
l_error("Getting regulatory info failed");
|
||||
|
||||
msg = l_genl_msg_new(NL80211_CMD_GET_WIPHY);
|
||||
if (!l_genl_family_dump(nl80211, msg, wiphy_dump_callback,
|
||||
NULL, wiphy_dump_done))
|
||||
l_error("Getting all wiphy devices failed");
|
||||
|
||||
rfkill_watch_add(wiphy_rfkill_cb, NULL);
|
||||
|
||||
if (!l_dbus_register_interface(dbus_get_bus(),
|
||||
|
Loading…
Reference in New Issue
Block a user