dnsmasq: move feature detection inside a shell func
[openwrt/openwrt.git] / target / linux / generic / pending-4.9 / 441-block2mtd_probe.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Subject: block2mtd
3
4 Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 ---
6 drivers/mtd/devices/block2mtd.c | 9 ++++++---
7 1 file changed, 6 insertions(+), 3 deletions(-)
8
9 --- a/drivers/mtd/devices/block2mtd.c
10 +++ b/drivers/mtd/devices/block2mtd.c
11 @@ -392,7 +392,7 @@ static int block2mtd_setup2(const char *
12 /* 80 for device, 12 for erase size, 80 for name, 8 for timeout */
13 char buf[80 + 12 + 80 + 8];
14 char *str = buf;
15 - char *token[3];
16 + char *token[4];
17 char *name;
18 size_t erase_size = PAGE_SIZE;
19 unsigned long timeout = MTD_DEFAULT_TIMEOUT;
20 @@ -406,7 +406,7 @@ static int block2mtd_setup2(const char *
21 strcpy(str, val);
22 kill_final_newline(str);
23
24 - for (i = 0; i < 3; i++)
25 + for (i = 0; i < 4; i++)
26 token[i] = strsep(&str, ",");
27
28 if (str) {
29 @@ -435,6 +435,9 @@ static int block2mtd_setup2(const char *
30 if (token[2] && (strlen(token[2]) + 1 > 80))
31 pr_err("mtd device name too long\n");
32
33 + if (token[3] && kstrtoul(token[3], 0, &timeout))
34 + pr_err("invalid timeout\n");
35 +
36 add_device(name, erase_size, token[2], timeout);
37
38 return 0;
39 @@ -469,7 +472,7 @@ static int block2mtd_setup(const char *v
40
41
42 module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
43 -MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>]]\"");
44 +MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>[,<timeout>]]]\"");
45
46 static int __init block2mtd_init(void)
47 {