Message ID | 56659FC2.1070906@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Dec 7, 2015 at 5:03 PM, zhaoxiu.zeng <zhaoxiu.zeng@gmail.com> wrote:
> is_power_of_2 is simple, and faster than "hweightN(x) == 1" on most architectures.
Thanks. I'm not sure that speed is a major concern here, since this
code executes only once during the lifetime of the driver. Readability
is probably more important.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap_hwspinlock.c index ad2f8ca..1848a4c 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -29,6 +29,7 @@ #include <linux/hwspinlock.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/log2.h> #include "hwspinlock_internal.h" @@ -125,7 +126,7 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) goto iounmap_base; /* one of the four lsb's must be set, and nothing else */ - if (hweight_long(i & 0xf) != 1 || i > 8) { + if (!is_power_of_2(i) || i > 8) { ret = -EINVAL; goto iounmap_base; }