OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --- a/drivers/mtd/devices/block2mtd.c |
2 | +++ b/drivers/mtd/devices/block2mtd.c |
||
3 | @@ -10,6 +10,7 @@ |
||
4 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
||
5 | |||
6 | #include <linux/module.h> |
||
7 | +#include <linux/delay.h> |
||
8 | #include <linux/fs.h> |
||
9 | #include <linux/blkdev.h> |
||
10 | #include <linux/bio.h> |
||
11 | @@ -210,13 +211,16 @@ static void block2mtd_free_device(struct |
||
12 | } |
||
13 | |||
14 | |||
15 | -static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname) |
||
16 | +static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname, int timeout) |
||
17 | { |
||
18 | const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL; |
||
19 | - struct block_device *bdev; |
||
20 | + struct block_device *bdev = ERR_PTR(-ENODEV); |
||
21 | struct block2mtd_dev *dev; |
||
22 | struct mtd_partition *part; |
||
23 | char *name; |
||
24 | +#ifndef MODULE |
||
25 | + int i; |
||
26 | +#endif |
||
27 | |||
28 | if (!devname) |
||
29 | return NULL; |
||
30 | @@ -227,15 +231,20 @@ static struct block2mtd_dev *add_device( |
||
31 | |||
32 | /* Get a handle on the device */ |
||
33 | bdev = blkdev_get_by_path(devname, mode, dev); |
||
34 | + |
||
35 | #ifndef MODULE |
||
36 | - if (IS_ERR(bdev)) { |
||
37 | + for (i = 0; IS_ERR(bdev) && i <= timeout; i++) { |
||
38 | + dev_t devt; |
||
39 | |||
40 | - /* We might not have rootfs mounted at this point. Try |
||
41 | - to resolve the device name by other means. */ |
||
42 | + if (i) |
||
43 | + msleep(1000); |
||
44 | + wait_for_device_probe(); |
||
45 | + |
||
46 | + devt = name_to_dev_t(devname); |
||
47 | + if (!devt) |
||
48 | + continue; |
||
49 | |||
50 | - dev_t devt = name_to_dev_t(devname); |
||
51 | - if (devt) |
||
52 | - bdev = blkdev_get_by_dev(devt, mode, dev); |
||
53 | + bdev = blkdev_get_by_dev(devt, mode, dev); |
||
54 | } |
||
55 | #endif |
||
56 | |||
57 | @@ -361,11 +370,12 @@ static char block2mtd_paramline[80 + 12] |
||
58 | |||
59 | static int block2mtd_setup2(const char *val) |
||
60 | { |
||
61 | - char buf[80 + 12 + 80]; /* 80 for device, 12 for erase size, 80 for name */ |
||
62 | + char buf[80 + 12 + 80 + 8]; /* 80 for device, 12 for erase size, 80 for name, 8 for timeout */ |
||
63 | char *str = buf; |
||
64 | - char *token[3]; |
||
65 | + char *token[4]; |
||
66 | char *name; |
||
67 | size_t erase_size = PAGE_SIZE; |
||
68 | + unsigned long timeout = 0; |
||
69 | int i, ret; |
||
70 | |||
71 | if (strnlen(val, sizeof(buf)) >= sizeof(buf)) { |
||
72 | @@ -376,7 +386,7 @@ static int block2mtd_setup2(const char * |
||
73 | strcpy(str, val); |
||
74 | kill_final_newline(str); |
||
75 | |||
76 | - for (i = 0; i < 3; i++) |
||
77 | + for (i = 0; i < 4; i++) |
||
78 | token[i] = strsep(&str, ","); |
||
79 | |||
80 | if (str) { |
||
81 | @@ -405,7 +415,10 @@ static int block2mtd_setup2(const char * |
||
82 | if (token[2] && (strlen(token[2]) + 1 > 80)) |
||
83 | pr_err("mtd device name too long\n"); |
||
84 | |||
85 | - add_device(name, erase_size, token[2]); |
||
86 | + if (token[3] && kstrtoul(token[3], 0, &timeout)) |
||
87 | + pr_err("invalid timeout\n"); |
||
88 | + |
||
89 | + add_device(name, erase_size, token[2], timeout); |
||
90 | |||
91 | return 0; |
||
92 | } |
||
93 | @@ -439,7 +452,7 @@ static int block2mtd_setup(const char *v |
||
94 | |||
95 | |||
96 | module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200); |
||
97 | -MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>]]\""); |
||
98 | +MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>[,<timeout>]]]\""); |
||
99 | |||
100 | static int __init block2mtd_init(void) |
||
101 | { |
||
102 | @@ -474,7 +487,7 @@ static void block2mtd_exit(void) |
||
103 | } |
||
104 | |||
105 | |||
106 | -module_init(block2mtd_init); |
||
107 | +late_initcall(block2mtd_init); |
||
108 | module_exit(block2mtd_exit); |
||
109 | |||
110 | MODULE_LICENSE("GPL"); |