kernel: add missing config symbol for 3.13.
[openwrt.git] / target / linux / generic / patches-3.10 / 400-mtd-add-rootfs-split-support.patch
index 4cacf641d8eb1822ce5826a020410406db68f370..6c17b01e53e71754cfd02a7a1a7a703bff5e752c 100644 (file)
@@ -1,9 +1,11 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -23,6 +23,23 @@ config MTD_TESTS
-         WARNING: some of the tests will ERASE entire MTD device which they
-         test. Do not use these tests unless you really know what you do.
+@@ -12,6 +12,32 @@ menuconfig MTD
  
+ if MTD
++menu "OpenWrt specific MTD options"
++
 +config MTD_ROOTFS_ROOT_DEV
 +      bool "Automatically set 'rootfs' partition to be root filesystem"
 +      default y
 +      bool "Automatically split 'rootfs' partition for squashfs"
 +      default y
 +
-+config MTD_UIMAGE_SPLIT
-+      bool "Automatically split off rootfs from a kernel partition containing a uImage"
++config MTD_SPLIT_FIRMWARE
++      bool "Automatically split firmware partition for kernel+rootfs"
 +      default y
 +
-+config MTD_UIMAGE_SPLIT_NAME
-+      string "uImage partition name"
-+      depends on MTD_UIMAGE_SPLIT
++config MTD_SPLIT_FIRMWARE_NAME
++      string "Firmware partition name"
++      depends on MTD_SPLIT_FIRMWARE
 +      default "firmware"
 +
- config MTD_REDBOOT_PARTS
-       tristate "RedBoot partition table parsing"
-       ---help---
++config MTD_UIMAGE_SPLIT
++      bool "Enable split support for firmware partitions containing a uImage"
++      depends on MTD_SPLIT_FIRMWARE
++      default y
++
++endmenu
++
+ config MTD_TESTS
+       tristate "MTD tests support (DANGEROUS)"
+       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/root_dev.h>
 +#include <linux/magic.h>
  #include <linux/err.h>
  
  #include "mtdcore.h"
-@@ -45,12 +47,14 @@ struct mtd_part {
+@@ -45,13 +46,14 @@ struct mtd_part {
        struct list_head list;
  };
  
   * the pointer to that structure with this macro.
   */
  #define PART(x)  ((struct mtd_part *)(x))
--
-+#define IS_PART(mtd) (mtd->_read == part_read)
  
+-
  /*
   * MTD methods which simply translate the effective address and pass through
-@@ -533,8 +537,10 @@ out_register:
+  * to the _real_ device.
+@@ -533,8 +535,10 @@ out_register:
        return slave;
  }
  
@@ -64,7 +72,7 @@
  {
        struct mtd_partition part;
        struct mtd_part *p, *new;
-@@ -566,21 +572,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);
  
        return ret;
  err_inv:
-@@ -590,6 +599,12 @@ err_inv:
+@@ -590,6 +597,12 @@ err_inv:
  }
  EXPORT_SYMBOL_GPL(mtd_add_partition);
  
  int mtd_del_partition(struct mtd_info *master, int partno)
  {
        struct mtd_part *slave, *next;
-@@ -613,6 +628,149 @@ 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);
  
 +      return len;
 +}
 +
-+#ifdef CONFIG_MTD_ROOTFS_SPLIT
 +#define ROOTFS_SPLIT_NAME "rootfs_data"
-+#define ROOTFS_REMOVED_NAME "<removed>"
 +
 +struct squashfs_super_block {
 +      __le32 s_magic;
 +      __mtd_add_partition(master, ROOTFS_SPLIT_NAME, split_offset,
 +                          split_size, false);
 +}
-+#endif /* CONFIG_MTD_ROOTFS_SPLIT */
 +
-+#ifdef CONFIG_MTD_UIMAGE_SPLIT
 +#define UBOOT_MAGIC   0x27051956
 +
 +static void split_uimage(struct mtd_info *master, struct mtd_part *part)
 +      } hdr;
 +      size_t len;
 +
-+      if (strcmp(part->mtd.name, CONFIG_MTD_UIMAGE_SPLIT_NAME) != 0)
-+              return;
-+
 +      if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr))
 +              return;
 +
 +      __mtd_add_partition(master, "rootfs", part->offset + len,
 +                          part->mtd.size - len, false);
 +}
++
++#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
++#define SPLIT_FIRMWARE_NAME   CONFIG_MTD_SPLIT_FIRMWARE_NAME
++#else
++#define SPLIT_FIRMWARE_NAME   "unused"
 +#endif
 +
++static void split_firmware(struct mtd_info *master, struct mtd_part *part)
++{
++      if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
++              split_uimage(master, part);
++}
++
 +void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
 +                                int offset, int size)
 +{
 +}
 +
-+
 +static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part)
 +{
 +      static int rootfs_found = 0;
 +      if (!strcmp(part->mtd.name, "rootfs")) {
 +              rootfs_found = 1;
 +
-+#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
-+              if (ROOT_DEV == 0) {
-+                      printk(KERN_NOTICE "mtd: partition \"rootfs\" "
-+                              "set to be root filesystem\n");
-+                      ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, part->mtd.index);
-+              }
-+#endif
-+#ifdef CONFIG_MTD_ROOTFS_SPLIT
-+              split_rootfs_data(master, part);
-+#endif
++              if (config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
++                      split_rootfs_data(master, part);
 +      }
 +
-+#ifdef CONFIG_MTD_UIMAGE_SPLIT
-+      split_uimage(master, part);
-+#endif
++      if (!strcmp(part->mtd.name, SPLIT_FIRMWARE_NAME) &&
++          config_enabled(CONFIG_MTD_SPLIT_FIRMWARE))
++              split_firmware(master, part);
 +
 +      arch_split_mtd_part(master, part->mtd.name, part->offset,
 +                          part->mtd.size);
  /*
   * 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 +800,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);