aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>2013-03-11 01:45:23 -0400
committerDavid S. Miller <davem@davemloft.net>2013-03-12 08:04:09 -0400
commit74694e7bd0fdba56f940c50ec4e51eda2c3870d3 (patch)
treed618dbb2ca0c1004f45caf0ccbc2a2b19fd76c18
parent5096e3c4b2815da79a7ee1533349b2f21a698622 (diff)
bridge: using for_each_set_bit to simplify the code
Using for_each_set_bit() to simplify the code. Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/bridge/br_fdb.c10
-rw-r--r--net/bridge/br_netlink.c5
2 files changed, 3 insertions, 12 deletions
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 48fe76176a22..10b47d4cdfe4 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -722,13 +722,10 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
722 * specify a VLAN. To be nice, add/update entry for every 722 * specify a VLAN. To be nice, add/update entry for every
723 * vlan on this port. 723 * vlan on this port.
724 */ 724 */
725 vid = find_first_bit(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN); 725 for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
726 while (vid < BR_VLAN_BITMAP_LEN) {
727 err = __br_fdb_add(ndm, p, addr, nlh_flags, vid); 726 err = __br_fdb_add(ndm, p, addr, nlh_flags, vid);
728 if (err) 727 if (err)
729 goto out; 728 goto out;
730 vid = find_next_bit(pv->vlan_bitmap,
731 BR_VLAN_BITMAP_LEN, vid+1);
732 } 729 }
733 } 730 }
734 731
@@ -813,11 +810,8 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
813 * vlan on this port. 810 * vlan on this port.
814 */ 811 */
815 err = -ENOENT; 812 err = -ENOENT;
816 vid = find_first_bit(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN); 813 for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
817 while (vid < BR_VLAN_BITMAP_LEN) {
818 err &= __br_fdb_delete(p, addr, vid); 814 err &= __br_fdb_delete(p, addr, vid);
819 vid = find_next_bit(pv->vlan_bitmap,
820 BR_VLAN_BITMAP_LEN, vid+1);
821 } 815 }
822 } 816 }
823out: 817out:
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index db12a0fcfe50..138284219c6d 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -136,10 +136,7 @@ static int br_fill_ifinfo(struct sk_buff *skb,
136 goto nla_put_failure; 136 goto nla_put_failure;
137 137
138 pvid = br_get_pvid(pv); 138 pvid = br_get_pvid(pv);
139 for (vid = find_first_bit(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN); 139 for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
140 vid < BR_VLAN_BITMAP_LEN;
141 vid = find_next_bit(pv->vlan_bitmap,
142 BR_VLAN_BITMAP_LEN, vid+1)) {
143 vinfo.vid = vid; 140 vinfo.vid = vid;
144 vinfo.flags = 0; 141 vinfo.flags = 0;
145 if (vid == pvid) 142 if (vid == pvid)