300-block2mtd_init.patch 5.3 KB

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