aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Greear <greearb@candelatech.com>2014-10-22 15:22:59 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-10-24 04:20:02 -0400
commit8cdd9e1c37dd888894922b8209d5fc8055cfde52 (patch)
treeb05f058bf0334db2f832a7b7080a08f811cdfbf4
parent2155c3f82327bddd092bd704ebaff79c0a2dfb9c (diff)
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>
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c21
-rw-r--r--drivers/net/wireless/mac80211_hwsim.h2
2 files changed, 18 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)
2544static int hwsim_destroy_radio_nl(struct sk_buff *msg, struct genl_info *info) 2544static int hwsim_destroy_radio_nl(struct sk_buff *msg, struct genl_info *info)
2545{ 2545{
2546 struct mac80211_hwsim_data *data; 2546 struct mac80211_hwsim_data *data;
2547 int idx; 2547 s64 idx = -1;
2548 const char *hwname = NULL;
2548 2549
2549 if (!info->attrs[HWSIM_ATTR_RADIO_ID]) 2550 if (info->attrs[HWSIM_ATTR_RADIO_ID])
2551 idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]);
2552 else if (info->attrs[HWSIM_ATTR_RADIO_NAME])
2553 hwname = (void *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]);
2554 else
2550 return -EINVAL; 2555 return -EINVAL;
2551 idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]);
2552 2556
2553 spin_lock_bh(&hwsim_radio_lock); 2557 spin_lock_bh(&hwsim_radio_lock);
2554 list_for_each_entry(data, &hwsim_radios, list) { 2558 list_for_each_entry(data, &hwsim_radios, list) {
2555 if (data->idx != idx) 2559 if (idx >= 0) {
2556 continue; 2560 if (data->idx != idx)
2561 continue;
2562 } else {
2563 if (hwname &&
2564 strcmp(hwname, wiphy_name(data->hw->wiphy)))
2565 continue;
2566 }
2567
2557 list_del(&data->list); 2568 list_del(&data->list);
2558 spin_unlock_bh(&hwsim_radio_lock); 2569 spin_unlock_bh(&hwsim_radio_lock);
2559 mac80211_hwsim_destroy_radio(data); 2570 mac80211_hwsim_destroy_radio(data);
diff --git a/drivers/net/wireless/mac80211_hwsim.h b/drivers/net/wireless/mac80211_hwsim.h
index b96d8670a703..98c69984878d 100644
--- a/drivers/net/wireless/mac80211_hwsim.h
+++ b/drivers/net/wireless/mac80211_hwsim.h
@@ -113,6 +113,7 @@ enum {
113 * single channel is supported 113 * single channel is supported
114 * @HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE: used with the %HWSIM_CMD_CREATE_RADIO 114 * @HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE: used with the %HWSIM_CMD_CREATE_RADIO
115 * command to force radio removal when process that created the radio dies 115 * command to force radio removal when process that created the radio dies
116 * @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666
116 * @__HWSIM_ATTR_MAX: enum limit 117 * @__HWSIM_ATTR_MAX: enum limit
117 */ 118 */
118 119
@@ -135,6 +136,7 @@ enum {
135 HWSIM_ATTR_SUPPORT_P2P_DEVICE, 136 HWSIM_ATTR_SUPPORT_P2P_DEVICE,
136 HWSIM_ATTR_USE_CHANCTX, 137 HWSIM_ATTR_USE_CHANCTX,
137 HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, 138 HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE,
139 HWSIM_ATTR_RADIO_NAME,
138 __HWSIM_ATTR_MAX, 140 __HWSIM_ATTR_MAX,
139}; 141};
140#define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1) 142#define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1)