wifi: mac80211: use wiphy guard

The wiphy guard simplifies some code here, so use it.

Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://patch.msgid.link/20241122094225.cea65b2d2fd4.Icc168c4bbeddec98ea096aee9077211a7b88b69e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2024-11-22 09:42:26 +01:00
parent f42d22d3f7
commit 8e66f6c673
3 changed files with 17 additions and 30 deletions

View File

@ -284,7 +284,8 @@ static ssize_t aql_txq_limit_write(struct file *file,
q_limit_low_old = local->aql_txq_limit_low[ac]; q_limit_low_old = local->aql_txq_limit_low[ac];
q_limit_high_old = local->aql_txq_limit_high[ac]; q_limit_high_old = local->aql_txq_limit_high[ac];
wiphy_lock(local->hw.wiphy); guard(wiphy)(local->hw.wiphy);
local->aql_txq_limit_low[ac] = q_limit_low; local->aql_txq_limit_low[ac] = q_limit_low;
local->aql_txq_limit_high[ac] = q_limit_high; local->aql_txq_limit_high[ac] = q_limit_high;
@ -296,7 +297,6 @@ static ssize_t aql_txq_limit_write(struct file *file,
sta->airtime[ac].aql_limit_high = q_limit_high; sta->airtime[ac].aql_limit_high = q_limit_high;
} }
} }
wiphy_unlock(local->hw.wiphy);
return count; return count;
} }

View File

@ -19,16 +19,13 @@ static int ieee80211_set_ringparam(struct net_device *dev,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct ieee80211_local *local = wiphy_priv(dev->ieee80211_ptr->wiphy); struct ieee80211_local *local = wiphy_priv(dev->ieee80211_ptr->wiphy);
int ret;
if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0) if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0)
return -EINVAL; return -EINVAL;
wiphy_lock(local->hw.wiphy); guard(wiphy)(local->hw.wiphy);
ret = drv_set_ringparam(local, rp->tx_pending, rp->rx_pending);
wiphy_unlock(local->hw.wiphy);
return ret; return drv_set_ringparam(local, rp->tx_pending, rp->rx_pending);
} }
static void ieee80211_get_ringparam(struct net_device *dev, static void ieee80211_get_ringparam(struct net_device *dev,
@ -40,10 +37,10 @@ static void ieee80211_get_ringparam(struct net_device *dev,
memset(rp, 0, sizeof(*rp)); memset(rp, 0, sizeof(*rp));
wiphy_lock(local->hw.wiphy); guard(wiphy)(local->hw.wiphy);
drv_get_ringparam(local, &rp->tx_pending, &rp->tx_max_pending, drv_get_ringparam(local, &rp->tx_pending, &rp->tx_max_pending,
&rp->rx_pending, &rp->rx_max_pending); &rp->rx_pending, &rp->rx_max_pending);
wiphy_unlock(local->hw.wiphy);
} }
static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = { static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
@ -109,7 +106,7 @@ static void ieee80211_get_stats(struct net_device *dev,
* network device. * network device.
*/ */
wiphy_lock(local->hw.wiphy); guard(wiphy)(local->hw.wiphy);
if (sdata->vif.type == NL80211_IFTYPE_STATION) { if (sdata->vif.type == NL80211_IFTYPE_STATION) {
sta = sta_info_get_bss(sdata, sdata->deflink.u.mgd.bssid); sta = sta_info_get_bss(sdata, sdata->deflink.u.mgd.bssid);
@ -205,13 +202,10 @@ do_survey:
else else
data[i++] = -1LL; data[i++] = -1LL;
if (WARN_ON(i != STA_STATS_LEN)) { if (WARN_ON(i != STA_STATS_LEN))
wiphy_unlock(local->hw.wiphy);
return; return;
}
drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN])); drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
wiphy_unlock(local->hw.wiphy);
} }
static void ieee80211_get_strings(struct net_device *dev, u32 sset, u8 *data) static void ieee80211_get_strings(struct net_device *dev, u32 sset, u8 *data)

View File

@ -300,7 +300,6 @@ static int ieee80211_change_mac(struct net_device *dev, void *addr)
{ {
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
int ret;
/* /*
* This happens during unregistration if there's a bond device * This happens during unregistration if there's a bond device
@ -310,11 +309,9 @@ static int ieee80211_change_mac(struct net_device *dev, void *addr)
if (!dev->ieee80211_ptr->registered) if (!dev->ieee80211_ptr->registered)
return 0; return 0;
wiphy_lock(local->hw.wiphy); guard(wiphy)(local->hw.wiphy);
ret = _ieee80211_change_mac(sdata, addr);
wiphy_unlock(local->hw.wiphy);
return ret; return _ieee80211_change_mac(sdata, addr);
} }
static inline int identical_mac_addr_allowed(int type1, int type2) static inline int identical_mac_addr_allowed(int type1, int type2)
@ -450,16 +447,13 @@ static int ieee80211_open(struct net_device *dev)
if (!is_valid_ether_addr(dev->dev_addr)) if (!is_valid_ether_addr(dev->dev_addr))
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
wiphy_lock(sdata->local->hw.wiphy); guard(wiphy)(sdata->local->hw.wiphy);
err = ieee80211_check_concurrent_iface(sdata, sdata->vif.type); err = ieee80211_check_concurrent_iface(sdata, sdata->vif.type);
if (err) if (err)
goto out; return err;
err = ieee80211_do_open(&sdata->wdev, true); return ieee80211_do_open(&sdata->wdev, true);
out:
wiphy_unlock(sdata->local->hw.wiphy);
return err;
} }
static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_down) static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_down)
@ -780,11 +774,11 @@ static int ieee80211_stop(struct net_device *dev)
ieee80211_stop_mbssid(sdata); ieee80211_stop_mbssid(sdata);
} }
wiphy_lock(sdata->local->hw.wiphy); guard(wiphy)(sdata->local->hw.wiphy);
wiphy_work_cancel(sdata->local->hw.wiphy, &sdata->activate_links_work); wiphy_work_cancel(sdata->local->hw.wiphy, &sdata->activate_links_work);
ieee80211_do_stop(sdata, true); ieee80211_do_stop(sdata, true);
wiphy_unlock(sdata->local->hw.wiphy);
return 0; return 0;
} }
@ -2282,7 +2276,7 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
*/ */
cfg80211_shutdown_all_interfaces(local->hw.wiphy); cfg80211_shutdown_all_interfaces(local->hw.wiphy);
wiphy_lock(local->hw.wiphy); guard(wiphy)(local->hw.wiphy);
WARN(local->open_count, "%s: open count remains %d\n", WARN(local->open_count, "%s: open count remains %d\n",
wiphy_name(local->hw.wiphy), local->open_count); wiphy_name(local->hw.wiphy), local->open_count);
@ -2312,7 +2306,6 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
if (!netdev) if (!netdev)
kfree(sdata); kfree(sdata);
} }
wiphy_unlock(local->hw.wiphy);
} }
static int netdev_notify(struct notifier_block *nb, static int netdev_notify(struct notifier_block *nb,