[WIRELESS] cfg80211: Clarify locking comment.
This patch clarifies the comment about locking in wiphy_unregister. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a4d73ee168
commit
f16bfc1c09
|
@ -91,7 +91,6 @@ int wiphy_register(struct wiphy *wiphy)
|
||||||
|
|
||||||
mutex_lock(&cfg80211_drv_mutex);
|
mutex_lock(&cfg80211_drv_mutex);
|
||||||
|
|
||||||
|
|
||||||
res = device_add(&drv->wiphy.dev);
|
res = device_add(&drv->wiphy.dev);
|
||||||
if (res)
|
if (res)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
@ -114,14 +113,26 @@ void wiphy_unregister(struct wiphy *wiphy)
|
||||||
{
|
{
|
||||||
struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy);
|
struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy);
|
||||||
|
|
||||||
|
/* protect the device list */
|
||||||
mutex_lock(&cfg80211_drv_mutex);
|
mutex_lock(&cfg80211_drv_mutex);
|
||||||
|
|
||||||
/* hold registered driver mutex during list removal as well
|
BUG_ON(!list_empty(&drv->netdev_list));
|
||||||
* to make sure no commands are in progress at the moment */
|
|
||||||
|
/*
|
||||||
|
* Try to grab drv->mtx. If a command is still in progress,
|
||||||
|
* hopefully the driver will refuse it since it's tearing
|
||||||
|
* down the device already. We wait for this command to complete
|
||||||
|
* before unlinking the item from the list.
|
||||||
|
* Note: as codified by the BUG_ON above we cannot get here if
|
||||||
|
* a virtual interface is still associated. Hence, we can only
|
||||||
|
* get to lock contention here if userspace issues a command
|
||||||
|
* that identified the hardware by wiphy index.
|
||||||
|
*/
|
||||||
mutex_lock(&drv->mtx);
|
mutex_lock(&drv->mtx);
|
||||||
list_del(&drv->list);
|
/* unlock again before freeing */
|
||||||
mutex_unlock(&drv->mtx);
|
mutex_unlock(&drv->mtx);
|
||||||
|
|
||||||
|
list_del(&drv->list);
|
||||||
device_del(&drv->wiphy.dev);
|
device_del(&drv->wiphy.dev);
|
||||||
debugfs_remove(drv->wiphy.debugfsdir);
|
debugfs_remove(drv->wiphy.debugfsdir);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue