Delete 2.6.24 files for OLPC
[openwrt.git] / target / linux / olpc / patches-2.6.26 / 300-block2mtd_init.patch
1 diff -urN linux-2.6.26.orig/arch/x86/kernel/vmlinux_32.lds.S linux-2.6.26/arch/x86/kernel/vmlinux_32.lds.S
2 --- linux-2.6.26.orig/arch/x86/kernel/vmlinux_32.lds.S  2008-08-13 03:51:12.000000000 +0200
3 +++ linux-2.6.26/arch/x86/kernel/vmlinux_32.lds.S       2008-08-13 04:08:18.000000000 +0200
4 @@ -144,6 +144,12 @@
5         INITCALLS
6         __initcall_end = .;
7    }
8 +  .root_initcall.init : AT(ADDR(.root_initcall.init) - LOAD_OFFSET) {
9 +    __root_initcall_start = .;
10 +    INITCALLS_ROOT
11 +    __root_initcall_end = .;
12 +  }
13 +   
14    .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
15         __con_initcall_start = .;
16         *(.con_initcall.init)
17 diff -urN linux-2.6.26.orig/drivers/mtd/devices/block2mtd.c linux-2.6.26/drivers/mtd/devices/block2mtd.c
18 --- linux-2.6.26.orig/drivers/mtd/devices/block2mtd.c   2008-08-13 03:51:05.000000000 +0200
19 +++ linux-2.6.26/drivers/mtd/devices/block2mtd.c        2008-08-13 04:06:43.000000000 +0200
20 @@ -20,6 +20,8 @@
21  #include <linux/buffer_head.h>
22  #include <linux/mutex.h>
23  #include <linux/mount.h>
24 +#include <linux/list.h>
25 +#include <linux/delay.h>
26  
27  #define VERSION "$Revision: 1.30 $"
28  
29 @@ -27,6 +29,12 @@
30  #define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args)
31  #define INFO(fmt, args...) printk(KERN_INFO "block2mtd: " fmt "\n" , ## args)
32  
33 +struct retry {
34 +    struct list_head list;
35 +    const char *val;
36 +};
37 +
38 +static LIST_HEAD(retry_list);
39  
40  /* Info for the block device */
41  struct block2mtd_dev {
42 @@ -38,10 +46,34 @@
43         char devname[0];
44  };
45  
46 +static int block2mtd_setup2(const char *val);
47  
48  /* Static info about the MTD, used in cleanup_module */
49  static LIST_HEAD(blkmtd_device_list);
50  
51 +static int add_retry(const char *val) {
52 +    struct retry *r = kmalloc(sizeof(struct retry), GFP_KERNEL);
53 +
54 +    INIT_LIST_HEAD(&r->list);
55 +    r->val = val;
56 +    list_add(&r->list, &retry_list);
57 +
58 +    return 0;
59 +}
60 +
61 +static int __init process_retries(void) {
62 +    struct list_head *p, *tmp;
63 +
64 +    list_for_each_safe(p, tmp, &retry_list) {
65 +        struct retry *r = list_entry(p, struct retry, list);
66 +        block2mtd_setup2(r->val);
67 +        msleep(100);
68 +        list_del(p);
69 +        kfree(r);
70 +    }
71 +    return 0;
72 +}
73 +rootfs_initcall(process_retries);
74  
75  static struct page *page_read(struct address_space *mapping, int index)
76  {
77 @@ -517,7 +549,9 @@
78         if (token[2] && (strlen(token[2]) + 1 > 80))
79                 parse_err("mtd device name too long");
80  
81 -       add_device(name, erase_size, token[2]);
82 +       if (add_device(name, erase_size, token[2]) == NULL) {
83 +        add_retry(val);
84 +    }   
85  
86         return 0;
87  }
88 diff -urN linux-2.6.26.orig/include/asm-generic/vmlinux.lds.h linux-2.6.26/include/asm-generic/vmlinux.lds.h
89 --- linux-2.6.26.orig/include/asm-generic/vmlinux.lds.h 2008-08-13 03:51:08.000000000 +0200
90 +++ linux-2.6.26/include/asm-generic/vmlinux.lds.h      2008-08-13 04:09:04.000000000 +0200
91 @@ -338,12 +338,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 PERCPU(align)                                                  \
105         . = ALIGN(align);                                               \
106         __per_cpu_start = .;                                            \
107 diff -urN linux-2.6.26.orig/init/do_mounts.c linux-2.6.26/init/do_mounts.c
108 --- linux-2.6.26.orig/init/do_mounts.c  2008-08-13 03:51:11.000000000 +0200
109 +++ linux-2.6.26/init/do_mounts.c       2008-08-13 04:00:22.000000000 +0200
110 @@ -173,16 +173,8 @@
111         return 1;
112  }
113  
114 -static unsigned int __initdata root_delay;
115 -static int __init root_delay_setup(char *str)
116 -{
117 -       root_delay = simple_strtoul(str, NULL, 0);
118 -       return 1;
119 -}
120 -
121  __setup("rootflags=", root_data_setup);
122  __setup("rootfstype=", fs_names_setup);
123 -__setup("rootdelay=", root_delay_setup);
124  
125  static void __init get_fs_names(char *page)
126  {
127 @@ -358,18 +350,6 @@
128  {
129         int is_floppy;
130  
131 -       if (root_delay) {
132 -               printk(KERN_INFO "Waiting %dsec before mounting root device...\n",
133 -                      root_delay);
134 -               ssleep(root_delay);
135 -       }
136 -
137 -       /* wait for the known devices to complete their probing */
138 -       while (driver_probe_done() != 0)
139 -               msleep(100);
140 -
141 -       md_run_setup();
142 -
143         if (saved_root_name[0]) {
144                 root_device_name = saved_root_name;
145                 if (!strncmp(root_device_name, "mtd", 3)) {
146 diff -urN linux-2.6.26.orig/init/main.c linux-2.6.26/init/main.c
147 --- linux-2.6.26.orig/init/main.c       2008-08-13 03:51:11.000000000 +0200
148 +++ linux-2.6.26/init/main.c    2008-08-13 04:06:01.000000000 +0200
149 @@ -70,6 +70,7 @@
150  #ifdef CONFIG_X86_LOCAL_APIC
151  #include <asm/smp.h>
152  #endif
153 +#include "do_mounts.h"
154  
155  /*
156   * This is one of the first .c files built. Error out early if we have compiler
157 @@ -737,12 +738,13 @@
158  
159  
160  extern initcall_t __initcall_start[], __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 = __initcall_start; 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 @@ -763,7 +765,7 @@
174         usermodehelper_init();
175         driver_init();
176         init_irq_proc();
177 -       do_initcalls();
178 +       do_initcalls(__initcall_start, __initcall_end);
179  }
180  
181  static int __initdata nosoftlockup;
182 @@ -835,6 +837,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 @@ -875,7 +884,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 +        md_run_setup();
209 +        do_initcalls(__root_initcall_start, __root_initcall_end);
210 +        prepare_namespace();
211         }
212  
213         /*