kernel/3.10: add new Kconfig option for firmware partition split
[librecmc/librecmc.git] / target / linux / generic / patches-3.10 / 400-mtd-add-rootfs-split-support.patch
index edbb70411565121e3c7f77112ea64146948eb042..6a4c16134e9e8f7183d3ed8bac2f41be3c7e1f5c 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -12,6 +12,27 @@ menuconfig MTD
+@@ -12,6 +12,32 @@ menuconfig MTD
  
  if MTD
  
 +      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_UIMAGE_SPLIT
++      bool "Enable split support for firmware partitions containing a uImage"
++      depends on MTD_SPLIT_FIRMWARE
++      default y
++
 +endmenu
 +
  config MTD_TESTS
  int mtd_del_partition(struct mtd_info *master, int partno)
  {
        struct mtd_part *slave, *next;
-@@ -613,6 +627,148 @@ int mtd_del_partition(struct mtd_info *m
+@@ -613,6 +627,151 @@ int mtd_del_partition(struct mtd_info *m
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
 +
 +#define UBOOT_MAGIC   0x27051956
 +
-+#ifdef CONFIG_MTD_UIMAGE_SPLIT_NAME
-+#define UIMAGE_SPLIT_NAME     CONFIG_MTD_UIMAGE_SPLIT_NAME
-+#else
-+#define UIMAGE_SPLIT_NAME     "unused"
-+#endif
-+
 +static void split_uimage(struct mtd_info *master, struct mtd_part *part)
 +{
 +      struct {
 +      } hdr;
 +      size_t len;
 +
-+      if (strcmp(part->mtd.name, UIMAGE_SPLIT_NAME) != 0)
-+              return;
-+
 +      if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr))
 +              return;
 +
 +                          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;
 +                      split_rootfs_data(master, part);
 +      }
 +
-+      if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
-+              split_uimage(master, part);
++      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 +798,7 @@ int add_mtd_partitions(struct mtd_info *
+@@ -642,6 +801,7 @@ int add_mtd_partitions(struct mtd_info *
                mutex_unlock(&mtd_partitions_mutex);
  
                add_mtd_device(&slave->mtd);