提交 c1505731 编写于 作者: M Matthias Kaehlcke 提交者: Jeff Garzik

[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: NMatthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: NJouni Malinen <j@w1.fi>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 b9180990
...@@ -326,7 +326,6 @@ static int ap_control_proc_read(char *page, char **start, off_t off, ...@@ -326,7 +326,6 @@ static int ap_control_proc_read(char *page, char **start, off_t off,
char *p = page; char *p = page;
struct ap_data *ap = (struct ap_data *) data; struct ap_data *ap = (struct ap_data *) data;
char *policy_txt; char *policy_txt;
struct list_head *ptr;
struct mac_entry *entry; struct mac_entry *entry;
if (off != 0) { if (off != 0) {
...@@ -352,14 +351,12 @@ static int ap_control_proc_read(char *page, char **start, off_t off, ...@@ -352,14 +351,12 @@ static int ap_control_proc_read(char *page, char **start, off_t off,
p += sprintf(p, "MAC entries: %u\n", ap->mac_restrictions.entries); p += sprintf(p, "MAC entries: %u\n", ap->mac_restrictions.entries);
p += sprintf(p, "MAC list:\n"); p += sprintf(p, "MAC list:\n");
spin_lock_bh(&ap->mac_restrictions.lock); spin_lock_bh(&ap->mac_restrictions.lock);
for (ptr = ap->mac_restrictions.mac_list.next; list_for_each_entry(entry, &ap->mac_restrictions.mac_list, list) {
ptr != &ap->mac_restrictions.mac_list; ptr = ptr->next) {
if (p - page > PAGE_SIZE - 80) { if (p - page > PAGE_SIZE - 80) {
p += sprintf(p, "All entries did not fit one page.\n"); p += sprintf(p, "All entries did not fit one page.\n");
break; break;
} }
entry = list_entry(ptr, struct mac_entry, list);
p += sprintf(p, MACSTR "\n", MAC2STR(entry->addr)); p += sprintf(p, MACSTR "\n", MAC2STR(entry->addr));
} }
spin_unlock_bh(&ap->mac_restrictions.lock); spin_unlock_bh(&ap->mac_restrictions.lock);
...@@ -413,7 +410,6 @@ int ap_control_del_mac(struct mac_restrictions *mac_restrictions, u8 *mac) ...@@ -413,7 +410,6 @@ int ap_control_del_mac(struct mac_restrictions *mac_restrictions, u8 *mac)
static int ap_control_mac_deny(struct mac_restrictions *mac_restrictions, static int ap_control_mac_deny(struct mac_restrictions *mac_restrictions,
u8 *mac) u8 *mac)
{ {
struct list_head *ptr;
struct mac_entry *entry; struct mac_entry *entry;
int found = 0; int found = 0;
...@@ -421,10 +417,7 @@ static int ap_control_mac_deny(struct mac_restrictions *mac_restrictions, ...@@ -421,10 +417,7 @@ static int ap_control_mac_deny(struct mac_restrictions *mac_restrictions,
return 0; return 0;
spin_lock_bh(&mac_restrictions->lock); spin_lock_bh(&mac_restrictions->lock);
for (ptr = mac_restrictions->mac_list.next; list_for_each_entry(entry, &mac_restrictions->mac_list, list) {
ptr != &mac_restrictions->mac_list; ptr = ptr->next) {
entry = list_entry(ptr, struct mac_entry, list);
if (memcmp(entry->addr, mac, ETH_ALEN) == 0) { if (memcmp(entry->addr, mac, ETH_ALEN) == 0) {
found = 1; found = 1;
break; break;
...@@ -519,7 +512,7 @@ static int prism2_ap_proc_read(char *page, char **start, off_t off, ...@@ -519,7 +512,7 @@ static int prism2_ap_proc_read(char *page, char **start, off_t off,
{ {
char *p = page; char *p = page;
struct ap_data *ap = (struct ap_data *) data; struct ap_data *ap = (struct ap_data *) data;
struct list_head *ptr; struct sta_info *sta;
int i; int i;
if (off > PROC_LIMIT) { if (off > PROC_LIMIT) {
...@@ -529,9 +522,7 @@ static int prism2_ap_proc_read(char *page, char **start, off_t off, ...@@ -529,9 +522,7 @@ static int prism2_ap_proc_read(char *page, char **start, off_t off,
p += sprintf(p, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n"); p += sprintf(p, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n");
spin_lock_bh(&ap->sta_table_lock); spin_lock_bh(&ap->sta_table_lock);
for (ptr = ap->sta_list.next; ptr != &ap->sta_list; ptr = ptr->next) { list_for_each_entry(sta, &ap->sta_list, list) {
struct sta_info *sta = (struct sta_info *) ptr;
if (!sta->ap) if (!sta->ap)
continue; continue;
...@@ -861,7 +852,7 @@ void hostap_init_ap_proc(local_info_t *local) ...@@ -861,7 +852,7 @@ void hostap_init_ap_proc(local_info_t *local)
void hostap_free_data(struct ap_data *ap) void hostap_free_data(struct ap_data *ap)
{ {
struct list_head *n, *ptr; struct sta_info *n, *sta;
if (ap == NULL || !ap->initialized) { if (ap == NULL || !ap->initialized) {
printk(KERN_DEBUG "hostap_free_data: ap has not yet been " printk(KERN_DEBUG "hostap_free_data: ap has not yet been "
...@@ -875,8 +866,7 @@ void hostap_free_data(struct ap_data *ap) ...@@ -875,8 +866,7 @@ void hostap_free_data(struct ap_data *ap)
ap->crypt = ap->crypt_priv = NULL; ap->crypt = ap->crypt_priv = NULL;
#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
list_for_each_safe(ptr, n, &ap->sta_list) { list_for_each_entry_safe(sta, n, &ap->sta_list, list) {
struct sta_info *sta = list_entry(ptr, struct sta_info, list);
ap_sta_hash_del(ap, sta); ap_sta_hash_del(ap, sta);
list_del(&sta->list); list_del(&sta->list);
if ((sta->flags & WLAN_STA_ASSOC) && !sta->ap && sta->local) if ((sta->flags & WLAN_STA_ASSOC) && !sta->ap && sta->local)
...@@ -3200,15 +3190,14 @@ int hostap_update_rx_stats(struct ap_data *ap, ...@@ -3200,15 +3190,14 @@ int hostap_update_rx_stats(struct ap_data *ap,
void hostap_update_rates(local_info_t *local) void hostap_update_rates(local_info_t *local)
{ {
struct list_head *ptr; struct sta_info *sta;
struct ap_data *ap = local->ap; struct ap_data *ap = local->ap;
if (!ap) if (!ap)
return; return;
spin_lock_bh(&ap->sta_table_lock); spin_lock_bh(&ap->sta_table_lock);
for (ptr = ap->sta_list.next; ptr != &ap->sta_list; ptr = ptr->next) { list_for_each_entry(sta, &ap->sta_list, list) {
struct sta_info *sta = (struct sta_info *) ptr;
prism2_check_tx_rates(sta); prism2_check_tx_rates(sta);
} }
spin_unlock_bh(&ap->sta_table_lock); 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,11 +3233,10 @@ void * ap_crypt_get_ptrs(struct ap_data *ap, u8 *addr, int permanent,
void hostap_add_wds_links(local_info_t *local) void hostap_add_wds_links(local_info_t *local)
{ {
struct ap_data *ap = local->ap; struct ap_data *ap = local->ap;
struct list_head *ptr; struct sta_info *sta;
spin_lock_bh(&ap->sta_table_lock); spin_lock_bh(&ap->sta_table_lock);
list_for_each(ptr, &ap->sta_list) { list_for_each_entry(sta, &ap->sta_list, list) {
struct sta_info *sta = list_entry(ptr, struct sta_info, list);
if (sta->ap) if (sta->ap)
hostap_wds_link_oper(local, sta->addr, WDS_ADD); hostap_wds_link_oper(local, sta->addr, WDS_ADD);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册