[PATCH 05/10] nand command: use enumeration for command instead of bitmask

Sascha Hauer s.hauer at pengutronix.de
Mon Mar 4 05:13:49 EST 2013


A command can only be one of NAND_*, so use an enumeration instead
of a bitmask.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/nand.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/commands/nand.c b/commands/nand.c
index d00845f..79f6735 100644
--- a/commands/nand.c
+++ b/commands/nand.c
@@ -29,9 +29,9 @@
 #include <fcntl.h>
 #include <libgen.h>
 
-#define NAND_ADD (1 << 0)
-#define NAND_DEL (1 << 1)
-#define NAND_MARKBAD (1 << 2)
+#define NAND_ADD	1
+#define NAND_DEL	2
+#define NAND_MARKBAD	3
 
 static int do_nand(int argc, char *argv[])
 {
@@ -58,7 +58,7 @@ static int do_nand(int argc, char *argv[])
 		}
 	}
 
-	if (command & NAND_ADD) {
+	if (command == NAND_ADD) {
 		while (optind < argc) {
 			if (dev_add_bb_dev(basename(argv[optind]), NULL))
 				return 1;
@@ -67,14 +67,14 @@ static int do_nand(int argc, char *argv[])
 		}
 	}
 
-	if (command & NAND_DEL) {
+	if (command == NAND_DEL) {
 		while (optind < argc) {
 			dev_remove_bb_dev(basename(argv[optind]));
 			optind++;
 		}
 	}
 
-	if (command & NAND_MARKBAD) {
+	if (command == NAND_MARKBAD) {
 		if (optind < argc) {
 			int ret = 0, fd;
 
-- 
1.7.10.4




More information about the barebox mailing list