diff options
| author | Michal Kazior <michal.kazior@tieto.com> | 2014-04-09 09:29:22 -0400 |
|---|---|---|
| committer | Johannes Berg <johannes.berg@intel.com> | 2014-04-25 11:08:14 -0400 |
| commit | 65a124dd719d6e90591e4756bb04e1719489705e (patch) | |
| tree | 6316d4354f73687799b3f53f29fe513bd627161b /net/wireless/util.c | |
| parent | 46d537245d8db96a4c282b449f8b582a71e5ec13 (diff) | |
cfg80211: allow drivers to iterate over matching combinations
The patch splits cfg80211_check_combinations()
into an iterator function and a simple iteration
user.
This makes it possible for drivers to asses how
many channels can use given iftype setup. This in
turn can be used for future
multi-interface/multi-channel channel switching.
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/util.c')
| -rw-r--r-- | net/wireless/util.c | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/net/wireless/util.c b/net/wireless/util.c index d032a31828f1..d8b599575a5e 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
| @@ -1263,10 +1263,13 @@ int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, | |||
| 1263 | return res; | 1263 | return res; |
| 1264 | } | 1264 | } |
| 1265 | 1265 | ||
| 1266 | int cfg80211_check_combinations(struct wiphy *wiphy, | 1266 | int cfg80211_iter_combinations(struct wiphy *wiphy, |
| 1267 | const int num_different_channels, | 1267 | const int num_different_channels, |
| 1268 | const u8 radar_detect, | 1268 | const u8 radar_detect, |
| 1269 | const int iftype_num[NUM_NL80211_IFTYPES]) | 1269 | const int iftype_num[NUM_NL80211_IFTYPES], |
| 1270 | void (*iter)(const struct ieee80211_iface_combination *c, | ||
| 1271 | void *data), | ||
| 1272 | void *data) | ||
| 1270 | { | 1273 | { |
| 1271 | int i, j, iftype; | 1274 | int i, j, iftype; |
| 1272 | int num_interfaces = 0; | 1275 | int num_interfaces = 0; |
| @@ -1323,13 +1326,40 @@ int cfg80211_check_combinations(struct wiphy *wiphy, | |||
| 1323 | /* This combination covered all interface types and | 1326 | /* This combination covered all interface types and |
| 1324 | * supported the requested numbers, so we're good. | 1327 | * supported the requested numbers, so we're good. |
| 1325 | */ | 1328 | */ |
| 1326 | kfree(limits); | 1329 | |
| 1327 | return 0; | 1330 | (*iter)(c, data); |
| 1328 | cont: | 1331 | cont: |
| 1329 | kfree(limits); | 1332 | kfree(limits); |
| 1330 | } | 1333 | } |
| 1331 | 1334 | ||
| 1332 | return -EBUSY; | 1335 | return 0; |
| 1336 | } | ||
| 1337 | EXPORT_SYMBOL(cfg80211_iter_combinations); | ||
| 1338 | |||
| 1339 | static void | ||
| 1340 | cfg80211_iter_sum_ifcombs(const struct ieee80211_iface_combination *c, | ||
| 1341 | void *data) | ||
| 1342 | { | ||
| 1343 | int *num = data; | ||
| 1344 | (*num)++; | ||
| 1345 | } | ||
| 1346 | |||
| 1347 | int cfg80211_check_combinations(struct wiphy *wiphy, | ||
| 1348 | const int num_different_channels, | ||
| 1349 | const u8 radar_detect, | ||
| 1350 | const int iftype_num[NUM_NL80211_IFTYPES]) | ||
| 1351 | { | ||
| 1352 | int err, num = 0; | ||
| 1353 | |||
| 1354 | err = cfg80211_iter_combinations(wiphy, num_different_channels, | ||
| 1355 | radar_detect, iftype_num, | ||
| 1356 | cfg80211_iter_sum_ifcombs, &num); | ||
| 1357 | if (err) | ||
| 1358 | return err; | ||
| 1359 | if (num == 0) | ||
| 1360 | return -EBUSY; | ||
| 1361 | |||
| 1362 | return 0; | ||
| 1333 | } | 1363 | } |
| 1334 | EXPORT_SYMBOL(cfg80211_check_combinations); | 1364 | EXPORT_SYMBOL(cfg80211_check_combinations); |
| 1335 | 1365 | ||
