diff options
author | Matthias Kaehlcke <matthias.kaehlcke@gmail.com> | 2007-05-28 12:38:48 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-08 22:16:37 -0400 |
commit | c15057313725942c6af8dcb60b4d4322101316d9 (patch) | |
tree | 85d7bf8a6aaf0faaae21099a13b84d0cfa9b307a /drivers | |
parent | b918099030fe6cc093a7d60a88039bd98f16538e (diff) |
[PATCH] hostap: Use list_for_each_entry
Use list_for_each_entry() instead of manual iteration and
substitute some list_for_each() loops with list_for_each_entry().
Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/hostap/hostap_ap.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c index d169529b90bc..90900525379c 100644 --- a/drivers/net/wireless/hostap/hostap_ap.c +++ b/drivers/net/wireless/hostap/hostap_ap.c | |||
@@ -326,7 +326,6 @@ static int ap_control_proc_read(char *page, char **start, off_t off, | |||
326 | char *p = page; | 326 | char *p = page; |
327 | struct ap_data *ap = (struct ap_data *) data; | 327 | struct ap_data *ap = (struct ap_data *) data; |
328 | char *policy_txt; | 328 | char *policy_txt; |
329 | struct list_head *ptr; | ||
330 | struct mac_entry *entry; | 329 | struct mac_entry *entry; |
331 | 330 | ||
332 | if (off != 0) { | 331 | if (off != 0) { |
@@ -352,14 +351,12 @@ static int ap_control_proc_read(char *page, char **start, off_t off, | |||
352 | p += sprintf(p, "MAC entries: %u\n", ap->mac_restrictions.entries); | 351 | p += sprintf(p, "MAC entries: %u\n", ap->mac_restrictions.entries); |
353 | p += sprintf(p, "MAC list:\n"); | 352 | p += sprintf(p, "MAC list:\n"); |
354 | spin_lock_bh(&ap->mac_restrictions.lock); | 353 | spin_lock_bh(&ap->mac_restrictions.lock); |
355 | for (ptr = ap->mac_restrictions.mac_list.next; | 354 | list_for_each_entry(entry, &ap->mac_restrictions.mac_list, list) { |
356 | ptr != &ap->mac_restrictions.mac_list; ptr = ptr->next) { | ||
357 | if (p - page > PAGE_SIZE - 80) { | 355 | if (p - page > PAGE_SIZE - 80) { |
358 | p += sprintf(p, "All entries did not fit one page.\n"); | 356 | p += sprintf(p, "All entries did not fit one page.\n"); |
359 | break; | 357 | break; |
360 | } | 358 | } |
361 | 359 | ||
362 | entry = list_entry(ptr, struct mac_entry, list); | ||
363 | p += sprintf(p, MACSTR "\n", MAC2STR(entry->addr)); | 360 | p += sprintf(p, MACSTR "\n", MAC2STR(entry->addr)); |
364 | } | 361 | } |
365 | spin_unlock_bh(&ap->mac_restrictions.lock); | 362 | spin_unlock_bh(&ap->mac_restrictions.lock); |
@@ -413,7 +410,6 @@ int ap_control_del_mac(struct mac_restrictions *mac_restrictions, u8 *mac) | |||
413 | static int ap_control_mac_deny(struct mac_restrictions *mac_restrictions, | 410 | static int ap_control_mac_deny(struct mac_restrictions *mac_restrictions, |
414 | u8 *mac) | 411 | u8 *mac) |
415 | { | 412 | { |
416 | struct list_head *ptr; | ||
417 | struct mac_entry *entry; | 413 | struct mac_entry *entry; |
418 | int found = 0; | 414 | int found = 0; |
419 | 415 | ||
@@ -421,10 +417,7 @@ static int ap_control_mac_deny(struct mac_restrictions *mac_restrictions, | |||
421 | return 0; | 417 | return 0; |
422 | 418 | ||
423 | spin_lock_bh(&mac_restrictions->lock); | 419 | spin_lock_bh(&mac_restrictions->lock); |
424 | for (ptr = mac_restrictions->mac_list.next; | 420 | list_for_each_entry(entry, &mac_restrictions->mac_list, list) { |
425 | ptr != &mac_restrictions->mac_list; ptr = ptr->next) { | ||
426 | entry = list_entry(ptr, struct mac_entry, list); | ||
427 | |||
428 | if (memcmp(entry->addr, mac, ETH_ALEN) == 0) { | 421 | if (memcmp(entry->addr, mac, ETH_ALEN) == 0) { |
429 | found = 1; | 422 | found = 1; |
430 | break; | 423 | break; |
@@ -519,7 +512,7 @@ static int prism2_ap_proc_read(char *page, char **start, off_t off, | |||
519 | { | 512 | { |
520 | char *p = page; | 513 | char *p = page; |
521 | struct ap_data *ap = (struct ap_data *) data; | 514 | struct ap_data *ap = (struct ap_data *) data; |
522 | struct list_head *ptr; | 515 | struct sta_info *sta; |
523 | int i; | 516 | int i; |
524 | 517 | ||
525 | if (off > PROC_LIMIT) { | 518 | if (off > PROC_LIMIT) { |
@@ -529,9 +522,7 @@ static int prism2_ap_proc_read(char *page, char **start, off_t off, | |||
529 | 522 | ||
530 | p += sprintf(p, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n"); | 523 | p += sprintf(p, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n"); |
531 | spin_lock_bh(&ap->sta_table_lock); | 524 | spin_lock_bh(&ap->sta_table_lock); |
532 | for (ptr = ap->sta_list.next; ptr != &ap->sta_list; ptr = ptr->next) { | 525 | list_for_each_entry(sta, &ap->sta_list, list) { |
533 | struct sta_info *sta = (struct sta_info *) ptr; | ||
534 | |||
535 | if (!sta->ap) | 526 | if (!sta->ap) |
536 | continue; | 527 | continue; |
537 | 528 | ||
@@ -861,7 +852,7 @@ void hostap_init_ap_proc(local_info_t *local) | |||
861 | 852 | ||
862 | void hostap_free_data(struct ap_data *ap) | 853 | void hostap_free_data(struct ap_data *ap) |
863 | { | 854 | { |
864 | struct list_head *n, *ptr; | 855 | struct sta_info *n, *sta; |
865 | 856 | ||
866 | if (ap == NULL || !ap->initialized) { | 857 | if (ap == NULL || !ap->initialized) { |
867 | printk(KERN_DEBUG "hostap_free_data: ap has not yet been " | 858 | printk(KERN_DEBUG "hostap_free_data: ap has not yet been " |
@@ -875,8 +866,7 @@ void hostap_free_data(struct ap_data *ap) | |||
875 | ap->crypt = ap->crypt_priv = NULL; | 866 | ap->crypt = ap->crypt_priv = NULL; |
876 | #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ | 867 | #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ |
877 | 868 | ||
878 | list_for_each_safe(ptr, n, &ap->sta_list) { | 869 | list_for_each_entry_safe(sta, n, &ap->sta_list, list) { |
879 | struct sta_info *sta = list_entry(ptr, struct sta_info, list); | ||
880 | ap_sta_hash_del(ap, sta); | 870 | ap_sta_hash_del(ap, sta); |
881 | list_del(&sta->list); | 871 | list_del(&sta->list); |
882 | if ((sta->flags & WLAN_STA_ASSOC) && !sta->ap && sta->local) | 872 | if ((sta->flags & WLAN_STA_ASSOC) && !sta->ap && sta->local) |
@@ -3200,15 +3190,14 @@ int hostap_update_rx_stats(struct ap_data *ap, | |||
3200 | 3190 | ||
3201 | void hostap_update_rates(local_info_t *local) | 3191 | void hostap_update_rates(local_info_t *local) |
3202 | { | 3192 | { |
3203 | struct list_head *ptr; | 3193 | struct sta_info *sta; |
3204 | struct ap_data *ap = local->ap; | 3194 | struct ap_data *ap = local->ap; |
3205 | 3195 | ||
3206 | if (!ap) | 3196 | if (!ap) |
3207 | return; | 3197 | return; |
3208 | 3198 | ||
3209 | spin_lock_bh(&ap->sta_table_lock); | 3199 | spin_lock_bh(&ap->sta_table_lock); |
3210 | for (ptr = ap->sta_list.next; ptr != &ap->sta_list; ptr = ptr->next) { | 3200 | list_for_each_entry(sta, &ap->sta_list, list) { |
3211 | struct sta_info *sta = (struct sta_info *) ptr; | ||
3212 | prism2_check_tx_rates(sta); | 3201 | prism2_check_tx_rates(sta); |
3213 | } | 3202 | } |
3214 | spin_unlock_bh(&ap->sta_table_lock); | 3203 | spin_unlock_bh(&ap->sta_table_lock); |
@@ -3244,11 +3233,10 @@ void * ap_crypt_get_ptrs(struct ap_data *ap, u8 *addr, int permanent, | |||
3244 | void hostap_add_wds_links(local_info_t *local) | 3233 | void hostap_add_wds_links(local_info_t *local) |
3245 | { | 3234 | { |
3246 | struct ap_data *ap = local->ap; | 3235 | struct ap_data *ap = local->ap; |
3247 | struct list_head *ptr; | 3236 | struct sta_info *sta; |
3248 | 3237 | ||
3249 | spin_lock_bh(&ap->sta_table_lock); | 3238 | spin_lock_bh(&ap->sta_table_lock); |
3250 | list_for_each(ptr, &ap->sta_list) { | 3239 | list_for_each_entry(sta, &ap->sta_list, list) { |
3251 | struct sta_info *sta = list_entry(ptr, struct sta_info, list); | ||
3252 | if (sta->ap) | 3240 | if (sta->ap) |
3253 | hostap_wds_link_oper(local, sta->addr, WDS_ADD); | 3241 | hostap_wds_link_oper(local, sta->addr, WDS_ADD); |
3254 | } | 3242 | } |