diff options
author | Johannes Berg <johannes.berg@intel.com> | 2012-12-03 12:23:37 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-01-03 07:01:23 -0500 |
commit | f41737669d2f4c07c09e90767498243e142171f9 (patch) | |
tree | 2ac531e5ec1ffefe17f4bb81b0d8d420e48f9499 | |
parent | 2f92212b71f198d42060f7133ff1dc4edf438f6c (diff) |
cfg80211: remove wiphy_idx_valid
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>
-rw-r--r-- | net/wireless/core.c | 14 | ||||
-rw-r--r-- | net/wireless/core.h | 16 | ||||
-rw-r--r-- | net/wireless/nl80211.c | 2 | ||||
-rw-r--r-- | net/wireless/reg.c | 14 |
4 files changed, 12 insertions, 34 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c index 14d990400354..747dd9365a44 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -57,9 +57,6 @@ struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx) | |||
57 | { | 57 | { |
58 | struct cfg80211_registered_device *result = NULL, *rdev; | 58 | struct cfg80211_registered_device *result = NULL, *rdev; |
59 | 59 | ||
60 | if (!wiphy_idx_valid(wiphy_idx)) | ||
61 | return NULL; | ||
62 | |||
63 | assert_cfg80211_lock(); | 60 | assert_cfg80211_lock(); |
64 | 61 | ||
65 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) { | 62 | 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) | |||
74 | 71 | ||
75 | int get_wiphy_idx(struct wiphy *wiphy) | 72 | int get_wiphy_idx(struct wiphy *wiphy) |
76 | { | 73 | { |
77 | struct cfg80211_registered_device *rdev; | 74 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
78 | if (!wiphy) | 75 | |
79 | return WIPHY_IDX_STALE; | ||
80 | rdev = wiphy_to_dev(wiphy); | ||
81 | return rdev->wiphy_idx; | 76 | return rdev->wiphy_idx; |
82 | } | 77 | } |
83 | 78 | ||
@@ -86,9 +81,6 @@ struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx) | |||
86 | { | 81 | { |
87 | struct cfg80211_registered_device *rdev; | 82 | struct cfg80211_registered_device *rdev; |
88 | 83 | ||
89 | if (!wiphy_idx_valid(wiphy_idx)) | ||
90 | return NULL; | ||
91 | |||
92 | assert_cfg80211_lock(); | 84 | assert_cfg80211_lock(); |
93 | 85 | ||
94 | rdev = cfg80211_rdev_by_wiphy_idx(wiphy_idx); | 86 | rdev = cfg80211_rdev_by_wiphy_idx(wiphy_idx); |
@@ -309,7 +301,7 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv) | |||
309 | 301 | ||
310 | rdev->wiphy_idx = wiphy_counter++; | 302 | rdev->wiphy_idx = wiphy_counter++; |
311 | 303 | ||
312 | if (unlikely(!wiphy_idx_valid(rdev->wiphy_idx))) { | 304 | if (unlikely(rdev->wiphy_idx < 0)) { |
313 | wiphy_counter--; | 305 | wiphy_counter--; |
314 | mutex_unlock(&cfg80211_mutex); | 306 | mutex_unlock(&cfg80211_mutex); |
315 | /* ugh, wrapped! */ | 307 | /* ugh, wrapped! */ |
diff --git a/net/wireless/core.h b/net/wireless/core.h index 3563097169cb..b8f4630c6ada 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h | |||
@@ -18,6 +18,9 @@ | |||
18 | #include <net/cfg80211.h> | 18 | #include <net/cfg80211.h> |
19 | #include "reg.h" | 19 | #include "reg.h" |
20 | 20 | ||
21 | |||
22 | #define WIPHY_IDX_INVALID -1 | ||
23 | |||
21 | struct cfg80211_registered_device { | 24 | struct cfg80211_registered_device { |
22 | const struct cfg80211_ops *ops; | 25 | const struct cfg80211_ops *ops; |
23 | struct list_head list; | 26 | struct list_head list; |
@@ -96,13 +99,6 @@ struct cfg80211_registered_device *wiphy_to_dev(struct wiphy *wiphy) | |||
96 | return container_of(wiphy, struct cfg80211_registered_device, wiphy); | 99 | return container_of(wiphy, struct cfg80211_registered_device, wiphy); |
97 | } | 100 | } |
98 | 101 | ||
99 | /* Note 0 is valid, hence phy0 */ | ||
100 | static inline | ||
101 | bool wiphy_idx_valid(int wiphy_idx) | ||
102 | { | ||
103 | return wiphy_idx >= 0; | ||
104 | } | ||
105 | |||
106 | static inline void | 102 | static inline void |
107 | cfg80211_rdev_free_wowlan(struct cfg80211_registered_device *rdev) | 103 | cfg80211_rdev_free_wowlan(struct cfg80211_registered_device *rdev) |
108 | { | 104 | { |
@@ -126,12 +122,6 @@ static inline void assert_cfg80211_lock(void) | |||
126 | lockdep_assert_held(&cfg80211_mutex); | 122 | lockdep_assert_held(&cfg80211_mutex); |
127 | } | 123 | } |
128 | 124 | ||
129 | /* | ||
130 | * You can use this to mark a wiphy_idx as not having an associated wiphy. | ||
131 | * It guarantees cfg80211_rdev_by_wiphy_idx(wiphy_idx) will return NULL | ||
132 | */ | ||
133 | #define WIPHY_IDX_STALE -1 | ||
134 | |||
135 | struct cfg80211_internal_bss { | 125 | struct cfg80211_internal_bss { |
136 | struct list_head list; | 126 | struct list_head list; |
137 | struct rb_node rbn; | 127 | struct rb_node rbn; |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index a19583cf4b6e..5fbc8cd9731b 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -8048,7 +8048,7 @@ void nl80211_send_reg_change_event(struct regulatory_request *request) | |||
8048 | goto nla_put_failure; | 8048 | goto nla_put_failure; |
8049 | } | 8049 | } |
8050 | 8050 | ||
8051 | if (wiphy_idx_valid(request->wiphy_idx) && | 8051 | if (request->wiphy_idx != WIPHY_IDX_INVALID && |
8052 | nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx)) | 8052 | nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx)) |
8053 | goto nla_put_failure; | 8053 | goto nla_put_failure; |
8054 | 8054 | ||
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 129586994662..b825c82e5a45 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -1539,7 +1539,7 @@ static void reg_process_hint(struct regulatory_request *reg_request, | |||
1539 | 1539 | ||
1540 | BUG_ON(!reg_request->alpha2); | 1540 | BUG_ON(!reg_request->alpha2); |
1541 | 1541 | ||
1542 | if (wiphy_idx_valid(reg_request->wiphy_idx)) | 1542 | if (reg_request->wiphy_idx != WIPHY_IDX_INVALID) |
1543 | wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); | 1543 | wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); |
1544 | 1544 | ||
1545 | if (reg_initiator == NL80211_REGDOM_SET_BY_DRIVER && !wiphy) { | 1545 | if (reg_initiator == NL80211_REGDOM_SET_BY_DRIVER && !wiphy) { |
@@ -1684,7 +1684,7 @@ int regulatory_hint_user(const char *alpha2, | |||
1684 | if (!request) | 1684 | if (!request) |
1685 | return -ENOMEM; | 1685 | return -ENOMEM; |
1686 | 1686 | ||
1687 | request->wiphy_idx = WIPHY_IDX_STALE; | 1687 | request->wiphy_idx = WIPHY_IDX_INVALID; |
1688 | request->alpha2[0] = alpha2[0]; | 1688 | request->alpha2[0] = alpha2[0]; |
1689 | request->alpha2[1] = alpha2[1]; | 1689 | request->alpha2[1] = alpha2[1]; |
1690 | request->initiator = NL80211_REGDOM_SET_BY_USER; | 1690 | request->initiator = NL80211_REGDOM_SET_BY_USER; |
@@ -1709,9 +1709,6 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2) | |||
1709 | 1709 | ||
1710 | request->wiphy_idx = get_wiphy_idx(wiphy); | 1710 | request->wiphy_idx = get_wiphy_idx(wiphy); |
1711 | 1711 | ||
1712 | /* Must have registered wiphy first */ | ||
1713 | BUG_ON(!wiphy_idx_valid(request->wiphy_idx)); | ||
1714 | |||
1715 | request->alpha2[0] = alpha2[0]; | 1712 | request->alpha2[0] = alpha2[0]; |
1716 | request->alpha2[1] = alpha2[1]; | 1713 | request->alpha2[1] = alpha2[1]; |
1717 | request->initiator = NL80211_REGDOM_SET_BY_DRIVER; | 1714 | request->initiator = NL80211_REGDOM_SET_BY_DRIVER; |
@@ -1758,9 +1755,8 @@ void regulatory_hint_11d(struct wiphy *wiphy, enum ieee80211_band band, | |||
1758 | * We leave conflict resolution to the workqueue, where can hold | 1755 | * We leave conflict resolution to the workqueue, where can hold |
1759 | * cfg80211_mutex. | 1756 | * cfg80211_mutex. |
1760 | */ | 1757 | */ |
1761 | if (likely(last_request->initiator == | 1758 | if (last_request->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE && |
1762 | NL80211_REGDOM_SET_BY_COUNTRY_IE && | 1759 | last_request->wiphy_idx != WIPHY_IDX_INVALID) |
1763 | wiphy_idx_valid(last_request->wiphy_idx))) | ||
1764 | goto out; | 1760 | goto out; |
1765 | 1761 | ||
1766 | request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); | 1762 | request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); |
@@ -2317,7 +2313,7 @@ void wiphy_regulatory_deregister(struct wiphy *wiphy) | |||
2317 | if (!request_wiphy || request_wiphy != wiphy) | 2313 | if (!request_wiphy || request_wiphy != wiphy) |
2318 | goto out; | 2314 | goto out; |
2319 | 2315 | ||
2320 | last_request->wiphy_idx = WIPHY_IDX_STALE; | 2316 | last_request->wiphy_idx = WIPHY_IDX_INVALID; |
2321 | last_request->country_ie_env = ENVIRON_ANY; | 2317 | last_request->country_ie_env = ENVIRON_ANY; |
2322 | out: | 2318 | out: |
2323 | mutex_unlock(®_mutex); | 2319 | mutex_unlock(®_mutex); |