aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/reg.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-12-03 11:32:01 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-01-03 07:01:21 -0500
commitfea9bcedce2d0c751d4f31155f4634689d46166e (patch)
tree92d842c278f0a5aad703d977fdd6f5b471e0f6e2 /net/wireless/reg.c
parente9763c3c295a8b31316e16558b58b226e005b160 (diff)
regulatory: don't test list before iterating
There's no need to test whether a list is empty or not before iterating. Acked-by: Luis R. Rodriguez <mcgrof@do-not-panic.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/reg.c')
-rw-r--r--net/wireless/reg.c66
1 files changed, 19 insertions, 47 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 52a3598859cd..1496a10da638 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1104,9 +1104,6 @@ static void wiphy_update_beacon_reg(struct wiphy *wiphy)
1104 1104
1105 assert_cfg80211_lock(); 1105 assert_cfg80211_lock();
1106 1106
1107 if (list_empty(&reg_beacon_list))
1108 return;
1109
1110 list_for_each_entry(reg_beacon, &reg_beacon_list, list) { 1107 list_for_each_entry(reg_beacon, &reg_beacon_list, list) {
1111 if (!wiphy->bands[reg_beacon->chan.band]) 1108 if (!wiphy->bands[reg_beacon->chan.band])
1112 continue; 1109 continue;
@@ -1666,11 +1663,6 @@ static void reg_process_pending_beacon_hints(void)
1666 /* This goes through the _pending_ beacon list */ 1663 /* This goes through the _pending_ beacon list */
1667 spin_lock_bh(&reg_pending_beacons_lock); 1664 spin_lock_bh(&reg_pending_beacons_lock);
1668 1665
1669 if (list_empty(&reg_pending_beacons)) {
1670 spin_unlock_bh(&reg_pending_beacons_lock);
1671 goto out;
1672 }
1673
1674 list_for_each_entry_safe(pending_beacon, tmp, 1666 list_for_each_entry_safe(pending_beacon, tmp,
1675 &reg_pending_beacons, list) { 1667 &reg_pending_beacons, list) {
1676 1668
@@ -1685,7 +1677,6 @@ static void reg_process_pending_beacon_hints(void)
1685 } 1677 }
1686 1678
1687 spin_unlock_bh(&reg_pending_beacons_lock); 1679 spin_unlock_bh(&reg_pending_beacons_lock);
1688out:
1689 mutex_unlock(&cfg80211_mutex); 1680 mutex_unlock(&cfg80211_mutex);
1690} 1681}
1691 1682
@@ -1949,34 +1940,24 @@ static void restore_regulatory_settings(bool reset_user)
1949 * settings. 1940 * settings.
1950 */ 1941 */
1951 spin_lock(&reg_requests_lock); 1942 spin_lock(&reg_requests_lock);
1952 if (!list_empty(&reg_requests_list)) { 1943 list_for_each_entry_safe(reg_request, tmp, &reg_requests_list, list) {
1953 list_for_each_entry_safe(reg_request, tmp, 1944 if (reg_request->initiator != NL80211_REGDOM_SET_BY_USER)
1954 &reg_requests_list, list) { 1945 continue;
1955 if (reg_request->initiator != 1946 list_move_tail(&reg_request->list, &tmp_reg_req_list);
1956 NL80211_REGDOM_SET_BY_USER)
1957 continue;
1958 list_move_tail(&reg_request->list, &tmp_reg_req_list);
1959 }
1960 } 1947 }
1961 spin_unlock(&reg_requests_lock); 1948 spin_unlock(&reg_requests_lock);
1962 1949
1963 /* Clear beacon hints */ 1950 /* Clear beacon hints */
1964 spin_lock_bh(&reg_pending_beacons_lock); 1951 spin_lock_bh(&reg_pending_beacons_lock);
1965 if (!list_empty(&reg_pending_beacons)) { 1952 list_for_each_entry_safe(reg_beacon, btmp, &reg_pending_beacons, list) {
1966 list_for_each_entry_safe(reg_beacon, btmp, 1953 list_del(&reg_beacon->list);
1967 &reg_pending_beacons, list) { 1954 kfree(reg_beacon);
1968 list_del(&reg_beacon->list);
1969 kfree(reg_beacon);
1970 }
1971 } 1955 }
1972 spin_unlock_bh(&reg_pending_beacons_lock); 1956 spin_unlock_bh(&reg_pending_beacons_lock);
1973 1957
1974 if (!list_empty(&reg_beacon_list)) { 1958 list_for_each_entry_safe(reg_beacon, btmp, &reg_beacon_list, list) {
1975 list_for_each_entry_safe(reg_beacon, btmp, 1959 list_del(&reg_beacon->list);
1976 &reg_beacon_list, list) { 1960 kfree(reg_beacon);
1977 list_del(&reg_beacon->list);
1978 kfree(reg_beacon);
1979 }
1980 } 1961 }
1981 1962
1982 /* First restore to the basic regulatory settings */ 1963 /* First restore to the basic regulatory settings */
@@ -2490,30 +2471,21 @@ void /* __init_or_exit */ regulatory_exit(void)
2490 platform_device_unregister(reg_pdev); 2471 platform_device_unregister(reg_pdev);
2491 2472
2492 spin_lock_bh(&reg_pending_beacons_lock); 2473 spin_lock_bh(&reg_pending_beacons_lock);
2493 if (!list_empty(&reg_pending_beacons)) { 2474 list_for_each_entry_safe(reg_beacon, btmp, &reg_pending_beacons, list) {
2494 list_for_each_entry_safe(reg_beacon, btmp, 2475 list_del(&reg_beacon->list);
2495 &reg_pending_beacons, list) { 2476 kfree(reg_beacon);
2496 list_del(&reg_beacon->list);
2497 kfree(reg_beacon);
2498 }
2499 } 2477 }
2500 spin_unlock_bh(&reg_pending_beacons_lock); 2478 spin_unlock_bh(&reg_pending_beacons_lock);
2501 2479
2502 if (!list_empty(&reg_beacon_list)) { 2480 list_for_each_entry_safe(reg_beacon, btmp, &reg_beacon_list, list) {
2503 list_for_each_entry_safe(reg_beacon, btmp, 2481 list_del(&reg_beacon->list);
2504 &reg_beacon_list, list) { 2482 kfree(reg_beacon);
2505 list_del(&reg_beacon->list);
2506 kfree(reg_beacon);
2507 }
2508 } 2483 }
2509 2484
2510 spin_lock(&reg_requests_lock); 2485 spin_lock(&reg_requests_lock);
2511 if (!list_empty(&reg_requests_list)) { 2486 list_for_each_entry_safe(reg_request, tmp, &reg_requests_list, list) {
2512 list_for_each_entry_safe(reg_request, tmp, 2487 list_del(&reg_request->list);
2513 &reg_requests_list, list) { 2488 kfree(reg_request);
2514 list_del(&reg_request->list);
2515 kfree(reg_request);
2516 }
2517 } 2489 }
2518 spin_unlock(&reg_requests_lock); 2490 spin_unlock(&reg_requests_lock);
2519 2491