diff options
author | David S. Miller <davem@davemloft.net> | 2008-01-21 05:21:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:08:39 -0500 |
commit | 5b0ac72bc5fdda9634fb07db4cb0237fa9b6df68 (patch) | |
tree | 26db7718b56ea492e25a5c9321f5669020bc7ea6 /net | |
parent | 81da99ed71254a08d9a0bce46c258c1e15ac3948 (diff) |
[PKT_SCHED] dsmark: Use hweight32() instead of convoluted loop.
Based upon a patch by Stephen Hemminger and suggestions
from Patrick McHardy.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/sched/sch_dsmark.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index a9732aef2ca1..d96eaf0aa6b8 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
11 | #include <linux/skbuff.h> | 11 | #include <linux/skbuff.h> |
12 | #include <linux/rtnetlink.h> | 12 | #include <linux/rtnetlink.h> |
13 | #include <linux/bitops.h> | ||
13 | #include <net/pkt_sched.h> | 14 | #include <net/pkt_sched.h> |
14 | #include <net/dsfield.h> | 15 | #include <net/dsfield.h> |
15 | #include <net/inet_ecn.h> | 16 | #include <net/inet_ecn.h> |
@@ -43,17 +44,6 @@ struct dsmark_qdisc_data { | |||
43 | int set_tc_index; | 44 | int set_tc_index; |
44 | }; | 45 | }; |
45 | 46 | ||
46 | static inline int dsmark_valid_indices(u16 indices) | ||
47 | { | ||
48 | while (indices != 1) { | ||
49 | if (indices & 1) | ||
50 | return 0; | ||
51 | indices >>= 1; | ||
52 | } | ||
53 | |||
54 | return 1; | ||
55 | } | ||
56 | |||
57 | static inline int dsmark_valid_index(struct dsmark_qdisc_data *p, u16 index) | 47 | static inline int dsmark_valid_index(struct dsmark_qdisc_data *p, u16 index) |
58 | { | 48 | { |
59 | return (index <= p->indices && index > 0); | 49 | return (index <= p->indices && index > 0); |
@@ -348,7 +338,8 @@ static int dsmark_init(struct Qdisc *sch, struct rtattr *opt) | |||
348 | goto errout; | 338 | goto errout; |
349 | 339 | ||
350 | indices = RTA_GET_U16(tb[TCA_DSMARK_INDICES-1]); | 340 | indices = RTA_GET_U16(tb[TCA_DSMARK_INDICES-1]); |
351 | if (!indices || !dsmark_valid_indices(indices)) | 341 | |
342 | if (hweight32(indices) != 1) | ||
352 | goto errout; | 343 | goto errout; |
353 | 344 | ||
354 | if (tb[TCA_DSMARK_DEFAULT_INDEX-1]) | 345 | if (tb[TCA_DSMARK_DEFAULT_INDEX-1]) |