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