]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/log2.h
[PATCH] sysctl: factor out sysctl_head_next from do_sysctl
[linux-2.6-omap-h63xx.git] / include / linux / log2.h
index d02e1a547a7e9deb1e8bc21857780bdc2c7693c0..99922bedfcc90acaef644369aee3d5e126b7d46d 100644 (file)
@@ -43,6 +43,17 @@ int __ilog2_u64(u64 n)
 }
 #endif
 
+/*
+ *  Determine whether some value is a power of two, where zero is
+ * *not* considered a power of two.
+ */
+
+static inline __attribute__((const))
+bool is_power_of_2(unsigned long n)
+{
+       return (n != 0 && ((n & (n - 1)) == 0));
+}
+
 /*
  * round up to nearest power of two
  */