Skip to content

Commit 426921b

Browse files
Matthias Kaehlckelinvjw
authored andcommitted
[PATCH] use list_for_each_entry() for iteration in Prism 54 driver
Use list_for_each_entry() instead of manual iteration and substitute a list_for_each_safe() loop with list_for_each_entry_safe() Signed-off-by: Matthias Kaehlcke <[email protected]> Cc: Christoph Hellwig <[email protected]> Acked-by: Luis R. Rodriguez <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent 777fa98 commit 426921b

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

drivers/net/wireless/prism54/isl_ioctl.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,19 +1853,16 @@ prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
18531853
islpci_private *priv = netdev_priv(ndev);
18541854
struct islpci_acl *acl = &priv->acl;
18551855
struct mac_entry *entry;
1856-
struct list_head *ptr;
18571856
struct sockaddr *addr = (struct sockaddr *) extra;
18581857

18591858
if (addr->sa_family != ARPHRD_ETHER)
18601859
return -EOPNOTSUPP;
18611860

18621861
if (down_interruptible(&acl->sem))
18631862
return -ERESTARTSYS;
1864-
for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1865-
entry = list_entry(ptr, struct mac_entry, _list);
1866-
1863+
list_for_each_entry(entry, &acl->mac_list, _list) {
18671864
if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) {
1868-
list_del(ptr);
1865+
list_del(&entry->_list);
18691866
acl->size--;
18701867
kfree(entry);
18711868
up(&acl->sem);
@@ -1883,17 +1880,14 @@ prism54_get_mac(struct net_device *ndev, struct iw_request_info *info,
18831880
islpci_private *priv = netdev_priv(ndev);
18841881
struct islpci_acl *acl = &priv->acl;
18851882
struct mac_entry *entry;
1886-
struct list_head *ptr;
18871883
struct sockaddr *dst = (struct sockaddr *) extra;
18881884

18891885
dwrq->length = 0;
18901886

18911887
if (down_interruptible(&acl->sem))
18921888
return -ERESTARTSYS;
18931889

1894-
for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1895-
entry = list_entry(ptr, struct mac_entry, _list);
1896-
1890+
list_for_each_entry(entry, &acl->mac_list, _list) {
18971891
memcpy(dst->sa_data, entry->addr, ETH_ALEN);
18981892
dst->sa_family = ARPHRD_ETHER;
18991893
dwrq->length++;
@@ -1960,7 +1954,6 @@ prism54_get_policy(struct net_device *ndev, struct iw_request_info *info,
19601954
static int
19611955
prism54_mac_accept(struct islpci_acl *acl, char *mac)
19621956
{
1963-
struct list_head *ptr;
19641957
struct mac_entry *entry;
19651958
int res = 0;
19661959

@@ -1972,8 +1965,7 @@ prism54_mac_accept(struct islpci_acl *acl, char *mac)
19721965
return 1;
19731966
}
19741967

1975-
for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1976-
entry = list_entry(ptr, struct mac_entry, _list);
1968+
list_for_each_entry(entry, &acl->mac_list, _list) {
19771969
if (memcmp(entry->addr, mac, ETH_ALEN) == 0) {
19781970
res = 1;
19791971
break;
@@ -2216,11 +2208,9 @@ prism54_wpa_bss_ie_init(islpci_private *priv)
22162208
void
22172209
prism54_wpa_bss_ie_clean(islpci_private *priv)
22182210
{
2219-
struct list_head *ptr, *n;
2211+
struct islpci_bss_wpa_ie *bss, *n;
22202212

2221-
list_for_each_safe(ptr, n, &priv->bss_wpa_list) {
2222-
struct islpci_bss_wpa_ie *bss;
2223-
bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
2213+
list_for_each_entry_safe(bss, n, &priv->bss_wpa_list, list) {
22242214
kfree(bss);
22252215
}
22262216
}

0 commit comments

Comments
 (0)