diff options
author | Ben Greear <greearb@candelatech.com> | 2014-10-22 12:22:59 -0700 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2014-10-24 10:20:02 +0200 |
commit | 8cdd9e1c37dd888894922b8209d5fc8055cfde52 (patch) | |
tree | b05f058bf0334db2f832a7b7080a08f811cdfbf4 /drivers/net/wireless/mac80211_hwsim.c | |
parent | 2155c3f82327bddd092bd704ebaff79c0a2dfb9c (diff) | |
download | blackbird-op-linux-8cdd9e1c37dd888894922b8209d5fc8055cfde52.tar.gz blackbird-op-linux-8cdd9e1c37dd888894922b8209d5fc8055cfde52.zip |
mac80211-hwsim: support destroying radio by name
It is not always convenient to have to know the device-id,
so allow deleting by name as well.
Signed-off-by: Ben Greear <greearb@candelatech.com>
[use wiphy_name() instead of dev_name()]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'drivers/net/wireless/mac80211_hwsim.c')
-rw-r--r-- | drivers/net/wireless/mac80211_hwsim.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 4e92a5b9324d..e9f7c1ec50a4 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -2544,16 +2544,27 @@ static int hwsim_create_radio_nl(struct sk_buff *msg, struct genl_info *info) static int hwsim_destroy_radio_nl(struct sk_buff *msg, struct genl_info *info) { struct mac80211_hwsim_data *data; - int idx; + s64 idx = -1; + const char *hwname = NULL; - if (!info->attrs[HWSIM_ATTR_RADIO_ID]) + if (info->attrs[HWSIM_ATTR_RADIO_ID]) + idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]); + else if (info->attrs[HWSIM_ATTR_RADIO_NAME]) + hwname = (void *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]); + else return -EINVAL; - idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]); spin_lock_bh(&hwsim_radio_lock); list_for_each_entry(data, &hwsim_radios, list) { - if (data->idx != idx) - continue; + if (idx >= 0) { + if (data->idx != idx) + continue; + } else { + if (hwname && + strcmp(hwname, wiphy_name(data->hw->wiphy))) + continue; + } + list_del(&data->list); spin_unlock_bh(&hwsim_radio_lock); mac80211_hwsim_destroy_radio(data); |