480-mtd-set-rootfs-to-be-root-dev.patch 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From: Gabor Juhos <juhosg@openwrt.org>
  2. Subject: kernel/3.1[02]: move MTD root device setup code to mtdcore
  3. The current code only allows to automatically set
  4. root device on MTD partitions. Move the code to MTD
  5. core to allow to use it with all MTD devices.
  6. Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
  7. ---
  8. drivers/mtd/mtdcore.c | 10 ++++++++++
  9. 1 file changed, 10 insertions(+)
  10. --- a/drivers/mtd/mtdcore.c
  11. +++ b/drivers/mtd/mtdcore.c
  12. @@ -41,6 +41,7 @@
  13. #include <linux/reboot.h>
  14. #include <linux/leds.h>
  15. #include <linux/debugfs.h>
  16. +#include <linux/root_dev.h>
  17. #include <linux/mtd/mtd.h>
  18. #include <linux/mtd/partitions.h>
  19. @@ -578,6 +579,15 @@ int add_mtd_device(struct mtd_info *mtd)
  20. of this try_ nonsense, and no bitching about it
  21. either. :) */
  22. __module_get(THIS_MODULE);
  23. +
  24. + if (!strcmp(mtd->name, "rootfs") &&
  25. + IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
  26. + ROOT_DEV == 0) {
  27. + pr_notice("mtd: device %d (%s) set to be root filesystem\n",
  28. + mtd->index, mtd->name);
  29. + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
  30. + }
  31. +
  32. return 0;
  33. fail_added: