UBI: use is_power_of_2()
authorVignesh Babu <vignesh.babu@wipro.com>
Tue, 12 Jun 2007 05:01:05 +0000 (10:31 +0530)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 18 Jul 2007 13:55:26 +0000 (16:55 +0300)
Replacing (n & (n-1)) in the context of power of 2 checks
with is_power_of_2

Signed-off-by: Vignesh Babu <vignesh.babu@wipro.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
drivers/mtd/ubi/build.c

index 08ca214abb957a80b5f76f18f99860eb3aa28b94..eb8b55dcc3bbc7d424368f8977bf500d5a927512 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/moduleparam.h>
 #include <linux/stringify.h>
 #include <linux/stat.h>
+#include <linux/log2.h>
 #include "ubi.h"
 
 /* Maximum length of the 'mtd=' parameter */
@@ -422,8 +423,7 @@ static int io_init(struct ubi_device *ubi)
        ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;
 
        /* Make sure minimal I/O unit is power of 2 */
-       if (ubi->min_io_size == 0 ||
-           (ubi->min_io_size & (ubi->min_io_size - 1))) {
+       if (!is_power_of_2(ubi->min_io_size)) {
                ubi_err("bad min. I/O unit");
                return -EINVAL;
        }