add olpc 2.6.31 configuration, forward port the block2mtd patch, refresh patches
[openwrt/staging/yousong.git] / target / linux / x86 / patches-2.6.31 / 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 @@ struct block2mtd_dev {
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 @@ static int block2mtd_setup2(const char *
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 @@ -622,12 +622,14 @@
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 --- a/init/do_mounts.c
87 +++ b/init/do_mounts.c
88 @@ -176,16 +176,8 @@ static int __init fs_names_setup(char *s
89 return 1;
90 }
91
92 -static unsigned int __initdata root_delay;
93 -static int __init root_delay_setup(char *str)
94 -{
95 - root_delay = simple_strtoul(str, NULL, 0);
96 - return 1;
97 -}
98 -
99 __setup("rootflags=", root_data_setup);
100 __setup("rootfstype=", fs_names_setup);
101 -__setup("rootdelay=", root_delay_setup);
102
103 static void __init get_fs_names(char *page)
104 {
105 @@ -366,23 +358,6 @@ void __init prepare_namespace(void)
106 {
107 int is_floppy;
108
109 - if (root_delay) {
110 - printk(KERN_INFO "Waiting %dsec before mounting root device...\n",
111 - root_delay);
112 - ssleep(root_delay);
113 - }
114 -
115 - /*
116 - * wait for the known devices to complete their probing
117 - *
118 - * Note: this is a potential source of long boot delays.
119 - * For example, it is not atypical to wait 5 seconds here
120 - * for the touchpad of a laptop to initialize.
121 - */
122 - wait_for_device_probe();
123 -
124 - md_run_setup();
125 -
126 if (saved_root_name[0]) {
127 root_device_name = saved_root_name;
128 if (!strncmp(root_device_name, "mtd", 3) ||
129 --- a/init/main.c
130 +++ b/init/main.c
131 @@ -79,6 +79,7 @@
132 #ifdef CONFIG_X86_LOCAL_APIC
133 #include <asm/smp.h>
134 #endif
135 +#include "do_mounts.h"
136
137 static int kernel_init(void *);
138
139 @@ -784,12 +785,13 @@ int do_one_initcall(initcall_t fn)
140
141
142 extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[];
143 +extern initcall_t __root_initcall_start[], __root_initcall_end[];
144
145 -static void __init do_initcalls(void)
146 +static void __init do_initcalls(initcall_t *start, initcall_t *end)
147 {
148 initcall_t *call;
149
150 - for (call = __early_initcall_end; call < __initcall_end; call++)
151 + for (call = start; call < end; call++)
152 do_one_initcall(*call);
153
154 /* Make sure there is no pending stuff from the initcall sequence */
155 @@ -873,6 +875,13 @@ static noinline int init_post(void)
156 panic("No init found. Try passing init= option to kernel.");
157 }
158
159 +static unsigned int __initdata root_delay;
160 +static int __init root_delay_setup(char *str)
161 +{
162 + root_delay = simple_strtoul(str, NULL, 0);
163 + return 1;
164 +}
165 +__setup("rootdelay=", root_delay_setup);
166 static int __init kernel_init(void * unused)
167 {
168 lock_kernel();
169 @@ -917,7 +926,16 @@ static int __init kernel_init(void * unu
170
171 if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
172 ramdisk_execute_command = NULL;
173 - prepare_namespace();
174 + if (root_delay) {
175 + printk(KERN_INFO "Waiting %desc before mounting root device...\n",
176 + root_delay);
177 + ssleep(root_delay);
178 + }
179 + while (driver_probe_done() != 0)
180 + msleep(100);
181 + md_run_setup();
182 + do_initcalls(__root_initcall_start, __root_initcall_end);
183 + prepare_namespace();
184 }
185
186 /*