Skip to content

Commit a04e965

Browse files
troglobitmiquelraynal
authored andcommitted
mtd: block2mtd: minor refactor to avoid hard coded constant
Signed-off-by: Joachim Wiberg <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 603362b commit a04e965

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/mtd/devices/block2mtd.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
#include <linux/slab.h>
3232
#include <linux/major.h>
3333

34+
/* Maximum number of comma-separated items in the 'block2mtd=' parameter */
35+
#define BLOCK2MTD_PARAM_MAX_COUNT 2
36+
3437
/* Info for the block device */
3538
struct block2mtd_dev {
3639
struct list_head list;
@@ -381,7 +384,7 @@ static int block2mtd_setup2(const char *val)
381384
/* 80 for device, 12 for erase size, 80 for name, 8 for timeout */
382385
char buf[80 + 12 + 80 + 8];
383386
char *str = buf;
384-
char *token[2];
387+
char *token[BLOCK2MTD_PARAM_MAX_COUNT];
385388
char *name;
386389
size_t erase_size = PAGE_SIZE;
387390
unsigned long timeout = MTD_DEFAULT_TIMEOUT;
@@ -395,7 +398,7 @@ static int block2mtd_setup2(const char *val)
395398
strcpy(str, val);
396399
kill_final_newline(str);
397400

398-
for (i = 0; i < 2; i++)
401+
for (i = 0; i < BLOCK2MTD_PARAM_MAX_COUNT; i++)
399402
token[i] = strsep(&str, ",");
400403

401404
if (str) {

0 commit comments

Comments
 (0)