mtd-root.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. diff -Nur linux-2.6.36.orig/drivers/mtd/Kconfig linux-2.6.36/drivers/mtd/Kconfig
  2. --- linux-2.6.36.orig/drivers/mtd/Kconfig 2010-10-20 22:30:22.000000000 +0200
  3. +++ linux-2.6.36/drivers/mtd/Kconfig 2010-11-09 13:26:44.923745421 +0100
  4. @@ -53,6 +53,11 @@
  5. devices. Partitioning on NFTL 'devices' is a different - that's the
  6. 'normal' form of partitioning used on a block device.
  7. +config MTD_ROOTFS_ROOT_DEV
  8. + bool "Automatically set 'rootfs' partition to be root filesystem"
  9. + depends on MTD_PARTITIONS
  10. + default y
  11. +
  12. config MTD_REDBOOT_PARTS
  13. tristate "RedBoot partition table parsing"
  14. depends on MTD_PARTITIONS
  15. diff -Nur linux-2.6.36.orig/drivers/mtd/mtdpart.c linux-2.6.36/drivers/mtd/mtdpart.c
  16. --- linux-2.6.36.orig/drivers/mtd/mtdpart.c 2010-10-20 22:30:22.000000000 +0200
  17. +++ linux-2.6.36/drivers/mtd/mtdpart.c 2010-11-09 13:27:26.703745576 +0100
  18. @@ -29,6 +29,7 @@
  19. #include <linux/kmod.h>
  20. #include <linux/mtd/mtd.h>
  21. #include <linux/mtd/partitions.h>
  22. +#include <linux/root_dev.h>
  23. /* Our partition linked list */
  24. static LIST_HEAD(mtd_partitions);
  25. @@ -46,7 +47,7 @@
  26. * the pointer to that structure with this macro.
  27. */
  28. #define PART(x) ((struct mtd_part *)(x))
  29. -
  30. +#define IS_PART(mtd) (mtd->read == part_read)
  31. /*
  32. * MTD methods which simply translate the effective address and pass through
  33. @@ -539,14 +540,23 @@
  34. {
  35. struct mtd_part *slave;
  36. uint64_t cur_offset = 0;
  37. - int i;
  38. + int i, j;
  39. printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
  40. - for (i = 0; i < nbparts; i++) {
  41. - slave = add_one_partition(master, parts + i, i, cur_offset);
  42. + for (i = 0, j = 0; i < nbparts; i++) {
  43. + slave = add_one_partition(master, parts + i, j++, cur_offset);
  44. if (!slave)
  45. return -ENOMEM;
  46. + if (!strcmp(parts[i].name, "rootfs")) {
  47. +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
  48. + if (ROOT_DEV == 0) {
  49. + printk(KERN_NOTICE "mtd: partition \"rootfs\" "
  50. + "set to be root filesystem\n");
  51. + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, slave->mtd.index);
  52. + }
  53. +#endif
  54. + }
  55. cur_offset = slave->offset + slave->mtd.size;
  56. }