aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-02-21 00:24:15 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-02-27 14:53:00 -0500
commitd951c1ddeba3c84c464069c808efc494aa705304 (patch)
tree48d554a91830bd16955efaeb21a09f2b84b7f9fe /net/wireless
parent28da32d7cafdd181d6a59e8c0b74e9651a8f8be3 (diff)
cfg80211: do not kzalloc() again for a new request on __regulatory_hint
Since we already have a regulatory request from the workqueue use that and avoid a new kzalloc() Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/reg.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 6e1733733e18..6152a7ac9b90 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1341,7 +1341,6 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
1341static int __regulatory_hint(struct wiphy *wiphy, 1341static int __regulatory_hint(struct wiphy *wiphy,
1342 struct regulatory_request *pending_request) 1342 struct regulatory_request *pending_request)
1343{ 1343{
1344 struct regulatory_request *request;
1345 bool intersect = false; 1344 bool intersect = false;
1346 int r = 0; 1345 int r = 0;
1347 1346
@@ -1354,8 +1353,10 @@ static int __regulatory_hint(struct wiphy *wiphy,
1354 if (r == REG_INTERSECT) { 1353 if (r == REG_INTERSECT) {
1355 if (pending_request->initiator == REGDOM_SET_BY_DRIVER) { 1354 if (pending_request->initiator == REGDOM_SET_BY_DRIVER) {
1356 r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); 1355 r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
1357 if (r) 1356 if (r) {
1357 kfree(pending_request);
1358 return r; 1358 return r;
1359 }
1359 } 1360 }
1360 intersect = true; 1361 intersect = true;
1361 } else if (r) { 1362 } else if (r) {
@@ -1367,30 +1368,24 @@ static int __regulatory_hint(struct wiphy *wiphy,
1367 if (r == -EALREADY && 1368 if (r == -EALREADY &&
1368 pending_request->initiator == REGDOM_SET_BY_DRIVER) { 1369 pending_request->initiator == REGDOM_SET_BY_DRIVER) {
1369 r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); 1370 r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
1370 if (r) 1371 if (r) {
1372 kfree(pending_request);
1371 return r; 1373 return r;
1374 }
1372 r = -EALREADY; 1375 r = -EALREADY;
1373 goto new_request; 1376 goto new_request;
1374 } 1377 }
1378 kfree(pending_request);
1375 return r; 1379 return r;
1376 } 1380 }
1377 1381
1378new_request: 1382new_request:
1379 request = kzalloc(sizeof(struct regulatory_request), 1383 kfree(last_request);
1380 GFP_KERNEL);
1381 if (!request)
1382 return -ENOMEM;
1383 1384
1384 request->alpha2[0] = pending_request->alpha2[0]; 1385 last_request = pending_request;
1385 request->alpha2[1] = pending_request->alpha2[1]; 1386 last_request->intersect = intersect;
1386 request->initiator = pending_request->initiator;
1387 request->wiphy_idx = pending_request->wiphy_idx;
1388 request->intersect = intersect;
1389 request->country_ie_checksum = pending_request->country_ie_checksum;
1390 request->country_ie_env = pending_request->country_ie_env;
1391 1387
1392 kfree(last_request); 1388 pending_request = NULL;
1393 last_request = request;
1394 1389
1395 /* When r == REG_INTERSECT we do need to call CRDA */ 1390 /* When r == REG_INTERSECT we do need to call CRDA */
1396 if (r < 0) 1391 if (r < 0)
@@ -1406,11 +1401,11 @@ new_request:
1406 * 1401 *
1407 * to intersect with the static rd 1402 * to intersect with the static rd
1408 */ 1403 */
1409 return call_crda(request->alpha2); 1404 return call_crda(last_request->alpha2);
1410} 1405}
1411 1406
1412/* This currently only processes user and driver regulatory hints */ 1407/* This currently only processes user and driver regulatory hints */
1413static int reg_process_hint(struct regulatory_request *reg_request) 1408static void reg_process_hint(struct regulatory_request *reg_request)
1414{ 1409{
1415 int r = 0; 1410 int r = 0;
1416 struct wiphy *wiphy = NULL; 1411 struct wiphy *wiphy = NULL;
@@ -1424,7 +1419,7 @@ static int reg_process_hint(struct regulatory_request *reg_request)
1424 1419
1425 if (reg_request->initiator == REGDOM_SET_BY_DRIVER && 1420 if (reg_request->initiator == REGDOM_SET_BY_DRIVER &&
1426 !wiphy) { 1421 !wiphy) {
1427 r = -ENODEV; 1422 kfree(reg_request);
1428 goto out; 1423 goto out;
1429 } 1424 }
1430 1425
@@ -1434,18 +1429,12 @@ static int reg_process_hint(struct regulatory_request *reg_request)
1434 wiphy_update_regulatory(wiphy, reg_request->initiator); 1429 wiphy_update_regulatory(wiphy, reg_request->initiator);
1435out: 1430out:
1436 mutex_unlock(&cfg80211_mutex); 1431 mutex_unlock(&cfg80211_mutex);
1437
1438 if (r == -EALREADY)
1439 r = 0;
1440
1441 return r;
1442} 1432}
1443 1433
1444/* Processes regulatory hints, this is all the REGDOM_SET_BY_* */ 1434/* Processes regulatory hints, this is all the REGDOM_SET_BY_* */
1445static void reg_process_pending_hints(void) 1435static void reg_process_pending_hints(void)
1446 { 1436 {
1447 struct regulatory_request *reg_request; 1437 struct regulatory_request *reg_request;
1448 int r;
1449 1438
1450 spin_lock(&reg_requests_lock); 1439 spin_lock(&reg_requests_lock);
1451 while (!list_empty(&reg_requests_list)) { 1440 while (!list_empty(&reg_requests_list)) {
@@ -1453,20 +1442,9 @@ static void reg_process_pending_hints(void)
1453 struct regulatory_request, 1442 struct regulatory_request,
1454 list); 1443 list);
1455 list_del_init(&reg_request->list); 1444 list_del_init(&reg_request->list);
1456 spin_unlock(&reg_requests_lock);
1457 1445
1458 r = reg_process_hint(reg_request); 1446 spin_unlock(&reg_requests_lock);
1459#ifdef CONFIG_CFG80211_REG_DEBUG 1447 reg_process_hint(reg_request);
1460 if (r && (reg_request->initiator == REGDOM_SET_BY_DRIVER ||
1461 reg_request->initiator == REGDOM_SET_BY_COUNTRY_IE))
1462 printk(KERN_ERR "cfg80211: wiphy_idx %d sent a "
1463 "regulatory hint for %c%c but now has "
1464 "gone fishing, ignoring request\n",
1465 reg_request->wiphy_idx,
1466 reg_request->alpha2[0],
1467 reg_request->alpha2[1]);
1468#endif
1469 kfree(reg_request);
1470 spin_lock(&reg_requests_lock); 1448 spin_lock(&reg_requests_lock);
1471 } 1449 }
1472 spin_unlock(&reg_requests_lock); 1450 spin_unlock(&reg_requests_lock);