mtd-root.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. diff -Nur linux-2.6.37.orig/drivers/mtd/Kconfig linux-2.6.37/drivers/mtd/Kconfig
  2. --- linux-2.6.37.orig/drivers/mtd/Kconfig 2011-01-05 01:50:19.000000000 +0100
  3. +++ linux-2.6.37/drivers/mtd/Kconfig 2011-01-11 20:32:21.000000000 +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.37.orig/drivers/mtd/mtdpart.c linux-2.6.37/drivers/mtd/mtdpart.c
  16. --- linux-2.6.37.orig/drivers/mtd/mtdpart.c 2011-01-05 01:50:19.000000000 +0100
  17. +++ linux-2.6.37/drivers/mtd/mtdpart.c 2011-01-11 20:40:29.000000000 +0100
  18. @@ -30,6 +30,7 @@
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/partitions.h>
  21. #include <linux/err.h>
  22. +#include <linux/root_dev.h>
  23. /* Our partition linked list */
  24. static LIST_HEAD(mtd_partitions);
  25. @@ -48,7 +49,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. @@ -633,15 +634,24 @@
  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 = allocate_partition(master, parts + i, i, cur_offset);
  42. - if (IS_ERR(slave))
  43. + for (i = 0, j = 0; i < nbparts; i++) {
  44. + slave = add_one_partition(master, parts + i, j++, cur_offset);
  45. + if (!(slave))
  46. return PTR_ERR(slave);
  47. +
  48. + if (!strcmp(parts[i].name, "rootfs")) {
  49. +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
  50. + if (ROOT_DEV == 0) {
  51. + printk(KERN_NOTICE "mtd: partition \"rootfs\" "
  52. + "set to be root filesystem\n");
  53. + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, slave->mtd.index);
  54. + }
  55. +#endif
  56. mutex_lock(&mtd_partitions_mutex);
  57. list_add(&slave->list, &mtd_partitions);
  58. mutex_unlock(&mtd_partitions_mutex);