mtd: rawnand: jedec: Define the number of parameter pages
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 28 Apr 2020 09:43:01 +0000 (11:43 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 11 May 2020 07:51:40 +0000 (09:51 +0200)
Use a macro to define the number of parameter page instead of
hardcoding it everywhere.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200428094302.14624-9-miquel.raynal@bootlin.com
drivers/mtd/nand/raw/nand_jedec.c

index 9b540e7..0cd322a 100644 (file)
@@ -16,6 +16,8 @@
 
 #include "internals.h"
 
+#define JEDEC_PARAM_PAGES 3
+
 /*
  * Check if the NAND chip is JEDEC compliant, returns 1 if it is, 0 otherwise.
  */
@@ -47,7 +49,7 @@ int nand_jedec_detect(struct nand_chip *chip)
                goto free_jedec_param_page;
        }
 
-       for (i = 0; i < 3; i++) {
+       for (i = 0; i < JEDEC_PARAM_PAGES; i++) {
                ret = nand_read_data_op(chip, p, sizeof(*p), true);
                if (ret) {
                        ret = 0;
@@ -59,7 +61,7 @@ int nand_jedec_detect(struct nand_chip *chip)
                        break;
        }
 
-       if (i == 3) {
+       if (i == JEDEC_PARAM_PAGES) {
                pr_err("Could not find valid JEDEC parameter page; aborting\n");
                goto free_jedec_param_page;
        }