]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PKT_SCHED] dsmark: Use hweight32() instead of convoluted loop.
authorDavid S. Miller <davem@davemloft.net>
Mon, 21 Jan 2008 10:21:45 +0000 (02:21 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:08:39 +0000 (15:08 -0800)
Based upon a patch by Stephen Hemminger and suggestions
from Patrick McHardy.

Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_dsmark.c

index a9732aef2ca16d3af5cb5e190c4bfd49e5faf5d6..d96eaf0aa6b8b6bb8809c682b5338732e84017ff 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/skbuff.h>
 #include <linux/rtnetlink.h>
+#include <linux/bitops.h>
 #include <net/pkt_sched.h>
 #include <net/dsfield.h>
 #include <net/inet_ecn.h>
@@ -43,17 +44,6 @@ struct dsmark_qdisc_data {
        int                     set_tc_index;
 };
 
-static inline int dsmark_valid_indices(u16 indices)
-{
-       while (indices != 1) {
-               if (indices & 1)
-                       return 0;
-               indices >>= 1;
-       }
-
-       return 1;
-}
-
 static inline int dsmark_valid_index(struct dsmark_qdisc_data *p, u16 index)
 {
        return (index <= p->indices && index > 0);
@@ -348,7 +338,8 @@ static int dsmark_init(struct Qdisc *sch, struct rtattr *opt)
                goto errout;
 
        indices = RTA_GET_U16(tb[TCA_DSMARK_INDICES-1]);
-       if (!indices || !dsmark_valid_indices(indices))
+
+       if (hweight32(indices) != 1)
                goto errout;
 
        if (tb[TCA_DSMARK_DEFAULT_INDEX-1])