diff options
author | Joachim Wiberg <troglobit@gmail.com> | 2021-10-09 08:09:54 +0200 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2021-10-15 12:30:32 +0200 |
commit | a04e96537cc64b63fbeb300df2503167bb54f2a1 (patch) | |
tree | 32d2750d38d71062e09aa2afdaa294cae43f0e22 /drivers/mtd | |
parent | mtd: fixup CFI on ixp4xx (diff) | |
download | linux-a04e96537cc64b63fbeb300df2503167bb54f2a1.tar.xz linux-a04e96537cc64b63fbeb300df2503167bb54f2a1.zip |
mtd: block2mtd: minor refactor to avoid hard coded constant
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20211009060955.552636-2-troglobit@gmail.com
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/devices/block2mtd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index c08721b11642..6c2871788d59 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -31,6 +31,9 @@ #include <linux/slab.h> #include <linux/major.h> +/* Maximum number of comma-separated items in the 'block2mtd=' parameter */ +#define BLOCK2MTD_PARAM_MAX_COUNT 2 + /* Info for the block device */ struct block2mtd_dev { struct list_head list; @@ -381,7 +384,7 @@ static int block2mtd_setup2(const char *val) /* 80 for device, 12 for erase size, 80 for name, 8 for timeout */ char buf[80 + 12 + 80 + 8]; char *str = buf; - char *token[2]; + char *token[BLOCK2MTD_PARAM_MAX_COUNT]; char *name; size_t erase_size = PAGE_SIZE; unsigned long timeout = MTD_DEFAULT_TIMEOUT; @@ -395,7 +398,7 @@ static int block2mtd_setup2(const char *val) strcpy(str, val); kill_final_newline(str); - for (i = 0; i < 2; i++) + for (i = 0; i < BLOCK2MTD_PARAM_MAX_COUNT; i++) token[i] = strsep(&str, ","); if (str) { |