[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080120132550.056370c0@deepthought>
Date:	Sun, 20 Jan 2008 13:25:50 -0800
From:	Stephen Hemminger <shemminger@...tta.com>
To:	David Miller <davem@...emloft.net>
Cc:	Patrick McHardy <kaber@...sh.net>, netdev@...r.kernel.org
Subject: [PATCH 2/4] dsmark: get rid of trivial function
Replace loop in dsmark_valid_indices with equivalent bit math.
Signed-off-by: Stephen Hemminger <shemminger@...tta.com>
--- a/net/sched/sch_dsmark.c	2008-01-20 13:07:58.000000000 -0800
+++ b/net/sched/sch_dsmark.c	2008-01-20 13:22:54.000000000 -0800
@@ -45,13 +45,8 @@ struct dsmark_qdisc_data {
 
 static inline int dsmark_valid_indices(u16 indices)
 {
-	while (indices != 1) {
-		if (indices & 1)
-			return 0;
-		indices >>= 1;
-	}
-
-	return 1;
+	/* Must have only one bit set */
+	return (indices & (indices - 1)) == 0;
 }
 
 static inline int dsmark_valid_index(struct dsmark_qdisc_data *p, u16 index)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists
 
