aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/libertas/cfg.c7
-rw-r--r--include/net/cfg80211.h8
-rw-r--r--net/wireless/nl80211.c13
-rw-r--r--net/wireless/scan.c7
-rw-r--r--net/wireless/sme.c13
-rw-r--r--net/wireless/util.c13
6 files changed, 29 insertions, 32 deletions
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
index 116f4aba08d6..32f75007a825 100644
--- a/drivers/net/wireless/libertas/cfg.c
+++ b/drivers/net/wireless/libertas/cfg.c
@@ -1268,14 +1268,9 @@ static struct cfg80211_scan_request *
1268_new_connect_scan_req(struct wiphy *wiphy, struct cfg80211_connect_params *sme) 1268_new_connect_scan_req(struct wiphy *wiphy, struct cfg80211_connect_params *sme)
1269{ 1269{
1270 struct cfg80211_scan_request *creq = NULL; 1270 struct cfg80211_scan_request *creq = NULL;
1271 int i, n_channels = 0; 1271 int i, n_channels = ieee80211_get_num_supported_channels(wiphy);
1272 enum ieee80211_band band; 1272 enum ieee80211_band band;
1273 1273
1274 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
1275 if (wiphy->bands[band])
1276 n_channels += wiphy->bands[band]->n_channels;
1277 }
1278
1279 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + 1274 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) +
1280 n_channels * sizeof(void *), 1275 n_channels * sizeof(void *),
1281 GFP_ATOMIC); 1276 GFP_ATOMIC);
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 56c597793d6d..b1f84b05c67e 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4640,6 +4640,14 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
4640 */ 4640 */
4641void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp); 4641void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp);
4642 4642
4643/**
4644 * ieee80211_get_num_supported_channels - get number of channels device has
4645 * @wiphy: the wiphy
4646 *
4647 * Return: the number of channels supported by the device.
4648 */
4649unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy);
4650
4643/* Logging, debugging and troubleshooting/diagnostic helpers. */ 4651/* Logging, debugging and troubleshooting/diagnostic helpers. */
4644 4652
4645/* wiphy_printk helpers, similar to dev_printk */ 4653/* wiphy_printk helpers, similar to dev_printk */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 20857126f742..d0afd82ebd77 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5285,12 +5285,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
5285 goto unlock; 5285 goto unlock;
5286 } 5286 }
5287 } else { 5287 } else {
5288 enum ieee80211_band band; 5288 n_channels = ieee80211_get_num_supported_channels(wiphy);
5289 n_channels = 0;
5290
5291 for (band = 0; band < IEEE80211_NUM_BANDS; band++)
5292 if (wiphy->bands[band])
5293 n_channels += wiphy->bands[band]->n_channels;
5294 } 5289 }
5295 5290
5296 if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) 5291 if (info->attrs[NL80211_ATTR_SCAN_SSIDS])
@@ -5498,11 +5493,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
5498 if (!n_channels) 5493 if (!n_channels)
5499 return -EINVAL; 5494 return -EINVAL;
5500 } else { 5495 } else {
5501 n_channels = 0; 5496 n_channels = ieee80211_get_num_supported_channels(wiphy);
5502
5503 for (band = 0; band < IEEE80211_NUM_BANDS; band++)
5504 if (wiphy->bands[band])
5505 n_channels += wiphy->bands[band]->n_channels;
5506 } 5497 }
5507 5498
5508 if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) 5499 if (info->attrs[NL80211_ATTR_SCAN_SSIDS])
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index a32d52a04c27..b528e31da2cf 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -1089,11 +1089,8 @@ int cfg80211_wext_siwscan(struct net_device *dev,
1089 /* Determine number of channels, needed to allocate creq */ 1089 /* Determine number of channels, needed to allocate creq */
1090 if (wreq && wreq->num_channels) 1090 if (wreq && wreq->num_channels)
1091 n_channels = wreq->num_channels; 1091 n_channels = wreq->num_channels;
1092 else { 1092 else
1093 for (band = 0; band < IEEE80211_NUM_BANDS; band++) 1093 n_channels = ieee80211_get_num_supported_channels(wiphy);
1094 if (wiphy->bands[band])
1095 n_channels += wiphy->bands[band]->n_channels;
1096 }
1097 1094
1098 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + 1095 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) +
1099 n_channels * sizeof(void *), 1096 n_channels * sizeof(void *),
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 3f64202358f4..c854f1ce22db 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -70,18 +70,11 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
70 if (rdev->scan_req) 70 if (rdev->scan_req)
71 return -EBUSY; 71 return -EBUSY;
72 72
73 if (wdev->conn->params.channel) { 73 if (wdev->conn->params.channel)
74 n_channels = 1; 74 n_channels = 1;
75 } else { 75 else
76 enum ieee80211_band band; 76 n_channels = ieee80211_get_num_supported_channels(wdev->wiphy);
77 n_channels = 0;
78 77
79 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
80 if (!wdev->wiphy->bands[band])
81 continue;
82 n_channels += wdev->wiphy->bands[band]->n_channels;
83 }
84 }
85 request = kzalloc(sizeof(*request) + sizeof(request->ssids[0]) + 78 request = kzalloc(sizeof(*request) + sizeof(request->ssids[0]) +
86 sizeof(request->channels[0]) * n_channels, 79 sizeof(request->channels[0]) * n_channels,
87 GFP_KERNEL); 80 GFP_KERNEL);
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 329b0efb3ded..d39c37104ae2 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1481,6 +1481,19 @@ int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
1481 return 0; 1481 return 0;
1482} 1482}
1483 1483
1484unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy)
1485{
1486 enum ieee80211_band band;
1487 unsigned int n_channels = 0;
1488
1489 for (band = 0; band < IEEE80211_NUM_BANDS; band++)
1490 if (wiphy->bands[band])
1491 n_channels += wiphy->bands[band]->n_channels;
1492
1493 return n_channels;
1494}
1495EXPORT_SYMBOL(ieee80211_get_num_supported_channels);
1496
1484/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ 1497/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
1485/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ 1498/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
1486const unsigned char rfc1042_header[] __aligned(2) = 1499const unsigned char rfc1042_header[] __aligned(2) =