aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/scan.c
diff options
context:
space:
mode:
authorZhao, Gang <gamerh2o@gmail.com>2014-04-21 00:53:02 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-04-25 11:32:56 -0400
commit1b8ec87aa077c527c9e3525e16098ca7efbc853d (patch)
tree5bc41e5194c59c88d3b27b637410c27c4a2a207e /net/wireless/scan.c
parent308f7fcfdba47f24cd70cba978fd10fb4584e61c (diff)
cfg80211: change registered device pointer name
Name "dev" is too common and ambiguous, let all the pointer name pointing to struct cfg80211_registered_device be "rdev". This can improve code readability and consistency(since other places have already called it rdev). Signed-off-by: Zhao, Gang <gamerh2o@gmail.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/scan.c')
-rw-r--r--net/wireless/scan.c130
1 files changed, 65 insertions, 65 deletions
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index cf478c075ddc..6d6f082b7bb8 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -81,10 +81,10 @@ static void bss_free(struct cfg80211_internal_bss *bss)
81 kfree(bss); 81 kfree(bss);
82} 82}
83 83
84static inline void bss_ref_get(struct cfg80211_registered_device *dev, 84static inline void bss_ref_get(struct cfg80211_registered_device *rdev,
85 struct cfg80211_internal_bss *bss) 85 struct cfg80211_internal_bss *bss)
86{ 86{
87 lockdep_assert_held(&dev->bss_lock); 87 lockdep_assert_held(&rdev->bss_lock);
88 88
89 bss->refcount++; 89 bss->refcount++;
90 if (bss->pub.hidden_beacon_bss) { 90 if (bss->pub.hidden_beacon_bss) {
@@ -95,10 +95,10 @@ static inline void bss_ref_get(struct cfg80211_registered_device *dev,
95 } 95 }
96} 96}
97 97
98static inline void bss_ref_put(struct cfg80211_registered_device *dev, 98static inline void bss_ref_put(struct cfg80211_registered_device *rdev,
99 struct cfg80211_internal_bss *bss) 99 struct cfg80211_internal_bss *bss)
100{ 100{
101 lockdep_assert_held(&dev->bss_lock); 101 lockdep_assert_held(&rdev->bss_lock);
102 102
103 if (bss->pub.hidden_beacon_bss) { 103 if (bss->pub.hidden_beacon_bss) {
104 struct cfg80211_internal_bss *hbss; 104 struct cfg80211_internal_bss *hbss;
@@ -114,10 +114,10 @@ static inline void bss_ref_put(struct cfg80211_registered_device *dev,
114 bss_free(bss); 114 bss_free(bss);
115} 115}
116 116
117static bool __cfg80211_unlink_bss(struct cfg80211_registered_device *dev, 117static bool __cfg80211_unlink_bss(struct cfg80211_registered_device *rdev,
118 struct cfg80211_internal_bss *bss) 118 struct cfg80211_internal_bss *bss)
119{ 119{
120 lockdep_assert_held(&dev->bss_lock); 120 lockdep_assert_held(&rdev->bss_lock);
121 121
122 if (!list_empty(&bss->hidden_list)) { 122 if (!list_empty(&bss->hidden_list)) {
123 /* 123 /*
@@ -134,31 +134,31 @@ static bool __cfg80211_unlink_bss(struct cfg80211_registered_device *dev,
134 } 134 }
135 135
136 list_del_init(&bss->list); 136 list_del_init(&bss->list);
137 rb_erase(&bss->rbn, &dev->bss_tree); 137 rb_erase(&bss->rbn, &rdev->bss_tree);
138 bss_ref_put(dev, bss); 138 bss_ref_put(rdev, bss);
139 return true; 139 return true;
140} 140}
141 141
142static void __cfg80211_bss_expire(struct cfg80211_registered_device *dev, 142static void __cfg80211_bss_expire(struct cfg80211_registered_device *rdev,
143 unsigned long expire_time) 143 unsigned long expire_time)
144{ 144{
145 struct cfg80211_internal_bss *bss, *tmp; 145 struct cfg80211_internal_bss *bss, *tmp;
146 bool expired = false; 146 bool expired = false;
147 147
148 lockdep_assert_held(&dev->bss_lock); 148 lockdep_assert_held(&rdev->bss_lock);
149 149
150 list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) { 150 list_for_each_entry_safe(bss, tmp, &rdev->bss_list, list) {
151 if (atomic_read(&bss->hold)) 151 if (atomic_read(&bss->hold))
152 continue; 152 continue;
153 if (!time_after(expire_time, bss->ts)) 153 if (!time_after(expire_time, bss->ts))
154 continue; 154 continue;
155 155
156 if (__cfg80211_unlink_bss(dev, bss)) 156 if (__cfg80211_unlink_bss(rdev, bss))
157 expired = true; 157 expired = true;
158 } 158 }
159 159
160 if (expired) 160 if (expired)
161 dev->bss_generation++; 161 rdev->bss_generation++;
162} 162}
163 163
164void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, 164void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
@@ -322,21 +322,21 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
322 return 0; 322 return 0;
323} 323}
324 324
325void cfg80211_bss_age(struct cfg80211_registered_device *dev, 325void cfg80211_bss_age(struct cfg80211_registered_device *rdev,
326 unsigned long age_secs) 326 unsigned long age_secs)
327{ 327{
328 struct cfg80211_internal_bss *bss; 328 struct cfg80211_internal_bss *bss;
329 unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC); 329 unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC);
330 330
331 spin_lock_bh(&dev->bss_lock); 331 spin_lock_bh(&rdev->bss_lock);
332 list_for_each_entry(bss, &dev->bss_list, list) 332 list_for_each_entry(bss, &rdev->bss_list, list)
333 bss->ts -= age_jiffies; 333 bss->ts -= age_jiffies;
334 spin_unlock_bh(&dev->bss_lock); 334 spin_unlock_bh(&rdev->bss_lock);
335} 335}
336 336
337void cfg80211_bss_expire(struct cfg80211_registered_device *dev) 337void cfg80211_bss_expire(struct cfg80211_registered_device *rdev)
338{ 338{
339 __cfg80211_bss_expire(dev, jiffies - IEEE80211_SCAN_RESULT_EXPIRE); 339 __cfg80211_bss_expire(rdev, jiffies - IEEE80211_SCAN_RESULT_EXPIRE);
340} 340}
341 341
342const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len) 342const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
@@ -526,16 +526,16 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
526 const u8 *ssid, size_t ssid_len, 526 const u8 *ssid, size_t ssid_len,
527 u16 capa_mask, u16 capa_val) 527 u16 capa_mask, u16 capa_val)
528{ 528{
529 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy); 529 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
530 struct cfg80211_internal_bss *bss, *res = NULL; 530 struct cfg80211_internal_bss *bss, *res = NULL;
531 unsigned long now = jiffies; 531 unsigned long now = jiffies;
532 532
533 trace_cfg80211_get_bss(wiphy, channel, bssid, ssid, ssid_len, capa_mask, 533 trace_cfg80211_get_bss(wiphy, channel, bssid, ssid, ssid_len, capa_mask,
534 capa_val); 534 capa_val);
535 535
536 spin_lock_bh(&dev->bss_lock); 536 spin_lock_bh(&rdev->bss_lock);
537 537
538 list_for_each_entry(bss, &dev->bss_list, list) { 538 list_for_each_entry(bss, &rdev->bss_list, list) {
539 if ((bss->pub.capability & capa_mask) != capa_val) 539 if ((bss->pub.capability & capa_mask) != capa_val)
540 continue; 540 continue;
541 if (channel && bss->pub.channel != channel) 541 if (channel && bss->pub.channel != channel)
@@ -548,12 +548,12 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
548 continue; 548 continue;
549 if (is_bss(&bss->pub, bssid, ssid, ssid_len)) { 549 if (is_bss(&bss->pub, bssid, ssid, ssid_len)) {
550 res = bss; 550 res = bss;
551 bss_ref_get(dev, res); 551 bss_ref_get(rdev, res);
552 break; 552 break;
553 } 553 }
554 } 554 }
555 555
556 spin_unlock_bh(&dev->bss_lock); 556 spin_unlock_bh(&rdev->bss_lock);
557 if (!res) 557 if (!res)
558 return NULL; 558 return NULL;
559 trace_cfg80211_return_bss(&res->pub); 559 trace_cfg80211_return_bss(&res->pub);
@@ -561,10 +561,10 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
561} 561}
562EXPORT_SYMBOL(cfg80211_get_bss); 562EXPORT_SYMBOL(cfg80211_get_bss);
563 563
564static void rb_insert_bss(struct cfg80211_registered_device *dev, 564static void rb_insert_bss(struct cfg80211_registered_device *rdev,
565 struct cfg80211_internal_bss *bss) 565 struct cfg80211_internal_bss *bss)
566{ 566{
567 struct rb_node **p = &dev->bss_tree.rb_node; 567 struct rb_node **p = &rdev->bss_tree.rb_node;
568 struct rb_node *parent = NULL; 568 struct rb_node *parent = NULL;
569 struct cfg80211_internal_bss *tbss; 569 struct cfg80211_internal_bss *tbss;
570 int cmp; 570 int cmp;
@@ -587,15 +587,15 @@ static void rb_insert_bss(struct cfg80211_registered_device *dev,
587 } 587 }
588 588
589 rb_link_node(&bss->rbn, parent, p); 589 rb_link_node(&bss->rbn, parent, p);
590 rb_insert_color(&bss->rbn, &dev->bss_tree); 590 rb_insert_color(&bss->rbn, &rdev->bss_tree);
591} 591}
592 592
593static struct cfg80211_internal_bss * 593static struct cfg80211_internal_bss *
594rb_find_bss(struct cfg80211_registered_device *dev, 594rb_find_bss(struct cfg80211_registered_device *rdev,
595 struct cfg80211_internal_bss *res, 595 struct cfg80211_internal_bss *res,
596 enum bss_compare_mode mode) 596 enum bss_compare_mode mode)
597{ 597{
598 struct rb_node *n = dev->bss_tree.rb_node; 598 struct rb_node *n = rdev->bss_tree.rb_node;
599 struct cfg80211_internal_bss *bss; 599 struct cfg80211_internal_bss *bss;
600 int r; 600 int r;
601 601
@@ -614,7 +614,7 @@ rb_find_bss(struct cfg80211_registered_device *dev,
614 return NULL; 614 return NULL;
615} 615}
616 616
617static bool cfg80211_combine_bsses(struct cfg80211_registered_device *dev, 617static bool cfg80211_combine_bsses(struct cfg80211_registered_device *rdev,
618 struct cfg80211_internal_bss *new) 618 struct cfg80211_internal_bss *new)
619{ 619{
620 const struct cfg80211_bss_ies *ies; 620 const struct cfg80211_bss_ies *ies;
@@ -644,7 +644,7 @@ static bool cfg80211_combine_bsses(struct cfg80211_registered_device *dev,
644 644
645 /* This is the bad part ... */ 645 /* This is the bad part ... */
646 646
647 list_for_each_entry(bss, &dev->bss_list, list) { 647 list_for_each_entry(bss, &rdev->bss_list, list) {
648 if (!ether_addr_equal(bss->pub.bssid, new->pub.bssid)) 648 if (!ether_addr_equal(bss->pub.bssid, new->pub.bssid))
649 continue; 649 continue;
650 if (bss->pub.channel != new->pub.channel) 650 if (bss->pub.channel != new->pub.channel)
@@ -678,7 +678,7 @@ static bool cfg80211_combine_bsses(struct cfg80211_registered_device *dev,
678 678
679/* Returned bss is reference counted and must be cleaned up appropriately. */ 679/* Returned bss is reference counted and must be cleaned up appropriately. */
680static struct cfg80211_internal_bss * 680static struct cfg80211_internal_bss *
681cfg80211_bss_update(struct cfg80211_registered_device *dev, 681cfg80211_bss_update(struct cfg80211_registered_device *rdev,
682 struct cfg80211_internal_bss *tmp, 682 struct cfg80211_internal_bss *tmp,
683 bool signal_valid) 683 bool signal_valid)
684{ 684{
@@ -689,14 +689,14 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev,
689 689
690 tmp->ts = jiffies; 690 tmp->ts = jiffies;
691 691
692 spin_lock_bh(&dev->bss_lock); 692 spin_lock_bh(&rdev->bss_lock);
693 693
694 if (WARN_ON(!rcu_access_pointer(tmp->pub.ies))) { 694 if (WARN_ON(!rcu_access_pointer(tmp->pub.ies))) {
695 spin_unlock_bh(&dev->bss_lock); 695 spin_unlock_bh(&rdev->bss_lock);
696 return NULL; 696 return NULL;
697 } 697 }
698 698
699 found = rb_find_bss(dev, tmp, BSS_CMP_REGULAR); 699 found = rb_find_bss(rdev, tmp, BSS_CMP_REGULAR);
700 700
701 if (found) { 701 if (found) {
702 /* Update IEs */ 702 /* Update IEs */
@@ -783,7 +783,7 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev,
783 * is allocated on the stack since it's not needed in the 783 * is allocated on the stack since it's not needed in the
784 * more common case of an update 784 * more common case of an update
785 */ 785 */
786 new = kzalloc(sizeof(*new) + dev->wiphy.bss_priv_size, 786 new = kzalloc(sizeof(*new) + rdev->wiphy.bss_priv_size,
787 GFP_ATOMIC); 787 GFP_ATOMIC);
788 if (!new) { 788 if (!new) {
789 ies = (void *)rcu_dereference(tmp->pub.beacon_ies); 789 ies = (void *)rcu_dereference(tmp->pub.beacon_ies);
@@ -799,9 +799,9 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev,
799 INIT_LIST_HEAD(&new->hidden_list); 799 INIT_LIST_HEAD(&new->hidden_list);
800 800
801 if (rcu_access_pointer(tmp->pub.proberesp_ies)) { 801 if (rcu_access_pointer(tmp->pub.proberesp_ies)) {
802 hidden = rb_find_bss(dev, tmp, BSS_CMP_HIDE_ZLEN); 802 hidden = rb_find_bss(rdev, tmp, BSS_CMP_HIDE_ZLEN);
803 if (!hidden) 803 if (!hidden)
804 hidden = rb_find_bss(dev, tmp, 804 hidden = rb_find_bss(rdev, tmp,
805 BSS_CMP_HIDE_NUL); 805 BSS_CMP_HIDE_NUL);
806 if (hidden) { 806 if (hidden) {
807 new->pub.hidden_beacon_bss = &hidden->pub; 807 new->pub.hidden_beacon_bss = &hidden->pub;
@@ -818,24 +818,24 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev,
818 * expensive search for any probe responses that should 818 * expensive search for any probe responses that should
819 * be grouped with this beacon for updates ... 819 * be grouped with this beacon for updates ...
820 */ 820 */
821 if (!cfg80211_combine_bsses(dev, new)) { 821 if (!cfg80211_combine_bsses(rdev, new)) {
822 kfree(new); 822 kfree(new);
823 goto drop; 823 goto drop;
824 } 824 }
825 } 825 }
826 826
827 list_add_tail(&new->list, &dev->bss_list); 827 list_add_tail(&new->list, &rdev->bss_list);
828 rb_insert_bss(dev, new); 828 rb_insert_bss(rdev, new);
829 found = new; 829 found = new;
830 } 830 }
831 831
832 dev->bss_generation++; 832 rdev->bss_generation++;
833 bss_ref_get(dev, found); 833 bss_ref_get(rdev, found);
834 spin_unlock_bh(&dev->bss_lock); 834 spin_unlock_bh(&rdev->bss_lock);
835 835
836 return found; 836 return found;
837 drop: 837 drop:
838 spin_unlock_bh(&dev->bss_lock); 838 spin_unlock_bh(&rdev->bss_lock);
839 return NULL; 839 return NULL;
840} 840}
841 841
@@ -1007,7 +1007,7 @@ EXPORT_SYMBOL(cfg80211_inform_bss_width_frame);
1007 1007
1008void cfg80211_ref_bss(struct wiphy *wiphy, struct cfg80211_bss *pub) 1008void cfg80211_ref_bss(struct wiphy *wiphy, struct cfg80211_bss *pub)
1009{ 1009{
1010 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy); 1010 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
1011 struct cfg80211_internal_bss *bss; 1011 struct cfg80211_internal_bss *bss;
1012 1012
1013 if (!pub) 1013 if (!pub)
@@ -1015,15 +1015,15 @@ void cfg80211_ref_bss(struct wiphy *wiphy, struct cfg80211_bss *pub)
1015 1015
1016 bss = container_of(pub, struct cfg80211_internal_bss, pub); 1016 bss = container_of(pub, struct cfg80211_internal_bss, pub);
1017 1017
1018 spin_lock_bh(&dev->bss_lock); 1018 spin_lock_bh(&rdev->bss_lock);
1019 bss_ref_get(dev, bss); 1019 bss_ref_get(rdev, bss);
1020 spin_unlock_bh(&dev->bss_lock); 1020 spin_unlock_bh(&rdev->bss_lock);
1021} 1021}
1022EXPORT_SYMBOL(cfg80211_ref_bss); 1022EXPORT_SYMBOL(cfg80211_ref_bss);
1023 1023
1024void cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *pub) 1024void cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *pub)
1025{ 1025{
1026 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy); 1026 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
1027 struct cfg80211_internal_bss *bss; 1027 struct cfg80211_internal_bss *bss;
1028 1028
1029 if (!pub) 1029 if (!pub)
@@ -1031,15 +1031,15 @@ void cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *pub)
1031 1031
1032 bss = container_of(pub, struct cfg80211_internal_bss, pub); 1032 bss = container_of(pub, struct cfg80211_internal_bss, pub);
1033 1033
1034 spin_lock_bh(&dev->bss_lock); 1034 spin_lock_bh(&rdev->bss_lock);
1035 bss_ref_put(dev, bss); 1035 bss_ref_put(rdev, bss);
1036 spin_unlock_bh(&dev->bss_lock); 1036 spin_unlock_bh(&rdev->bss_lock);
1037} 1037}
1038EXPORT_SYMBOL(cfg80211_put_bss); 1038EXPORT_SYMBOL(cfg80211_put_bss);
1039 1039
1040void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *pub) 1040void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *pub)
1041{ 1041{
1042 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy); 1042 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
1043 struct cfg80211_internal_bss *bss; 1043 struct cfg80211_internal_bss *bss;
1044 1044
1045 if (WARN_ON(!pub)) 1045 if (WARN_ON(!pub))
@@ -1047,12 +1047,12 @@ void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *pub)
1047 1047
1048 bss = container_of(pub, struct cfg80211_internal_bss, pub); 1048 bss = container_of(pub, struct cfg80211_internal_bss, pub);
1049 1049
1050 spin_lock_bh(&dev->bss_lock); 1050 spin_lock_bh(&rdev->bss_lock);
1051 if (!list_empty(&bss->list)) { 1051 if (!list_empty(&bss->list)) {
1052 if (__cfg80211_unlink_bss(dev, bss)) 1052 if (__cfg80211_unlink_bss(rdev, bss))
1053 dev->bss_generation++; 1053 rdev->bss_generation++;
1054 } 1054 }
1055 spin_unlock_bh(&dev->bss_lock); 1055 spin_unlock_bh(&rdev->bss_lock);
1056} 1056}
1057EXPORT_SYMBOL(cfg80211_unlink_bss); 1057EXPORT_SYMBOL(cfg80211_unlink_bss);
1058 1058
@@ -1465,7 +1465,7 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info,
1465} 1465}
1466 1466
1467 1467
1468static int ieee80211_scan_results(struct cfg80211_registered_device *dev, 1468static int ieee80211_scan_results(struct cfg80211_registered_device *rdev,
1469 struct iw_request_info *info, 1469 struct iw_request_info *info,
1470 char *buf, size_t len) 1470 char *buf, size_t len)
1471{ 1471{
@@ -1473,18 +1473,18 @@ static int ieee80211_scan_results(struct cfg80211_registered_device *dev,
1473 char *end_buf = buf + len; 1473 char *end_buf = buf + len;
1474 struct cfg80211_internal_bss *bss; 1474 struct cfg80211_internal_bss *bss;
1475 1475
1476 spin_lock_bh(&dev->bss_lock); 1476 spin_lock_bh(&rdev->bss_lock);
1477 cfg80211_bss_expire(dev); 1477 cfg80211_bss_expire(rdev);
1478 1478
1479 list_for_each_entry(bss, &dev->bss_list, list) { 1479 list_for_each_entry(bss, &rdev->bss_list, list) {
1480 if (buf + len - current_ev <= IW_EV_ADDR_LEN) { 1480 if (buf + len - current_ev <= IW_EV_ADDR_LEN) {
1481 spin_unlock_bh(&dev->bss_lock); 1481 spin_unlock_bh(&rdev->bss_lock);
1482 return -E2BIG; 1482 return -E2BIG;
1483 } 1483 }
1484 current_ev = ieee80211_bss(&dev->wiphy, info, bss, 1484 current_ev = ieee80211_bss(&rdev->wiphy, info, bss,
1485 current_ev, end_buf); 1485 current_ev, end_buf);
1486 } 1486 }
1487 spin_unlock_bh(&dev->bss_lock); 1487 spin_unlock_bh(&rdev->bss_lock);
1488 return current_ev - buf; 1488 return current_ev - buf;
1489} 1489}
1490 1490