kernel/3.1[02]: move MTD root device setup code to mtdcore
authorGabor Juhos <juhosg@openwrt.org>
Mon, 4 Nov 2013 18:37:05 +0000 (18:37 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Mon, 4 Nov 2013 18:37:05 +0000 (18:37 +0000)
The current code only allows to automatically set
root device on MTD partitions. Move the code to MTD
core to allow to use it with all MTD devices.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
SVN-Revision: 38643

16 files changed:
target/linux/generic/patches-3.10/400-mtd-add-rootfs-split-support.patch
target/linux/generic/patches-3.10/401-mtd-add-support-for-different-partition-parser-types.patch
target/linux/generic/patches-3.10/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch
target/linux/generic/patches-3.10/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch
target/linux/generic/patches-3.10/405-mtd-add-more-helper-functions.patch
target/linux/generic/patches-3.10/411-mtd-partial_eraseblock_write.patch
target/linux/generic/patches-3.10/412-mtd-partial_eraseblock_unlock.patch
target/linux/generic/patches-3.10/480-mtd-set-rootfs-to-be-root-dev.patch [new file with mode: 0644]
target/linux/generic/patches-3.12/400-mtd-add-rootfs-split-support.patch
target/linux/generic/patches-3.12/401-mtd-add-support-for-different-partition-parser-types.patch
target/linux/generic/patches-3.12/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch
target/linux/generic/patches-3.12/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch
target/linux/generic/patches-3.12/405-mtd-add-more-helper-functions.patch
target/linux/generic/patches-3.12/411-mtd-partial_eraseblock_write.patch
target/linux/generic/patches-3.12/412-mtd-partial_eraseblock_unlock.patch
target/linux/generic/patches-3.12/480-mtd-set-rootfs-to-be-root-dev.patch [new file with mode: 0644]

index 6a4c16134e9e8f7183d3ed8bac2f41be3c7e1f5c..6c17b01e53e71754cfd02a7a1a7a703bff5e752c 100644 (file)
        depends on m
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
        depends on m
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -29,6 +29,8 @@
+@@ -29,6 +29,7 @@
  #include <linux/kmod.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
  #include <linux/kmod.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
-+#include <linux/root_dev.h>
 +#include <linux/magic.h>
  #include <linux/err.h>
  
  #include "mtdcore.h"
 +#include <linux/magic.h>
  #include <linux/err.h>
  
  #include "mtdcore.h"
-@@ -45,13 +47,14 @@ struct mtd_part {
+@@ -45,13 +46,14 @@ struct mtd_part {
        struct list_head list;
  };
  
        struct list_head list;
  };
  
@@ -60,7 +59,7 @@
  /*
   * MTD methods which simply translate the effective address and pass through
   * to the _real_ device.
  /*
   * MTD methods which simply translate the effective address and pass through
   * to the _real_ device.
-@@ -533,8 +536,10 @@ out_register:
+@@ -533,8 +535,10 @@ out_register:
        return slave;
  }
  
        return slave;
  }
  
@@ -73,7 +72,7 @@
  {
        struct mtd_partition part;
        struct mtd_part *p, *new;
  {
        struct mtd_partition part;
        struct mtd_part *p, *new;
-@@ -566,21 +571,24 @@ int mtd_add_partition(struct mtd_info *m
+@@ -566,21 +570,24 @@ int mtd_add_partition(struct mtd_info *m
        end = offset + length;
  
        mutex_lock(&mtd_partitions_mutex);
        end = offset + length;
  
        mutex_lock(&mtd_partitions_mutex);
  
        return ret;
  err_inv:
  
        return ret;
  err_inv:
-@@ -590,6 +598,12 @@ err_inv:
+@@ -590,6 +597,12 @@ err_inv:
  }
  EXPORT_SYMBOL_GPL(mtd_add_partition);
  
  }
  EXPORT_SYMBOL_GPL(mtd_add_partition);
  
  int mtd_del_partition(struct mtd_info *master, int partno)
  {
        struct mtd_part *slave, *next;
  int mtd_del_partition(struct mtd_info *master, int partno)
  {
        struct mtd_part *slave, *next;
-@@ -613,6 +627,151 @@ int mtd_del_partition(struct mtd_info *m
+@@ -613,6 +626,144 @@ int mtd_del_partition(struct mtd_info *m
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
 +      if (!strcmp(part->mtd.name, "rootfs")) {
 +              rootfs_found = 1;
 +
 +      if (!strcmp(part->mtd.name, "rootfs")) {
 +              rootfs_found = 1;
 +
-+              if (config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
-+                  ROOT_DEV == 0) {
-+                      printk(KERN_NOTICE "mtd: partition \"rootfs\" "
-+                              "set to be root filesystem\n");
-+                      ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, part->mtd.index);
-+              }
-+
 +              if (config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
 +                      split_rootfs_data(master, part);
 +      }
 +              if (config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
 +                      split_rootfs_data(master, part);
 +      }
  /*
   * This function, given a master MTD object and a partition table, creates
   * and registers slave MTD objects which are bound to the master according to
  /*
   * This function, given a master MTD object and a partition table, creates
   * and registers slave MTD objects which are bound to the master according to
-@@ -642,6 +801,7 @@ int add_mtd_partitions(struct mtd_info *
+@@ -642,6 +793,7 @@ int add_mtd_partitions(struct mtd_info *
                mutex_unlock(&mtd_partitions_mutex);
  
                add_mtd_device(&slave->mtd);
                mutex_unlock(&mtd_partitions_mutex);
  
                add_mtd_device(&slave->mtd);
index 8ac084d5e1fc152d4c29253711b06e47c2b80f50..bd35aa7d35388e96178fc1e4ab3b49a9756e7f53 100644 (file)
@@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
 
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -831,6 +831,30 @@ static struct mtd_part_parser *get_parti
+@@ -823,6 +823,30 @@ static struct mtd_part_parser *get_parti
  
  #define put_partition_parser(p) do { module_put((p)->owner); } while (0)
  
  
  #define put_partition_parser(p) do { module_put((p)->owner); } while (0)
  
@@ -42,7 +42,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
  int register_mtd_parser(struct mtd_part_parser *p)
  {
        spin_lock(&part_parser_lock);
  int register_mtd_parser(struct mtd_part_parser *p)
  {
        spin_lock(&part_parser_lock);
-@@ -907,6 +931,38 @@ int parse_mtd_partitions(struct mtd_info
+@@ -899,6 +923,38 @@ int parse_mtd_partitions(struct mtd_info
        return ret;
  }
  
        return ret;
  }
  
index a614094851c8db0a23be3225724cd28a7d2f1798..649693ff22c2c6c7ac8f7800f9d37c22ec7d6dd7 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -627,6 +627,37 @@ int mtd_del_partition(struct mtd_info *m
+@@ -626,6 +626,37 @@ int mtd_del_partition(struct mtd_info *m
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
@@ -38,7 +38,7 @@
  static inline unsigned long
  mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
  {
  static inline unsigned long
  mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
  {
-@@ -686,6 +717,10 @@ static void split_rootfs_data(struct mtd
+@@ -685,6 +716,10 @@ static void split_rootfs_data(struct mtd
        unsigned int split_size;
        int ret;
  
        unsigned int split_size;
        int ret;
  
@@ -49,7 +49,7 @@
        ret = split_squashfs(master, part->offset, &split_offset);
        if (ret)
                return;
        ret = split_squashfs(master, part->offset, &split_offset);
        if (ret)
                return;
-@@ -735,6 +770,12 @@ static void split_uimage(struct mtd_info
+@@ -734,6 +769,12 @@ static void split_uimage(struct mtd_info
  
  static void split_firmware(struct mtd_info *master, struct mtd_part *part)
  {
  
  static void split_firmware(struct mtd_info *master, struct mtd_part *part)
  {
index 43960b3065a0aad2d17a9b1d130218a227c3db28..9024026c9c67cab35771dd5626d8b04b274d217f 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -34,6 +34,7 @@
+@@ -33,6 +33,7 @@
  #include <linux/err.h>
  
  #include "mtdcore.h"
  #include <linux/err.h>
  
  #include "mtdcore.h"
@@ -8,7 +8,7 @@
  
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
-@@ -669,43 +670,16 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+@@ -668,43 +669,16 @@ mtd_pad_erasesize(struct mtd_info *mtd,
        return len;
  }
  
        return len;
  }
  
index 97ad2db87e5d1f6fe45a4b1a08ab135bd6f279eb..9c75e5cb15aaf1054a5f19c86bd7a705e92289fd 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -435,14 +435,12 @@ static struct mtd_part *allocate_partiti
+@@ -434,14 +434,12 @@ static struct mtd_part *allocate_partiti
        if (slave->offset == MTDPART_OFS_APPEND)
                slave->offset = cur_offset;
        if (slave->offset == MTDPART_OFS_NXTBLK) {
        if (slave->offset == MTDPART_OFS_APPEND)
                slave->offset = cur_offset;
        if (slave->offset == MTDPART_OFS_NXTBLK) {
@@ -18,7 +18,7 @@
        }
        if (slave->offset == MTDPART_OFS_RETAIN) {
                slave->offset = cur_offset;
        }
        if (slave->offset == MTDPART_OFS_RETAIN) {
                slave->offset = cur_offset;
-@@ -995,6 +993,24 @@ int mtd_is_partition(const struct mtd_in
+@@ -987,6 +985,24 @@ int mtd_is_partition(const struct mtd_in
  }
  EXPORT_SYMBOL_GPL(mtd_is_partition);
  
  }
  EXPORT_SYMBOL_GPL(mtd_is_partition);
  
index 560096f854b1642e13129b02b16946ed688a73fe..b7152110b2912b61bddbbd0e0b039063bcca6c32 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -36,6 +36,8 @@
+@@ -35,6 +35,8 @@
  #include "mtdcore.h"
  #include "mtdsplit.h"
  
  #include "mtdcore.h"
  #include "mtdsplit.h"
  
@@ -9,7 +9,7 @@
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -232,13 +234,60 @@ static int part_erase(struct mtd_info *m
+@@ -231,13 +233,60 @@ static int part_erase(struct mtd_info *m
        struct mtd_part *part = PART(mtd);
        int ret;
  
        struct mtd_part *part = PART(mtd);
        int ret;
  
@@ -70,7 +70,7 @@
        return ret;
  }
  
        return ret;
  }
  
-@@ -246,7 +295,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -245,7 +294,25 @@ void mtd_erase_callback(struct erase_inf
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
@@ -96,7 +96,7 @@
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
-@@ -504,18 +571,24 @@ static struct mtd_part *allocate_partiti
+@@ -503,18 +570,24 @@ static struct mtd_part *allocate_partiti
        if ((slave->mtd.flags & MTD_WRITEABLE) &&
            mtd_mod_by_eb(slave->offset, &slave->mtd)) {
                /* Doesn't start on a boundary of major erase size */
        if ((slave->mtd.flags & MTD_WRITEABLE) &&
            mtd_mod_by_eb(slave->offset, &slave->mtd)) {
                /* Doesn't start on a boundary of major erase size */
index 87c8257fe115d55ae72c1476d01f9288591ecc59..134f65715e95bd320a449d3fcfb99a11d7b391b5 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -332,7 +332,14 @@ static int part_lock(struct mtd_info *mt
+@@ -331,7 +331,14 @@ static int part_lock(struct mtd_info *mt
  static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
  {
        struct mtd_part *part = PART(mtd);
  static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
  {
        struct mtd_part *part = PART(mtd);
diff --git a/target/linux/generic/patches-3.10/480-mtd-set-rootfs-to-be-root-dev.patch b/target/linux/generic/patches-3.10/480-mtd-set-rootfs-to-be-root-dev.patch
new file mode 100644 (file)
index 0000000..58c4a8a
--- /dev/null
@@ -0,0 +1,26 @@
+--- a/drivers/mtd/mtdcore.c
++++ b/drivers/mtd/mtdcore.c
+@@ -37,6 +37,7 @@
+ #include <linux/backing-dev.h>
+ #include <linux/gfp.h>
+ #include <linux/slab.h>
++#include <linux/root_dev.h>
+ #include <linux/mtd/mtd.h>
+ #include <linux/mtd/partitions.h>
+@@ -408,6 +409,15 @@ int add_mtd_device(struct mtd_info *mtd)
+          of this try_ nonsense, and no bitching about it
+          either. :) */
+       __module_get(THIS_MODULE);
++
++      if (!strcmp(mtd->name, "rootfs") &&
++          config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
++          ROOT_DEV == 0) {
++              pr_notice("mtd: device %d (%s) set to be root filesystem\n",
++                        mtd->index, mtd->name);
++              ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
++      }
++
+       return 0;
+ fail_added:
index 215aef14deb6d7516eea580c4b6d5240c9b39bc2..ce91d7ba5e369063123358f4d62c2f72f336aed0 100644 (file)
        depends on m
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
        depends on m
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -29,6 +29,8 @@
+@@ -29,6 +29,7 @@
  #include <linux/kmod.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
  #include <linux/kmod.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
-+#include <linux/root_dev.h>
 +#include <linux/magic.h>
  #include <linux/err.h>
  
  #include "mtdcore.h"
 +#include <linux/magic.h>
  #include <linux/err.h>
  
  #include "mtdcore.h"
-@@ -45,13 +47,14 @@ struct mtd_part {
+@@ -45,13 +46,14 @@ struct mtd_part {
        struct list_head list;
  };
  
        struct list_head list;
  };
  
@@ -60,7 +59,7 @@
  /*
   * MTD methods which simply translate the effective address and pass through
   * to the _real_ device.
  /*
   * MTD methods which simply translate the effective address and pass through
   * to the _real_ device.
-@@ -534,8 +537,10 @@ out_register:
+@@ -534,8 +536,10 @@ out_register:
        return slave;
  }
  
        return slave;
  }
  
@@ -73,7 +72,7 @@
  {
        struct mtd_partition part;
        struct mtd_part *p, *new;
  {
        struct mtd_partition part;
        struct mtd_part *p, *new;
-@@ -567,21 +572,24 @@ int mtd_add_partition(struct mtd_info *m
+@@ -567,21 +571,24 @@ int mtd_add_partition(struct mtd_info *m
        end = offset + length;
  
        mutex_lock(&mtd_partitions_mutex);
        end = offset + length;
  
        mutex_lock(&mtd_partitions_mutex);
  
        return ret;
  err_inv:
  
        return ret;
  err_inv:
-@@ -591,6 +599,12 @@ err_inv:
+@@ -591,6 +598,12 @@ err_inv:
  }
  EXPORT_SYMBOL_GPL(mtd_add_partition);
  
  }
  EXPORT_SYMBOL_GPL(mtd_add_partition);
  
  int mtd_del_partition(struct mtd_info *master, int partno)
  {
        struct mtd_part *slave, *next;
  int mtd_del_partition(struct mtd_info *master, int partno)
  {
        struct mtd_part *slave, *next;
-@@ -614,6 +628,151 @@ int mtd_del_partition(struct mtd_info *m
+@@ -614,6 +627,144 @@ int mtd_del_partition(struct mtd_info *m
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
 +      if (!strcmp(part->mtd.name, "rootfs")) {
 +              rootfs_found = 1;
 +
 +      if (!strcmp(part->mtd.name, "rootfs")) {
 +              rootfs_found = 1;
 +
-+              if (config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
-+                  ROOT_DEV == 0) {
-+                      printk(KERN_NOTICE "mtd: partition \"rootfs\" "
-+                              "set to be root filesystem\n");
-+                      ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, part->mtd.index);
-+              }
-+
 +              if (config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
 +                      split_rootfs_data(master, part);
 +      }
 +              if (config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
 +                      split_rootfs_data(master, part);
 +      }
  /*
   * This function, given a master MTD object and a partition table, creates
   * and registers slave MTD objects which are bound to the master according to
  /*
   * This function, given a master MTD object and a partition table, creates
   * and registers slave MTD objects which are bound to the master according to
-@@ -643,6 +802,7 @@ int add_mtd_partitions(struct mtd_info *
+@@ -643,6 +794,7 @@ int add_mtd_partitions(struct mtd_info *
                mutex_unlock(&mtd_partitions_mutex);
  
                add_mtd_device(&slave->mtd);
                mutex_unlock(&mtd_partitions_mutex);
  
                add_mtd_device(&slave->mtd);
index 8d7bcdeee6049457e8cf8d07dcb1c90267fd06b9..52b87f56cc903cc84490f0de3dc4ec5744b5bb7f 100644 (file)
@@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
 
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -832,6 +832,30 @@ static struct mtd_part_parser *get_parti
+@@ -824,6 +824,30 @@ static struct mtd_part_parser *get_parti
  
  #define put_partition_parser(p) do { module_put((p)->owner); } while (0)
  
  
  #define put_partition_parser(p) do { module_put((p)->owner); } while (0)
  
@@ -42,7 +42,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
  int register_mtd_parser(struct mtd_part_parser *p)
  {
        spin_lock(&part_parser_lock);
  int register_mtd_parser(struct mtd_part_parser *p)
  {
        spin_lock(&part_parser_lock);
-@@ -908,6 +932,38 @@ int parse_mtd_partitions(struct mtd_info
+@@ -900,6 +924,38 @@ int parse_mtd_partitions(struct mtd_info
        return ret;
  }
  
        return ret;
  }
  
index 8d0bda825f460a7c96171d9534480918864eebd2..a614094851c8db0a23be3225724cd28a7d2f1798 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -628,6 +628,37 @@ int mtd_del_partition(struct mtd_info *m
+@@ -627,6 +627,37 @@ int mtd_del_partition(struct mtd_info *m
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
@@ -38,7 +38,7 @@
  static inline unsigned long
  mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
  {
  static inline unsigned long
  mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
  {
-@@ -687,6 +718,10 @@ static void split_rootfs_data(struct mtd
+@@ -686,6 +717,10 @@ static void split_rootfs_data(struct mtd
        unsigned int split_size;
        int ret;
  
        unsigned int split_size;
        int ret;
  
@@ -49,7 +49,7 @@
        ret = split_squashfs(master, part->offset, &split_offset);
        if (ret)
                return;
        ret = split_squashfs(master, part->offset, &split_offset);
        if (ret)
                return;
-@@ -736,6 +771,12 @@ static void split_uimage(struct mtd_info
+@@ -735,6 +770,12 @@ static void split_uimage(struct mtd_info
  
  static void split_firmware(struct mtd_info *master, struct mtd_part *part)
  {
  
  static void split_firmware(struct mtd_info *master, struct mtd_part *part)
  {
index 1ebeca64d1b1e67a222c4c9222d05109749f8e16..a54b97b07c391ba242bbdbeb5b3f7fddd4774ecd 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -34,6 +34,7 @@
+@@ -33,6 +33,7 @@
  #include <linux/err.h>
  
  #include "mtdcore.h"
  #include <linux/err.h>
  
  #include "mtdcore.h"
@@ -8,7 +8,7 @@
  
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
-@@ -670,43 +671,16 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+@@ -669,43 +670,16 @@ mtd_pad_erasesize(struct mtd_info *mtd,
        return len;
  }
  
        return len;
  }
  
index c2578c3003643435cc26bc2d1c095cad80a0b60f..a32aad4f70f7fd1510cb8614db2fba8aec950c8b 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -435,14 +435,12 @@ static struct mtd_part *allocate_partiti
+@@ -434,14 +434,12 @@ static struct mtd_part *allocate_partiti
        if (slave->offset == MTDPART_OFS_APPEND)
                slave->offset = cur_offset;
        if (slave->offset == MTDPART_OFS_NXTBLK) {
        if (slave->offset == MTDPART_OFS_APPEND)
                slave->offset = cur_offset;
        if (slave->offset == MTDPART_OFS_NXTBLK) {
@@ -18,7 +18,7 @@
        }
        if (slave->offset == MTDPART_OFS_RETAIN) {
                slave->offset = cur_offset;
        }
        if (slave->offset == MTDPART_OFS_RETAIN) {
                slave->offset = cur_offset;
-@@ -996,6 +994,24 @@ int mtd_is_partition(const struct mtd_in
+@@ -988,6 +986,24 @@ int mtd_is_partition(const struct mtd_in
  }
  EXPORT_SYMBOL_GPL(mtd_is_partition);
  
  }
  EXPORT_SYMBOL_GPL(mtd_is_partition);
  
index 7ecb3312c267000acd582a17161a88523dcbc469..523dd4e375660f262e4e298541eb4307f8f38886 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -36,6 +36,8 @@
+@@ -35,6 +35,8 @@
  #include "mtdcore.h"
  #include "mtdsplit.h"
  
  #include "mtdcore.h"
  #include "mtdsplit.h"
  
@@ -9,7 +9,7 @@
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -232,13 +234,60 @@ static int part_erase(struct mtd_info *m
+@@ -231,13 +233,60 @@ static int part_erase(struct mtd_info *m
        struct mtd_part *part = PART(mtd);
        int ret;
  
        struct mtd_part *part = PART(mtd);
        int ret;
  
@@ -70,7 +70,7 @@
        return ret;
  }
  
        return ret;
  }
  
-@@ -246,7 +295,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -245,7 +294,25 @@ void mtd_erase_callback(struct erase_inf
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
@@ -96,7 +96,7 @@
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
-@@ -504,18 +571,24 @@ static struct mtd_part *allocate_partiti
+@@ -503,18 +570,24 @@ static struct mtd_part *allocate_partiti
        if ((slave->mtd.flags & MTD_WRITEABLE) &&
            mtd_mod_by_eb(slave->offset, &slave->mtd)) {
                /* Doesn't start on a boundary of major erase size */
        if ((slave->mtd.flags & MTD_WRITEABLE) &&
            mtd_mod_by_eb(slave->offset, &slave->mtd)) {
                /* Doesn't start on a boundary of major erase size */
index 87c8257fe115d55ae72c1476d01f9288591ecc59..134f65715e95bd320a449d3fcfb99a11d7b391b5 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -332,7 +332,14 @@ static int part_lock(struct mtd_info *mt
+@@ -331,7 +331,14 @@ static int part_lock(struct mtd_info *mt
  static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
  {
        struct mtd_part *part = PART(mtd);
  static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
  {
        struct mtd_part *part = PART(mtd);
diff --git a/target/linux/generic/patches-3.12/480-mtd-set-rootfs-to-be-root-dev.patch b/target/linux/generic/patches-3.12/480-mtd-set-rootfs-to-be-root-dev.patch
new file mode 100644 (file)
index 0000000..7ef6778
--- /dev/null
@@ -0,0 +1,26 @@
+--- a/drivers/mtd/mtdcore.c
++++ b/drivers/mtd/mtdcore.c
+@@ -37,6 +37,7 @@
+ #include <linux/backing-dev.h>
+ #include <linux/gfp.h>
+ #include <linux/slab.h>
++#include <linux/root_dev.h>
+ #include <linux/mtd/mtd.h>
+ #include <linux/mtd/partitions.h>
+@@ -419,6 +420,15 @@ int add_mtd_device(struct mtd_info *mtd)
+          of this try_ nonsense, and no bitching about it
+          either. :) */
+       __module_get(THIS_MODULE);
++
++      if (!strcmp(mtd->name, "rootfs") &&
++          config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
++          ROOT_DEV == 0) {
++              pr_notice("mtd: device %d (%s) set to be root filesystem\n",
++                        mtd->index, mtd->name);
++              ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
++      }
++
+       return 0;
+ fail_added: