Skip to content

Commit

Permalink
cfg80211/mac80211: use lockdep_assert_held
Browse files Browse the repository at this point in the history
Instead of using a WARN_ON(!mutex_is_locked())
use lockdep_assert_held() which compiles away
completely when lockdep isn't enabled, and
also is a more accurate assertion since it
checks that the current thread is holding the
mutex.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Johannes Berg authored and John W. Linville committed Sep 16, 2010
1 parent f5521b1 commit 46a5eba
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion net/mac80211/chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ __ieee80211_get_channel_mode(struct ieee80211_local *local,
{
struct ieee80211_sub_if_data *sdata;

WARN_ON(!mutex_is_locked(&local->iflist_mtx));
lockdep_assert_held(&local->iflist_mtx);

list_for_each_entry(sdata, &local->interfaces, list) {
if (sdata == ignore)
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };

static void assert_key_lock(struct ieee80211_local *local)
{
WARN_ON(!mutex_is_locked(&local->key_mtx));
lockdep_assert_held(&local->key_mtx);
}

static struct ieee80211_sta *get_sta_for_key(struct ieee80211_key *key)
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ enum rx_mgmt_action {
/* utils */
static inline void ASSERT_MGD_MTX(struct ieee80211_if_managed *ifmgd)
{
WARN_ON(!mutex_is_locked(&ifmgd->mtx));
lockdep_assert_held(&ifmgd->mtx);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/sta_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static int sta_info_finish_insert(struct sta_info *sta, bool async)
unsigned long flags;
int err = 0;

WARN_ON(!mutex_is_locked(&local->sta_mtx));
lockdep_assert_held(&local->sta_mtx);

/* notify driver */
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
Expand Down
4 changes: 2 additions & 2 deletions net/mac80211/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1296,9 +1296,9 @@ void ieee80211_recalc_smps(struct ieee80211_local *local,
int count = 0;

if (forsdata)
WARN_ON(!mutex_is_locked(&forsdata->u.mgd.mtx));
lockdep_assert_held(&forsdata->u.mgd.mtx);

WARN_ON(!mutex_is_locked(&local->iflist_mtx));
lockdep_assert_held(&local->iflist_mtx);

/*
* This function could be improved to handle multiple
Expand Down
9 changes: 6 additions & 3 deletions net/wireless/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ extern struct mutex cfg80211_mutex;
extern struct list_head cfg80211_rdev_list;
extern int cfg80211_rdev_list_generation;

#define assert_cfg80211_lock() WARN_ON(!mutex_is_locked(&cfg80211_mutex))
static inline void assert_cfg80211_lock(void)
{
lockdep_assert_held(&cfg80211_mutex);
}

/*
* You can use this to mark a wiphy_idx as not having an associated wiphy.
Expand Down Expand Up @@ -202,8 +205,8 @@ static inline void wdev_unlock(struct wireless_dev *wdev)
mutex_unlock(&wdev->mtx);
}

#define ASSERT_RDEV_LOCK(rdev) WARN_ON(!mutex_is_locked(&(rdev)->mtx));
#define ASSERT_WDEV_LOCK(wdev) WARN_ON(!mutex_is_locked(&(wdev)->mtx));
#define ASSERT_RDEV_LOCK(rdev) lockdep_assert_held(&(rdev)->mtx)
#define ASSERT_WDEV_LOCK(wdev) lockdep_assert_held(&(wdev)->mtx)

enum cfg80211_event_type {
EVENT_CONNECT_RESULT,
Expand Down
6 changes: 5 additions & 1 deletion net/wireless/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ const struct ieee80211_regdomain *cfg80211_regdomain;
* - last_request
*/
static DEFINE_MUTEX(reg_mutex);
#define assert_reg_lock() WARN_ON(!mutex_is_locked(&reg_mutex))

static inline void assert_reg_lock(void)
{
lockdep_assert_held(&reg_mutex);
}

/* Used to queue up regulatory hints */
static LIST_HEAD(reg_requests_list);
Expand Down

0 comments on commit 46a5eba

Please sign in to comment.