Commit 7753f169 authored by Vignesh Babu's avatar Vignesh Babu Committed by Artem Bityutskiy

UBI: use is_power_of_2()

Replacing (n & (n-1)) in the context of power of 2 checks
with is_power_of_2
Signed-off-by: default avatarVignesh Babu <vignesh.babu@wipro.com>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent d7f0c4dc
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/log2.h>
#include "ubi.h" #include "ubi.h"
/* Maximum length of the 'mtd=' parameter */ /* Maximum length of the 'mtd=' parameter */
...@@ -422,8 +423,7 @@ static int io_init(struct ubi_device *ubi) ...@@ -422,8 +423,7 @@ static int io_init(struct ubi_device *ubi)
ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft; ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;
/* Make sure minimal I/O unit is power of 2 */ /* Make sure minimal I/O unit is power of 2 */
if (ubi->min_io_size == 0 || if (!is_power_of_2(ubi->min_io_size)) {
(ubi->min_io_size & (ubi->min_io_size - 1))) {
ubi_err("bad min. I/O unit"); ubi_err("bad min. I/O unit");
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment