]> git.karo-electronics.de Git - linux-beck.git/commitdiff
cfg80211: remove wiphy_idx_valid
authorJohannes Berg <johannes.berg@intel.com>
Mon, 3 Dec 2012 17:23:37 +0000 (18:23 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 3 Jan 2013 12:01:23 +0000 (13:01 +0100)
This is pretty much useless since get_wiphy_idx()
always returns true since it's always called with
a valid wiphy pointer.

Acked-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/core.c
net/wireless/core.h
net/wireless/nl80211.c
net/wireless/reg.c

index 14d990400354200056e99d14132d6e7ab2504ccb..747dd9365a44ff7ce336c5db1f70d6a466cf6d0d 100644 (file)
@@ -57,9 +57,6 @@ struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx)
 {
        struct cfg80211_registered_device *result = NULL, *rdev;
 
-       if (!wiphy_idx_valid(wiphy_idx))
-               return NULL;
-
        assert_cfg80211_lock();
 
        list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
@@ -74,10 +71,8 @@ struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx)
 
 int get_wiphy_idx(struct wiphy *wiphy)
 {
-       struct cfg80211_registered_device *rdev;
-       if (!wiphy)
-               return WIPHY_IDX_STALE;
-       rdev = wiphy_to_dev(wiphy);
+       struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
+
        return rdev->wiphy_idx;
 }
 
@@ -86,9 +81,6 @@ struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx)
 {
        struct cfg80211_registered_device *rdev;
 
-       if (!wiphy_idx_valid(wiphy_idx))
-               return NULL;
-
        assert_cfg80211_lock();
 
        rdev = cfg80211_rdev_by_wiphy_idx(wiphy_idx);
@@ -309,7 +301,7 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
 
        rdev->wiphy_idx = wiphy_counter++;
 
-       if (unlikely(!wiphy_idx_valid(rdev->wiphy_idx))) {
+       if (unlikely(rdev->wiphy_idx < 0)) {
                wiphy_counter--;
                mutex_unlock(&cfg80211_mutex);
                /* ugh, wrapped! */
index 3563097169cb3ca8b767e9f5398a741c03a9885b..b8f4630c6ada34cae35ddad13ef45a96a7a30af9 100644 (file)
@@ -18,6 +18,9 @@
 #include <net/cfg80211.h>
 #include "reg.h"
 
+
+#define WIPHY_IDX_INVALID      -1
+
 struct cfg80211_registered_device {
        const struct cfg80211_ops *ops;
        struct list_head list;
@@ -96,13 +99,6 @@ struct cfg80211_registered_device *wiphy_to_dev(struct wiphy *wiphy)
        return container_of(wiphy, struct cfg80211_registered_device, wiphy);
 }
 
-/* Note 0 is valid, hence phy0 */
-static inline
-bool wiphy_idx_valid(int wiphy_idx)
-{
-       return wiphy_idx >= 0;
-}
-
 static inline void
 cfg80211_rdev_free_wowlan(struct cfg80211_registered_device *rdev)
 {
@@ -126,12 +122,6 @@ 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.
- * It guarantees cfg80211_rdev_by_wiphy_idx(wiphy_idx) will return NULL
- */
-#define WIPHY_IDX_STALE -1
-
 struct cfg80211_internal_bss {
        struct list_head list;
        struct rb_node rbn;
index a19583cf4b6e8b1378a1583e61aa7f2cc2d5ef0c..5fbc8cd9731b8007e484a8ed2ca932f35b56fb7e 100644 (file)
@@ -8048,7 +8048,7 @@ void nl80211_send_reg_change_event(struct regulatory_request *request)
                        goto nla_put_failure;
        }
 
-       if (wiphy_idx_valid(request->wiphy_idx) &&
+       if (request->wiphy_idx != WIPHY_IDX_INVALID &&
            nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx))
                goto nla_put_failure;
 
index 129586994662a00a5c8350048e917543a57f2403..b825c82e5a452701b114314d55f7cdb5e8b4a9e0 100644 (file)
@@ -1539,7 +1539,7 @@ static void reg_process_hint(struct regulatory_request *reg_request,
 
        BUG_ON(!reg_request->alpha2);
 
-       if (wiphy_idx_valid(reg_request->wiphy_idx))
+       if (reg_request->wiphy_idx != WIPHY_IDX_INVALID)
                wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx);
 
        if (reg_initiator == NL80211_REGDOM_SET_BY_DRIVER && !wiphy) {
@@ -1684,7 +1684,7 @@ int regulatory_hint_user(const char *alpha2,
        if (!request)
                return -ENOMEM;
 
-       request->wiphy_idx = WIPHY_IDX_STALE;
+       request->wiphy_idx = WIPHY_IDX_INVALID;
        request->alpha2[0] = alpha2[0];
        request->alpha2[1] = alpha2[1];
        request->initiator = NL80211_REGDOM_SET_BY_USER;
@@ -1709,9 +1709,6 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2)
 
        request->wiphy_idx = get_wiphy_idx(wiphy);
 
-       /* Must have registered wiphy first */
-       BUG_ON(!wiphy_idx_valid(request->wiphy_idx));
-
        request->alpha2[0] = alpha2[0];
        request->alpha2[1] = alpha2[1];
        request->initiator = NL80211_REGDOM_SET_BY_DRIVER;
@@ -1758,9 +1755,8 @@ void regulatory_hint_11d(struct wiphy *wiphy, enum ieee80211_band band,
         * We leave conflict resolution to the workqueue, where can hold
         * cfg80211_mutex.
         */
-       if (likely(last_request->initiator ==
-                  NL80211_REGDOM_SET_BY_COUNTRY_IE &&
-                  wiphy_idx_valid(last_request->wiphy_idx)))
+       if (last_request->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE &&
+           last_request->wiphy_idx != WIPHY_IDX_INVALID)
                goto out;
 
        request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
@@ -2317,7 +2313,7 @@ void wiphy_regulatory_deregister(struct wiphy *wiphy)
        if (!request_wiphy || request_wiphy != wiphy)
                goto out;
 
-       last_request->wiphy_idx = WIPHY_IDX_STALE;
+       last_request->wiphy_idx = WIPHY_IDX_INVALID;
        last_request->country_ie_env = ENVIRON_ANY;
 out:
        mutex_unlock(&reg_mutex);