Skip to contentSkip to conversation

is_power_of_2-mtd/ubi/build.c

PATCH In review vignesh babu 2 participants 2 messages Jun 12, 2007 – Jun 17, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 is_power_of_2-mtd/ubi/build.c

Replacing (n & (n-1)) in the context of power of 2 checks with is_power_of_2

---

drivers/mtd/ubi/build.c +2 -2
index 555d594..54e923f 100644
@@ -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;
 	}
Signature · 11 lines
Vignesh Babu BM 
_____________________________________________________________ 
"Why is it that every time I'm with you, makes me believe in magic?"



The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
 
www.wipro.com
#1 lore raw
Quoted 2 lines · vignesh babu

Replacing (n & (n-1)) in the context of power of 2 checks with is_power_of_2

Committed to UBI git tree, thanks.

Signature · 8 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)


_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors