[imagebuilder] fix custom package selection
[openwrt.git] / target / linux / x86 / patches-2.6.32 / 300-block2mtd_init.patch
1 --- a/drivers/mtd/devices/block2mtd.c
2 +++ b/drivers/mtd/devices/block2mtd.c
3 @@ -18,10 +18,18 @@
4 #include <linux/buffer_head.h>
5 #include <linux/mutex.h>
6 #include <linux/mount.h>
7 +#include <linux/list.h>
8 +#include <linux/delay.h>
9
10 #define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args)
11 #define INFO(fmt, args...) printk(KERN_INFO "block2mtd: " fmt "\n" , ## args)
12
13 +struct retry {
14 + struct list_head list;
15 + const char *val;
16 +};
17 +
18 +static LIST_HEAD(retry_list);
19
20 /* Info for the block device */
21 struct block2mtd_dev {
22 @@ -33,10 +41,34 @@
23 char devname[0];
24 };
25
26 +static int block2mtd_setup2(const char *val);
27
28 /* Static info about the MTD, used in cleanup_module */
29 static LIST_HEAD(blkmtd_device_list);
30
31 +static int add_retry(const char *val) {
32 + struct retry *r = kmalloc(sizeof(struct retry), GFP_KERNEL);
33 +
34 + INIT_LIST_HEAD(&r->list);
35 + r->val = val;
36 + list_add(&r->list, &retry_list);
37 +
38 + return 0;
39 +}
40 +
41 +static int __init process_retries(void) {
42 + struct list_head *p, *tmp;
43 +
44 + list_for_each_safe(p, tmp, &retry_list) {
45 + struct retry *r = list_entry(p, struct retry, list);
46 + block2mtd_setup2(r->val);
47 + msleep(100);
48 + list_del(p);
49 + kfree(r);
50 + }
51 + return 0;
52 +}
53 +rootfs_initcall(process_retries);
54
55 static struct page *page_read(struct address_space *mapping, int index)
56 {
57 @@ -511,7 +543,9 @@
58 if (token[2] && (strlen(token[2]) + 1 > 80))
59 parse_err("mtd device name too long");
60
61 - add_device(name, erase_size, token[2]);
62 + if (add_device(name, erase_size, token[2]) == NULL) {
63 + add_retry(val);
64 + }
65
66 return 0;
67 }
68 --- a/include/asm-generic/vmlinux.lds.h
69 +++ b/include/asm-generic/vmlinux.lds.h
70 @@ -614,17 +614,24 @@
71 *(.initcall4s.init) \
72 *(.initcall5.init) \
73 *(.initcall5s.init) \
74 - *(.initcallrootfs.init) \
75 *(.initcall6.init) \
76 *(.initcall6s.init) \
77 *(.initcall7.init) \
78 *(.initcall7s.init)
79
80 +#define INITCALLS_ROOT \
81 + *(.initcallrootfs.init)
82 +
83 #define INIT_CALLS \
84 VMLINUX_SYMBOL(__initcall_start) = .; \
85 INITCALLS \
86 VMLINUX_SYMBOL(__initcall_end) = .;
87
88 +#define INIT_CALLS_ROOT \
89 + VMLINUX_SYMBOL(__root_initcall_start) = .; \
90 + INITCALLS_ROOT \
91 + VMLINUX_SYMBOL(__root_initcall_end) = .;
92 +
93 #define CON_INITCALL \
94 VMLINUX_SYMBOL(__con_initcall_start) = .; \
95 *(.con_initcall.init) \
96 @@ -766,6 +773,7 @@
97 INIT_DATA \
98 INIT_SETUP(initsetup_align) \
99 INIT_CALLS \
100 + INIT_CALLS_ROOT \
101 CON_INITCALL \
102 SECURITY_INITCALL \
103 INIT_RAM_FS \
104 --- a/init/do_mounts.c
105 +++ b/init/do_mounts.c
106 @@ -176,16 +176,8 @@
107 return 1;
108 }
109
110 -static unsigned int __initdata root_delay;
111 -static int __init root_delay_setup(char *str)
112 -{
113 - root_delay = simple_strtoul(str, NULL, 0);
114 - return 1;
115 -}
116 -
117 __setup("rootflags=", root_data_setup);
118 __setup("rootfstype=", fs_names_setup);
119 -__setup("rootdelay=", root_delay_setup);
120
121 static void __init get_fs_names(char *page)
122 {
123 @@ -366,23 +358,6 @@
124 {
125 int is_floppy;
126
127 - if (root_delay) {
128 - printk(KERN_INFO "Waiting %dsec before mounting root device...\n",
129 - root_delay);
130 - ssleep(root_delay);
131 - }
132 -
133 - /*
134 - * wait for the known devices to complete their probing
135 - *
136 - * Note: this is a potential source of long boot delays.
137 - * For example, it is not atypical to wait 5 seconds here
138 - * for the touchpad of a laptop to initialize.
139 - */
140 - wait_for_device_probe();
141 -
142 - md_run_setup();
143 -
144 if (saved_root_name[0]) {
145 root_device_name = saved_root_name;
146 if (!strncmp(root_device_name, "mtd", 3) ||
147 --- a/init/main.c
148 +++ b/init/main.c
149 @@ -80,6 +80,7 @@
150 #ifdef CONFIG_X86_LOCAL_APIC
151 #include <asm/smp.h>
152 #endif
153 +#include "do_mounts.h"
154
155 static int kernel_init(void *);
156
157 @@ -752,12 +753,13 @@
158
159
160 extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[];
161 +extern initcall_t __root_initcall_start[], __root_initcall_end[];
162
163 -static void __init do_initcalls(void)
164 +static void __init do_initcalls(initcall_t *start, initcall_t *end)
165 {
166 initcall_t *call;
167
168 - for (call = __early_initcall_end; call < __initcall_end; call++)
169 + for (call = start; call < end; call++)
170 do_one_initcall(*call);
171
172 /* Make sure there is no pending stuff from the initcall sequence */
173 @@ -780,7 +782,7 @@
174 driver_init();
175 init_irq_proc();
176 do_ctors();
177 - do_initcalls();
178 + do_initcalls(__early_initcall_end, __initcall_end);
179 }
180
181 static void __init do_pre_smp_initcalls(void)
182 @@ -841,6 +843,13 @@
183 panic("No init found. Try passing init= option to kernel.");
184 }
185
186 +static unsigned int __initdata root_delay;
187 +static int __init root_delay_setup(char *str)
188 +{
189 + root_delay = simple_strtoul(str, NULL, 0);
190 + return 1;
191 +}
192 +__setup("rootdelay=", root_delay_setup);
193 static int __init kernel_init(void * unused)
194 {
195 lock_kernel();
196 @@ -885,7 +894,16 @@
197
198 if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
199 ramdisk_execute_command = NULL;
200 - prepare_namespace();
201 + if (root_delay) {
202 + printk(KERN_INFO "Waiting %desc before mounting root device...\n",
203 + root_delay);
204 + ssleep(root_delay);
205 + }
206 + while (driver_probe_done() != 0)
207 + msleep(100);
208 + do_initcalls(__root_initcall_start, __root_initcall_end);
209 + md_run_setup();
210 + prepare_namespace();
211 }
212
213 /*
This page took 0.049494 seconds and 5 git commands to generate.