kernel: move mtdsplit files to drivers/mtd/mtdsplit/ to simplify maintenance, unify...
authorFelix Fietkau <nbd@openwrt.org>
Fri, 2 Jan 2015 21:52:35 +0000 (21:52 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 2 Jan 2015 21:52:35 +0000 (21:52 +0000)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 43805

65 files changed:
target/linux/generic/files/drivers/mtd/mtdsplit.c [deleted file]
target/linux/generic/files/drivers/mtd/mtdsplit.h [deleted file]
target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig
target/linux/generic/files/drivers/mtd/mtdsplit/Makefile [new file with mode: 0644]
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c [new file with mode: 0644]
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h [new file with mode: 0644]
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c [new file with mode: 0644]
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c [new file with mode: 0644]
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c [new file with mode: 0644]
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c [new file with mode: 0644]
target/linux/generic/files/drivers/mtd/mtdsplit_lzma.c [deleted file]
target/linux/generic/files/drivers/mtd/mtdsplit_seama.c [deleted file]
target/linux/generic/files/drivers/mtd/mtdsplit_squashfs.c [deleted file]
target/linux/generic/files/drivers/mtd/mtdsplit_uimage.c [deleted file]
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/403-mtd-hook-mtdsplit-to-Kbuild.patch
target/linux/generic/patches-3.10/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch
target/linux/generic/patches-3.10/406-mtd-add-squashfs-parser.patch [deleted file]
target/linux/generic/patches-3.10/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch [deleted file]
target/linux/generic/patches-3.10/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch [deleted file]
target/linux/generic/patches-3.10/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch [deleted file]
target/linux/generic/patches-3.10/411-mtd-partial_eraseblock_write.patch
target/linux/generic/patches-3.10/430-mtd-add-myloader-partition-parser.patch
target/linux/generic/patches-3.10/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
target/linux/generic/patches-3.13/400-mtd-add-rootfs-split-support.patch
target/linux/generic/patches-3.13/401-mtd-add-support-for-different-partition-parser-types.patch
target/linux/generic/patches-3.13/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch
target/linux/generic/patches-3.13/403-mtd-hook-mtdsplit-to-Kbuild.patch
target/linux/generic/patches-3.13/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch
target/linux/generic/patches-3.13/406-mtd-add-squashfs-parser.patch [deleted file]
target/linux/generic/patches-3.13/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch [deleted file]
target/linux/generic/patches-3.13/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch [deleted file]
target/linux/generic/patches-3.13/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch [deleted file]
target/linux/generic/patches-3.13/411-mtd-partial_eraseblock_write.patch
target/linux/generic/patches-3.13/430-mtd-add-myloader-partition-parser.patch
target/linux/generic/patches-3.13/471-mtd-m25p80-allow-to-disable-small-sector-erase.patch
target/linux/generic/patches-3.13/502-yaffs-3.10-disable-proc-entry.patch
target/linux/generic/patches-3.14/400-mtd-add-rootfs-split-support.patch
target/linux/generic/patches-3.14/403-mtd-hook-mtdsplit-to-Kbuild.patch
target/linux/generic/patches-3.14/404-mtd-add-more-helper-functions.patch [new file with mode: 0644]
target/linux/generic/patches-3.14/405-mtd-add-more-helper-functions.patch [deleted file]
target/linux/generic/patches-3.14/405-mtd-old-firmware-uimage-splitter.patch [new file with mode: 0644]
target/linux/generic/patches-3.14/406-mtd-hook-mtdsplit-into-Kbuild.patch [deleted file]
target/linux/generic/patches-3.14/406-mtd-old-rootfs-squashfs-splitter.patch [new file with mode: 0644]
target/linux/generic/patches-3.14/407-mtd-old-firmware-uimage-splitter.patch [deleted file]
target/linux/generic/patches-3.14/408-mtd-old-rootfs-squashfs-splitter.patch [deleted file]
target/linux/generic/patches-3.14/411-mtd-partial_eraseblock_write.patch
target/linux/generic/patches-3.14/430-mtd-add-myloader-partition-parser.patch
target/linux/generic/patches-3.14/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch
target/linux/generic/patches-3.14/471-mtd-m25p80-allow-to-disable-small-sector-erase.patch
target/linux/generic/patches-3.18/400-mtd-add-rootfs-split-support.patch
target/linux/generic/patches-3.18/403-mtd-hook-mtdsplit-to-Kbuild.patch
target/linux/generic/patches-3.18/404-mtd-add-more-helper-functions.patch [new file with mode: 0644]
target/linux/generic/patches-3.18/405-mtd-add-more-helper-functions.patch [deleted file]
target/linux/generic/patches-3.18/405-mtd-old-firmware-uimage-splitter.patch [new file with mode: 0644]
target/linux/generic/patches-3.18/406-mtd-hook-mtdsplit-into-Kbuild.patch [deleted file]
target/linux/generic/patches-3.18/406-mtd-old-rootfs-squashfs-splitter.patch [new file with mode: 0644]
target/linux/generic/patches-3.18/407-mtd-old-firmware-uimage-splitter.patch [deleted file]
target/linux/generic/patches-3.18/408-mtd-old-rootfs-squashfs-splitter.patch [deleted file]
target/linux/generic/patches-3.18/411-mtd-partial_eraseblock_write.patch
target/linux/generic/patches-3.18/430-mtd-add-myloader-partition-parser.patch
target/linux/generic/patches-3.18/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch
target/linux/generic/patches-3.18/502-yaffs-3.10-disable-proc-entry.patch

diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit.c b/target/linux/generic/files/drivers/mtd/mtdsplit.c
deleted file mode 100644 (file)
index 162739f..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2009-2013 Felix Fietkau <nbd@openwrt.org>
- * Copyright (C) 2009-2013 Gabor Juhos <juhosg@openwrt.org>
- * Copyright (C) 2012 Jonas Gorski <jogo@openwrt.org>
- * Copyright (C) 2013 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- */
-
-#define pr_fmt(fmt)    "mtdsplit: " fmt
-
-#include <linux/export.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/magic.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
-#include <linux/byteorder/generic.h>
-
-#include "mtdsplit.h"
-
-struct squashfs_super_block {
-       __le32 s_magic;
-       __le32 pad0[9];
-       __le64 bytes_used;
-};
-
-int mtd_get_squashfs_len(struct mtd_info *master,
-                        size_t offset,
-                        size_t *squashfs_len)
-{
-       struct squashfs_super_block sb;
-       size_t retlen;
-       int err;
-
-       err = mtd_read(master, offset, sizeof(sb), &retlen, (void *)&sb);
-       if (err || (retlen != sizeof(sb))) {
-               pr_alert("error occured while reading from \"%s\"\n",
-                        master->name);
-               return -EIO;
-       }
-
-       if (le32_to_cpu(sb.s_magic) != SQUASHFS_MAGIC) {
-               pr_alert("no squashfs found in \"%s\"\n", master->name);
-               return -EINVAL;
-       }
-
-       retlen = le64_to_cpu(sb.bytes_used);
-       if (retlen <= 0) {
-               pr_alert("squashfs is empty in \"%s\"\n", master->name);
-               return -ENODEV;
-       }
-
-       if (offset + retlen > master->size) {
-               pr_alert("squashfs has invalid size in \"%s\"\n",
-                        master->name);
-               return -EINVAL;
-       }
-
-       *squashfs_len = retlen;
-       return 0;
-}
-EXPORT_SYMBOL_GPL(mtd_get_squashfs_len);
-
-static ssize_t mtd_next_eb(struct mtd_info *mtd, size_t offset)
-{
-       return mtd_rounddown_to_eb(offset, mtd) + mtd->erasesize;
-}
-
-int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
-{
-       u32 magic;
-       size_t retlen;
-       int ret;
-
-       ret = mtd_read(mtd, offset, sizeof(magic), &retlen,
-                      (unsigned char *) &magic);
-       if (ret)
-               return ret;
-
-       if (retlen != sizeof(magic))
-               return -EIO;
-
-       if (le32_to_cpu(magic) != SQUASHFS_MAGIC &&
-           magic != 0x19852003)
-               return -EINVAL;
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(mtd_check_rootfs_magic);
-
-int mtd_find_rootfs_from(struct mtd_info *mtd,
-                        size_t from,
-                        size_t limit,
-                        size_t *ret_offset)
-{
-       size_t offset;
-       int err;
-
-       for (offset = from; offset < limit;
-            offset = mtd_next_eb(mtd, offset)) {
-               err = mtd_check_rootfs_magic(mtd, offset);
-               if (err)
-                       continue;
-
-               *ret_offset = offset;
-               return 0;
-       }
-
-       return -ENODEV;
-}
-EXPORT_SYMBOL_GPL(mtd_find_rootfs_from);
-
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit.h b/target/linux/generic/files/drivers/mtd/mtdsplit.h
deleted file mode 100644 (file)
index 7ee88b0..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2009-2013 Felix Fietkau <nbd@openwrt.org>
- * Copyright (C) 2009-2013 Gabor Juhos <juhosg@openwrt.org>
- * Copyright (C) 2012 Jonas Gorski <jogo@openwrt.org>
- * Copyright (C) 2013 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- */
-
-#ifndef _MTDSPLIT_H
-#define _MTDSPLIT_H
-
-#define KERNEL_PART_NAME       "kernel"
-#define ROOTFS_PART_NAME       "rootfs"
-
-#define ROOTFS_SPLIT_NAME      "rootfs_data"
-
-#ifdef CONFIG_MTD_SPLIT
-int mtd_get_squashfs_len(struct mtd_info *master,
-                        size_t offset,
-                        size_t *squashfs_len);
-
-int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset);
-
-int mtd_find_rootfs_from(struct mtd_info *mtd,
-                        size_t from,
-                        size_t limit,
-                        size_t *ret_offset);
-
-#else
-static inline int mtd_get_squashfs_len(struct mtd_info *master,
-                                      size_t offset,
-                                      size_t *squashfs_len)
-{
-       return -ENODEV;
-}
-
-static inline int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
-{
-       return -EINVAL;
-}
-
-static inline int mtd_find_rootfs_from(struct mtd_info *mtd,
-                                      size_t from,
-                                      size_t limit,
-                                      size_t *ret_offset)
-{
-       return -ENODEV;
-}
-#endif /* CONFIG_MTD_SPLIT */
-
-#endif /* _MTDSPLIT_H */
index 09794f4f844e5cca9e0800974e872a5e0ad613bc..9a32daadc850f41012e60ddce336a5fdac614d02 100644 (file)
@@ -1,7 +1,16 @@
+config MTD_SPLIT
+       def_bool n
+       help
+         Generic MTD split support.
+
+config MTD_SPLIT_SUPPORT
+       def_bool MTD = y
+
 comment "Rootfs partition parsers"
 
 config MTD_SPLIT_SQUASHFS_ROOT
        bool "Squashfs based root partition parser"
+       depends on MTD_SPLIT_SUPPORT
        select MTD_SPLIT
        default n
        help
@@ -13,12 +22,15 @@ comment "Firmware partition parsers"
 
 config MTD_SPLIT_SEAMA_FW
        bool "Seama firmware parser"
+       depends on MTD_SPLIT_SUPPORT
        select MTD_SPLIT
 
 config MTD_SPLIT_UIMAGE_FW
        bool "uImage based firmware partition parser"
+       depends on MTD_SPLIT_SUPPORT
        select MTD_SPLIT
 
 config MTD_SPLIT_LZMA_FW
        bool "LZMA compressed kernel based firmware partition parser"
+       depends on MTD_SPLIT_SUPPORT
        select MTD_SPLIT
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile b/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile
new file mode 100644 (file)
index 0000000..41bc1de
--- /dev/null
@@ -0,0 +1,5 @@
+obj-$(CONFIG_MTD_SPLIT)                += mtdsplit.o
+obj-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o
+obj-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
+obj-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o
+obj-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c
new file mode 100644 (file)
index 0000000..162739f
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2009-2013 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2009-2013 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2012 Jonas Gorski <jogo@openwrt.org>
+ * Copyright (C) 2013 Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+
+#define pr_fmt(fmt)    "mtdsplit: " fmt
+
+#include <linux/export.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/magic.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/byteorder/generic.h>
+
+#include "mtdsplit.h"
+
+struct squashfs_super_block {
+       __le32 s_magic;
+       __le32 pad0[9];
+       __le64 bytes_used;
+};
+
+int mtd_get_squashfs_len(struct mtd_info *master,
+                        size_t offset,
+                        size_t *squashfs_len)
+{
+       struct squashfs_super_block sb;
+       size_t retlen;
+       int err;
+
+       err = mtd_read(master, offset, sizeof(sb), &retlen, (void *)&sb);
+       if (err || (retlen != sizeof(sb))) {
+               pr_alert("error occured while reading from \"%s\"\n",
+                        master->name);
+               return -EIO;
+       }
+
+       if (le32_to_cpu(sb.s_magic) != SQUASHFS_MAGIC) {
+               pr_alert("no squashfs found in \"%s\"\n", master->name);
+               return -EINVAL;
+       }
+
+       retlen = le64_to_cpu(sb.bytes_used);
+       if (retlen <= 0) {
+               pr_alert("squashfs is empty in \"%s\"\n", master->name);
+               return -ENODEV;
+       }
+
+       if (offset + retlen > master->size) {
+               pr_alert("squashfs has invalid size in \"%s\"\n",
+                        master->name);
+               return -EINVAL;
+       }
+
+       *squashfs_len = retlen;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mtd_get_squashfs_len);
+
+static ssize_t mtd_next_eb(struct mtd_info *mtd, size_t offset)
+{
+       return mtd_rounddown_to_eb(offset, mtd) + mtd->erasesize;
+}
+
+int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
+{
+       u32 magic;
+       size_t retlen;
+       int ret;
+
+       ret = mtd_read(mtd, offset, sizeof(magic), &retlen,
+                      (unsigned char *) &magic);
+       if (ret)
+               return ret;
+
+       if (retlen != sizeof(magic))
+               return -EIO;
+
+       if (le32_to_cpu(magic) != SQUASHFS_MAGIC &&
+           magic != 0x19852003)
+               return -EINVAL;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mtd_check_rootfs_magic);
+
+int mtd_find_rootfs_from(struct mtd_info *mtd,
+                        size_t from,
+                        size_t limit,
+                        size_t *ret_offset)
+{
+       size_t offset;
+       int err;
+
+       for (offset = from; offset < limit;
+            offset = mtd_next_eb(mtd, offset)) {
+               err = mtd_check_rootfs_magic(mtd, offset);
+               if (err)
+                       continue;
+
+               *ret_offset = offset;
+               return 0;
+       }
+
+       return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(mtd_find_rootfs_from);
+
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h
new file mode 100644 (file)
index 0000000..7ee88b0
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009-2013 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2009-2013 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2012 Jonas Gorski <jogo@openwrt.org>
+ * Copyright (C) 2013 Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+
+#ifndef _MTDSPLIT_H
+#define _MTDSPLIT_H
+
+#define KERNEL_PART_NAME       "kernel"
+#define ROOTFS_PART_NAME       "rootfs"
+
+#define ROOTFS_SPLIT_NAME      "rootfs_data"
+
+#ifdef CONFIG_MTD_SPLIT
+int mtd_get_squashfs_len(struct mtd_info *master,
+                        size_t offset,
+                        size_t *squashfs_len);
+
+int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset);
+
+int mtd_find_rootfs_from(struct mtd_info *mtd,
+                        size_t from,
+                        size_t limit,
+                        size_t *ret_offset);
+
+#else
+static inline int mtd_get_squashfs_len(struct mtd_info *master,
+                                      size_t offset,
+                                      size_t *squashfs_len)
+{
+       return -ENODEV;
+}
+
+static inline int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
+{
+       return -EINVAL;
+}
+
+static inline int mtd_find_rootfs_from(struct mtd_info *mtd,
+                                      size_t from,
+                                      size_t limit,
+                                      size_t *ret_offset)
+{
+       return -ENODEV;
+}
+#endif /* CONFIG_MTD_SPLIT */
+
+#endif /* _MTDSPLIT_H */
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c
new file mode 100644 (file)
index 0000000..64dc7cb
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ *  Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/unaligned.h>
+
+#include "mtdsplit.h"
+
+#define LZMA_NR_PARTS          2
+#define LZMA_PROPERTIES_SIZE   5
+
+struct lzma_header {
+       u8 props[LZMA_PROPERTIES_SIZE];
+       u8 size_low[4];
+       u8 size_high[4];
+};
+
+static int mtdsplit_parse_lzma(struct mtd_info *master,
+                              struct mtd_partition **pparts,
+                              struct mtd_part_parser_data *data)
+{
+       struct lzma_header hdr;
+       size_t hdr_len, retlen;
+       size_t rootfs_offset;
+       u32 t;
+       struct mtd_partition *parts;
+       int err;
+
+       hdr_len = sizeof(hdr);
+       err = mtd_read(master, 0, hdr_len, &retlen, (void *) &hdr);
+       if (err)
+               return err;
+
+       if (retlen != hdr_len)
+               return -EIO;
+
+       /* verify LZMA properties */
+       if (hdr.props[0] >= (9 * 5 * 5))
+               return -EINVAL;
+
+       t = get_unaligned_le32(&hdr.props[1]);
+       if (!is_power_of_2(t))
+               return -EINVAL;
+
+       t = get_unaligned_le32(&hdr.size_high);
+       if (t)
+               return -EINVAL;
+
+       err = mtd_find_rootfs_from(master, master->erasesize,
+                                  master->size, &rootfs_offset);
+       if (err)
+               return err;
+
+       parts = kzalloc(LZMA_NR_PARTS * sizeof(*parts), GFP_KERNEL);
+       if (!parts)
+               return -ENOMEM;
+
+       parts[0].name = KERNEL_PART_NAME;
+       parts[0].offset = 0;
+       parts[0].size = rootfs_offset;
+
+       parts[1].name = ROOTFS_PART_NAME;
+       parts[1].offset = rootfs_offset;
+       parts[1].size = master->size - rootfs_offset;
+
+       *pparts = parts;
+       return LZMA_NR_PARTS;
+}
+
+static struct mtd_part_parser mtdsplit_lzma_parser = {
+       .owner = THIS_MODULE,
+       .name = "lzma-fw",
+       .parse_fn = mtdsplit_parse_lzma,
+       .type = MTD_PARSER_TYPE_FIRMWARE,
+};
+
+static int __init mtdsplit_lzma_init(void)
+{
+       register_mtd_parser(&mtdsplit_lzma_parser);
+
+       return 0;
+}
+
+subsys_initcall(mtdsplit_lzma_init);
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c
new file mode 100644 (file)
index 0000000..6f21f8f
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ *  Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/byteorder/generic.h>
+
+#include "mtdsplit.h"
+
+#define SEAMA_MAGIC            0x5EA3A417
+#define SEAMA_NR_PARTS         2
+#define SEAMA_MIN_ROOTFS_OFFS  0x80000 /* 512KiB */
+
+struct seama_header {
+       __be32  magic;          /* should always be SEAMA_MAGIC. */
+       __be16  reserved;       /* reserved for  */
+       __be16  metasize;       /* size of the META data */
+       __be32  size;           /* size of the image */
+};
+
+static int mtdsplit_parse_seama(struct mtd_info *master,
+                               struct mtd_partition **pparts,
+                               struct mtd_part_parser_data *data)
+{
+       struct seama_header hdr;
+       size_t hdr_len, retlen, kernel_size;
+       size_t rootfs_offset;
+       struct mtd_partition *parts;
+       int err;
+
+       hdr_len = sizeof(hdr);
+       err = mtd_read(master, 0, hdr_len, &retlen, (void *) &hdr);
+       if (err)
+               return err;
+
+       if (retlen != hdr_len)
+               return -EIO;
+
+       /* sanity checks */
+       if (be32_to_cpu(hdr.magic) != SEAMA_MAGIC)
+               return -EINVAL;
+
+       kernel_size = hdr_len + be32_to_cpu(hdr.size) +
+                     be16_to_cpu(hdr.metasize);
+       if (kernel_size > master->size)
+               return -EINVAL;
+
+       /* Find the rootfs after the kernel. */
+       err = mtd_check_rootfs_magic(master, kernel_size);
+       if (!err) {
+               rootfs_offset = kernel_size;
+       } else {
+               /*
+                * The size in the header might cover the rootfs as well.
+                * Start the search from an arbitrary offset.
+                */
+               err = mtd_find_rootfs_from(master, SEAMA_MIN_ROOTFS_OFFS,
+                                          master->size, &rootfs_offset);
+               if (err)
+                       return err;
+       }
+
+       parts = kzalloc(SEAMA_NR_PARTS * sizeof(*parts), GFP_KERNEL);
+       if (!parts)
+               return -ENOMEM;
+
+       parts[0].name = KERNEL_PART_NAME;
+       parts[0].offset = 0;
+       parts[0].size = rootfs_offset;
+
+       parts[1].name = ROOTFS_PART_NAME;
+       parts[1].offset = rootfs_offset;
+       parts[1].size = master->size - rootfs_offset;
+
+       *pparts = parts;
+       return SEAMA_NR_PARTS;
+}
+
+static struct mtd_part_parser mtdsplit_seama_parser = {
+       .owner = THIS_MODULE,
+       .name = "seama-fw",
+       .parse_fn = mtdsplit_parse_seama,
+       .type = MTD_PARSER_TYPE_FIRMWARE,
+};
+
+static int __init mtdsplit_seama_init(void)
+{
+       register_mtd_parser(&mtdsplit_seama_parser);
+
+       return 0;
+}
+
+subsys_initcall(mtdsplit_seama_init);
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c
new file mode 100644 (file)
index 0000000..3d80e07
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ *  Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
+ *  Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#define pr_fmt(fmt)    KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/magic.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/byteorder/generic.h>
+
+#include "mtdsplit.h"
+
+static int
+mtdsplit_parse_squashfs(struct mtd_info *master,
+                       struct mtd_partition **pparts,
+                       struct mtd_part_parser_data *data)
+{
+       struct mtd_partition *part;
+       struct mtd_info *parent_mtd;
+       size_t part_offset;
+       size_t squashfs_len;
+       int err;
+
+       err = mtd_get_squashfs_len(master, 0, &squashfs_len);
+       if (err)
+               return err;
+
+       parent_mtd = mtdpart_get_master(master);
+       part_offset = mtdpart_get_offset(master);
+
+       part = kzalloc(sizeof(*part), GFP_KERNEL);
+       if (!part) {
+               pr_alert("unable to allocate memory for \"%s\" partition\n",
+                        ROOTFS_SPLIT_NAME);
+               return -ENOMEM;
+       }
+
+       part->name = ROOTFS_SPLIT_NAME;
+       part->offset = mtd_roundup_to_eb(part_offset + squashfs_len,
+                                        parent_mtd) - part_offset;
+       part->size = master->size - part->offset;
+
+       *pparts = part;
+       return 1;
+}
+
+static struct mtd_part_parser mtdsplit_squashfs_parser = {
+       .owner = THIS_MODULE,
+       .name = "squashfs-split",
+       .parse_fn = mtdsplit_parse_squashfs,
+       .type = MTD_PARSER_TYPE_ROOTFS,
+};
+
+static int __init mtdsplit_squashfs_init(void)
+{
+       register_mtd_parser(&mtdsplit_squashfs_parser);
+
+       return 0;
+}
+
+subsys_initcall(mtdsplit_squashfs_init);
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
new file mode 100644 (file)
index 0000000..7dad63c
--- /dev/null
@@ -0,0 +1,287 @@
+/*
+ *  Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#define pr_fmt(fmt)    KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/byteorder/generic.h>
+
+#include "mtdsplit.h"
+
+#define IH_MAGIC       0x27051956      /* Image Magic Number           */
+#define IH_NMLEN               32      /* Image Name Length            */
+
+#define IH_OS_LINUX            5       /* Linux        */
+
+#define IH_TYPE_KERNEL         2       /* OS Kernel Image              */
+#define IH_TYPE_FILESYSTEM     7       /* Filesystem Image             */
+
+/*
+ * Legacy format image header,
+ * all data in network byte order (aka natural aka bigendian).
+ */
+struct uimage_header {
+       uint32_t        ih_magic;       /* Image Header Magic Number    */
+       uint32_t        ih_hcrc;        /* Image Header CRC Checksum    */
+       uint32_t        ih_time;        /* Image Creation Timestamp     */
+       uint32_t        ih_size;        /* Image Data Size              */
+       uint32_t        ih_load;        /* Data  Load  Address          */
+       uint32_t        ih_ep;          /* Entry Point Address          */
+       uint32_t        ih_dcrc;        /* Image Data CRC Checksum      */
+       uint8_t         ih_os;          /* Operating System             */
+       uint8_t         ih_arch;        /* CPU architecture             */
+       uint8_t         ih_type;        /* Image Type                   */
+       uint8_t         ih_comp;        /* Compression Type             */
+       uint8_t         ih_name[IH_NMLEN];      /* Image Name           */
+};
+
+static int
+read_uimage_header(struct mtd_info *mtd, size_t offset,
+                  struct uimage_header *header)
+{
+       size_t header_len;
+       size_t retlen;
+       int ret;
+
+       header_len = sizeof(*header);
+       ret = mtd_read(mtd, offset, header_len, &retlen,
+                      (unsigned char *) header);
+       if (ret) {
+               pr_debug("read error in \"%s\"\n", mtd->name);
+               return ret;
+       }
+
+       if (retlen != header_len) {
+               pr_debug("short read in \"%s\"\n", mtd->name);
+               return -EIO;
+       }
+
+       return 0;
+}
+
+static int __mtdsplit_parse_uimage(struct mtd_info *master,
+                                  struct mtd_partition **pparts,
+                                  struct mtd_part_parser_data *data,
+                                  bool (*verify)(struct uimage_header *hdr))
+{
+       struct mtd_partition *parts;
+       struct uimage_header *header;
+       int nr_parts;
+       size_t offset;
+       size_t uimage_offset;
+       size_t uimage_size = 0;
+       size_t rootfs_offset;
+       size_t rootfs_size = 0;
+       int uimage_part, rf_part;
+       int ret;
+
+       nr_parts = 2;
+       parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL);
+       if (!parts)
+               return -ENOMEM;
+
+       header = vmalloc(sizeof(*header));
+       if (!header) {
+               ret = -ENOMEM;
+               goto err_free_parts;
+       }
+
+       /* find uImage on erase block boundaries */
+       for (offset = 0; offset < master->size; offset += master->erasesize) {
+               uimage_size = 0;
+
+               ret = read_uimage_header(master, offset, header);
+               if (ret)
+                       continue;
+
+               if (!verify(header)) {
+                       pr_debug("no valid uImage found in \"%s\" at offset %llx\n",
+                                master->name, (unsigned long long) offset);
+                       continue;
+               }
+
+               uimage_size = sizeof(*header) + be32_to_cpu(header->ih_size);
+               if ((offset + uimage_size) > master->size) {
+                       pr_debug("uImage exceeds MTD device \"%s\"\n",
+                                master->name);
+                       continue;
+               }
+               break;
+       }
+
+       if (uimage_size == 0) {
+               pr_debug("no uImage found in \"%s\"\n", master->name);
+               ret = -ENODEV;
+               goto err_free_header;
+       }
+
+       uimage_offset = offset;
+
+       if (uimage_offset == 0) {
+               uimage_part = 0;
+               rf_part = 1;
+
+               /* find the roots after the uImage */
+               ret = mtd_find_rootfs_from(master,
+                                          uimage_offset + uimage_size,
+                                          master->size,
+                                          &rootfs_offset);
+               if (ret) {
+                       pr_debug("no rootfs after uImage in \"%s\"\n",
+                                master->name);
+                       goto err_free_header;
+               }
+
+               rootfs_size = master->size - rootfs_offset;
+               uimage_size = rootfs_offset - uimage_offset;
+       } else {
+               rf_part = 0;
+               uimage_part = 1;
+
+               /* check rootfs presence at offset 0 */
+               ret = mtd_check_rootfs_magic(master, 0);
+               if (ret) {
+                       pr_debug("no rootfs before uImage in \"%s\"\n",
+                                master->name);
+                       goto err_free_header;
+               }
+
+               rootfs_offset = 0;
+               rootfs_size = uimage_offset;
+       }
+
+       if (rootfs_size == 0) {
+               pr_debug("no rootfs found in \"%s\"\n", master->name);
+               ret = -ENODEV;
+               goto err_free_header;
+       }
+
+       parts[uimage_part].name = KERNEL_PART_NAME;
+       parts[uimage_part].offset = uimage_offset;
+       parts[uimage_part].size = uimage_size;
+
+       parts[rf_part].name = ROOTFS_PART_NAME;
+       parts[rf_part].offset = rootfs_offset;
+       parts[rf_part].size = rootfs_size;
+
+       vfree(header);
+
+       *pparts = parts;
+       return nr_parts;
+
+err_free_header:
+       vfree(header);
+
+err_free_parts:
+       kfree(parts);
+       return ret;
+}
+
+static bool uimage_verify_default(struct uimage_header *header)
+{
+       /* default sanity checks */
+       if (be32_to_cpu(header->ih_magic) != IH_MAGIC) {
+               pr_debug("invalid uImage magic: %08x\n",
+                        be32_to_cpu(header->ih_magic));
+               return false;
+       }
+
+       if (header->ih_os != IH_OS_LINUX) {
+               pr_debug("invalid uImage OS: %08x\n",
+                        be32_to_cpu(header->ih_os));
+               return false;
+       }
+
+       if (header->ih_type != IH_TYPE_KERNEL) {
+               pr_debug("invalid uImage type: %08x\n",
+                        be32_to_cpu(header->ih_type));
+               return false;
+       }
+
+       return true;
+}
+
+static int
+mtdsplit_uimage_parse_generic(struct mtd_info *master,
+                             struct mtd_partition **pparts,
+                             struct mtd_part_parser_data *data)
+{
+       return __mtdsplit_parse_uimage(master, pparts, data,
+                                     uimage_verify_default);
+}
+
+static struct mtd_part_parser uimage_generic_parser = {
+       .owner = THIS_MODULE,
+       .name = "uimage-fw",
+       .parse_fn = mtdsplit_uimage_parse_generic,
+       .type = MTD_PARSER_TYPE_FIRMWARE,
+};
+
+#define FW_MAGIC_WNR2000V3     0x32303033
+#define FW_MAGIC_WNR2000V4     0x32303034
+#define FW_MAGIC_WNR2200       0x32323030
+#define FW_MAGIC_WNR612V2      0x32303631
+#define FW_MAGIC_WNDR3700      0x33373030
+#define FW_MAGIC_WNDR3700V2    0x33373031
+
+static bool uimage_verify_wndr3700(struct uimage_header *header)
+{
+       uint8_t expected_type = IH_TYPE_FILESYSTEM;
+       switch be32_to_cpu(header->ih_magic) {
+       case FW_MAGIC_WNR612V2:
+       case FW_MAGIC_WNR2000V3:
+       case FW_MAGIC_WNR2200:
+       case FW_MAGIC_WNDR3700:
+       case FW_MAGIC_WNDR3700V2:
+               break;
+       case FW_MAGIC_WNR2000V4:
+               expected_type = IH_TYPE_KERNEL;
+               break;
+       default:
+               return false;
+       }
+
+       if (header->ih_os != IH_OS_LINUX ||
+           header->ih_type != expected_type)
+               return false;
+
+       return true;
+}
+
+static int
+mtdsplit_uimage_parse_netgear(struct mtd_info *master,
+                             struct mtd_partition **pparts,
+                             struct mtd_part_parser_data *data)
+{
+       return __mtdsplit_parse_uimage(master, pparts, data,
+                                     uimage_verify_wndr3700);
+}
+
+static struct mtd_part_parser uimage_netgear_parser = {
+       .owner = THIS_MODULE,
+       .name = "netgear-fw",
+       .parse_fn = mtdsplit_uimage_parse_netgear,
+       .type = MTD_PARSER_TYPE_FIRMWARE,
+};
+
+static int __init mtdsplit_uimage_init(void)
+{
+       register_mtd_parser(&uimage_generic_parser);
+       register_mtd_parser(&uimage_netgear_parser);
+
+       return 0;
+}
+
+module_init(mtdsplit_uimage_init);
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit_lzma.c b/target/linux/generic/files/drivers/mtd/mtdsplit_lzma.c
deleted file mode 100644 (file)
index 64dc7cb..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *  Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License version 2 as published
- *  by the Free Software Foundation.
- *
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
-
-#include <asm/unaligned.h>
-
-#include "mtdsplit.h"
-
-#define LZMA_NR_PARTS          2
-#define LZMA_PROPERTIES_SIZE   5
-
-struct lzma_header {
-       u8 props[LZMA_PROPERTIES_SIZE];
-       u8 size_low[4];
-       u8 size_high[4];
-};
-
-static int mtdsplit_parse_lzma(struct mtd_info *master,
-                              struct mtd_partition **pparts,
-                              struct mtd_part_parser_data *data)
-{
-       struct lzma_header hdr;
-       size_t hdr_len, retlen;
-       size_t rootfs_offset;
-       u32 t;
-       struct mtd_partition *parts;
-       int err;
-
-       hdr_len = sizeof(hdr);
-       err = mtd_read(master, 0, hdr_len, &retlen, (void *) &hdr);
-       if (err)
-               return err;
-
-       if (retlen != hdr_len)
-               return -EIO;
-
-       /* verify LZMA properties */
-       if (hdr.props[0] >= (9 * 5 * 5))
-               return -EINVAL;
-
-       t = get_unaligned_le32(&hdr.props[1]);
-       if (!is_power_of_2(t))
-               return -EINVAL;
-
-       t = get_unaligned_le32(&hdr.size_high);
-       if (t)
-               return -EINVAL;
-
-       err = mtd_find_rootfs_from(master, master->erasesize,
-                                  master->size, &rootfs_offset);
-       if (err)
-               return err;
-
-       parts = kzalloc(LZMA_NR_PARTS * sizeof(*parts), GFP_KERNEL);
-       if (!parts)
-               return -ENOMEM;
-
-       parts[0].name = KERNEL_PART_NAME;
-       parts[0].offset = 0;
-       parts[0].size = rootfs_offset;
-
-       parts[1].name = ROOTFS_PART_NAME;
-       parts[1].offset = rootfs_offset;
-       parts[1].size = master->size - rootfs_offset;
-
-       *pparts = parts;
-       return LZMA_NR_PARTS;
-}
-
-static struct mtd_part_parser mtdsplit_lzma_parser = {
-       .owner = THIS_MODULE,
-       .name = "lzma-fw",
-       .parse_fn = mtdsplit_parse_lzma,
-       .type = MTD_PARSER_TYPE_FIRMWARE,
-};
-
-static int __init mtdsplit_lzma_init(void)
-{
-       register_mtd_parser(&mtdsplit_lzma_parser);
-
-       return 0;
-}
-
-subsys_initcall(mtdsplit_lzma_init);
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit_seama.c b/target/linux/generic/files/drivers/mtd/mtdsplit_seama.c
deleted file mode 100644 (file)
index 6f21f8f..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- *  Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License version 2 as published
- *  by the Free Software Foundation.
- *
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
-#include <linux/byteorder/generic.h>
-
-#include "mtdsplit.h"
-
-#define SEAMA_MAGIC            0x5EA3A417
-#define SEAMA_NR_PARTS         2
-#define SEAMA_MIN_ROOTFS_OFFS  0x80000 /* 512KiB */
-
-struct seama_header {
-       __be32  magic;          /* should always be SEAMA_MAGIC. */
-       __be16  reserved;       /* reserved for  */
-       __be16  metasize;       /* size of the META data */
-       __be32  size;           /* size of the image */
-};
-
-static int mtdsplit_parse_seama(struct mtd_info *master,
-                               struct mtd_partition **pparts,
-                               struct mtd_part_parser_data *data)
-{
-       struct seama_header hdr;
-       size_t hdr_len, retlen, kernel_size;
-       size_t rootfs_offset;
-       struct mtd_partition *parts;
-       int err;
-
-       hdr_len = sizeof(hdr);
-       err = mtd_read(master, 0, hdr_len, &retlen, (void *) &hdr);
-       if (err)
-               return err;
-
-       if (retlen != hdr_len)
-               return -EIO;
-
-       /* sanity checks */
-       if (be32_to_cpu(hdr.magic) != SEAMA_MAGIC)
-               return -EINVAL;
-
-       kernel_size = hdr_len + be32_to_cpu(hdr.size) +
-                     be16_to_cpu(hdr.metasize);
-       if (kernel_size > master->size)
-               return -EINVAL;
-
-       /* Find the rootfs after the kernel. */
-       err = mtd_check_rootfs_magic(master, kernel_size);
-       if (!err) {
-               rootfs_offset = kernel_size;
-       } else {
-               /*
-                * The size in the header might cover the rootfs as well.
-                * Start the search from an arbitrary offset.
-                */
-               err = mtd_find_rootfs_from(master, SEAMA_MIN_ROOTFS_OFFS,
-                                          master->size, &rootfs_offset);
-               if (err)
-                       return err;
-       }
-
-       parts = kzalloc(SEAMA_NR_PARTS * sizeof(*parts), GFP_KERNEL);
-       if (!parts)
-               return -ENOMEM;
-
-       parts[0].name = KERNEL_PART_NAME;
-       parts[0].offset = 0;
-       parts[0].size = rootfs_offset;
-
-       parts[1].name = ROOTFS_PART_NAME;
-       parts[1].offset = rootfs_offset;
-       parts[1].size = master->size - rootfs_offset;
-
-       *pparts = parts;
-       return SEAMA_NR_PARTS;
-}
-
-static struct mtd_part_parser mtdsplit_seama_parser = {
-       .owner = THIS_MODULE,
-       .name = "seama-fw",
-       .parse_fn = mtdsplit_parse_seama,
-       .type = MTD_PARSER_TYPE_FIRMWARE,
-};
-
-static int __init mtdsplit_seama_init(void)
-{
-       register_mtd_parser(&mtdsplit_seama_parser);
-
-       return 0;
-}
-
-subsys_initcall(mtdsplit_seama_init);
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit_squashfs.c b/target/linux/generic/files/drivers/mtd/mtdsplit_squashfs.c
deleted file mode 100644 (file)
index 3d80e07..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *  Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
- *  Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License version 2 as published
- *  by the Free Software Foundation.
- *
- */
-
-#define pr_fmt(fmt)    KBUILD_MODNAME ": " fmt
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/magic.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
-#include <linux/byteorder/generic.h>
-
-#include "mtdsplit.h"
-
-static int
-mtdsplit_parse_squashfs(struct mtd_info *master,
-                       struct mtd_partition **pparts,
-                       struct mtd_part_parser_data *data)
-{
-       struct mtd_partition *part;
-       struct mtd_info *parent_mtd;
-       size_t part_offset;
-       size_t squashfs_len;
-       int err;
-
-       err = mtd_get_squashfs_len(master, 0, &squashfs_len);
-       if (err)
-               return err;
-
-       parent_mtd = mtdpart_get_master(master);
-       part_offset = mtdpart_get_offset(master);
-
-       part = kzalloc(sizeof(*part), GFP_KERNEL);
-       if (!part) {
-               pr_alert("unable to allocate memory for \"%s\" partition\n",
-                        ROOTFS_SPLIT_NAME);
-               return -ENOMEM;
-       }
-
-       part->name = ROOTFS_SPLIT_NAME;
-       part->offset = mtd_roundup_to_eb(part_offset + squashfs_len,
-                                        parent_mtd) - part_offset;
-       part->size = master->size - part->offset;
-
-       *pparts = part;
-       return 1;
-}
-
-static struct mtd_part_parser mtdsplit_squashfs_parser = {
-       .owner = THIS_MODULE,
-       .name = "squashfs-split",
-       .parse_fn = mtdsplit_parse_squashfs,
-       .type = MTD_PARSER_TYPE_ROOTFS,
-};
-
-static int __init mtdsplit_squashfs_init(void)
-{
-       register_mtd_parser(&mtdsplit_squashfs_parser);
-
-       return 0;
-}
-
-subsys_initcall(mtdsplit_squashfs_init);
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit_uimage.c
deleted file mode 100644 (file)
index 7dad63c..0000000
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- *  Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License version 2 as published
- *  by the Free Software Foundation.
- *
- */
-
-#define pr_fmt(fmt)    KBUILD_MODNAME ": " fmt
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
-#include <linux/byteorder/generic.h>
-
-#include "mtdsplit.h"
-
-#define IH_MAGIC       0x27051956      /* Image Magic Number           */
-#define IH_NMLEN               32      /* Image Name Length            */
-
-#define IH_OS_LINUX            5       /* Linux        */
-
-#define IH_TYPE_KERNEL         2       /* OS Kernel Image              */
-#define IH_TYPE_FILESYSTEM     7       /* Filesystem Image             */
-
-/*
- * Legacy format image header,
- * all data in network byte order (aka natural aka bigendian).
- */
-struct uimage_header {
-       uint32_t        ih_magic;       /* Image Header Magic Number    */
-       uint32_t        ih_hcrc;        /* Image Header CRC Checksum    */
-       uint32_t        ih_time;        /* Image Creation Timestamp     */
-       uint32_t        ih_size;        /* Image Data Size              */
-       uint32_t        ih_load;        /* Data  Load  Address          */
-       uint32_t        ih_ep;          /* Entry Point Address          */
-       uint32_t        ih_dcrc;        /* Image Data CRC Checksum      */
-       uint8_t         ih_os;          /* Operating System             */
-       uint8_t         ih_arch;        /* CPU architecture             */
-       uint8_t         ih_type;        /* Image Type                   */
-       uint8_t         ih_comp;        /* Compression Type             */
-       uint8_t         ih_name[IH_NMLEN];      /* Image Name           */
-};
-
-static int
-read_uimage_header(struct mtd_info *mtd, size_t offset,
-                  struct uimage_header *header)
-{
-       size_t header_len;
-       size_t retlen;
-       int ret;
-
-       header_len = sizeof(*header);
-       ret = mtd_read(mtd, offset, header_len, &retlen,
-                      (unsigned char *) header);
-       if (ret) {
-               pr_debug("read error in \"%s\"\n", mtd->name);
-               return ret;
-       }
-
-       if (retlen != header_len) {
-               pr_debug("short read in \"%s\"\n", mtd->name);
-               return -EIO;
-       }
-
-       return 0;
-}
-
-static int __mtdsplit_parse_uimage(struct mtd_info *master,
-                                  struct mtd_partition **pparts,
-                                  struct mtd_part_parser_data *data,
-                                  bool (*verify)(struct uimage_header *hdr))
-{
-       struct mtd_partition *parts;
-       struct uimage_header *header;
-       int nr_parts;
-       size_t offset;
-       size_t uimage_offset;
-       size_t uimage_size = 0;
-       size_t rootfs_offset;
-       size_t rootfs_size = 0;
-       int uimage_part, rf_part;
-       int ret;
-
-       nr_parts = 2;
-       parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL);
-       if (!parts)
-               return -ENOMEM;
-
-       header = vmalloc(sizeof(*header));
-       if (!header) {
-               ret = -ENOMEM;
-               goto err_free_parts;
-       }
-
-       /* find uImage on erase block boundaries */
-       for (offset = 0; offset < master->size; offset += master->erasesize) {
-               uimage_size = 0;
-
-               ret = read_uimage_header(master, offset, header);
-               if (ret)
-                       continue;
-
-               if (!verify(header)) {
-                       pr_debug("no valid uImage found in \"%s\" at offset %llx\n",
-                                master->name, (unsigned long long) offset);
-                       continue;
-               }
-
-               uimage_size = sizeof(*header) + be32_to_cpu(header->ih_size);
-               if ((offset + uimage_size) > master->size) {
-                       pr_debug("uImage exceeds MTD device \"%s\"\n",
-                                master->name);
-                       continue;
-               }
-               break;
-       }
-
-       if (uimage_size == 0) {
-               pr_debug("no uImage found in \"%s\"\n", master->name);
-               ret = -ENODEV;
-               goto err_free_header;
-       }
-
-       uimage_offset = offset;
-
-       if (uimage_offset == 0) {
-               uimage_part = 0;
-               rf_part = 1;
-
-               /* find the roots after the uImage */
-               ret = mtd_find_rootfs_from(master,
-                                          uimage_offset + uimage_size,
-                                          master->size,
-                                          &rootfs_offset);
-               if (ret) {
-                       pr_debug("no rootfs after uImage in \"%s\"\n",
-                                master->name);
-                       goto err_free_header;
-               }
-
-               rootfs_size = master->size - rootfs_offset;
-               uimage_size = rootfs_offset - uimage_offset;
-       } else {
-               rf_part = 0;
-               uimage_part = 1;
-
-               /* check rootfs presence at offset 0 */
-               ret = mtd_check_rootfs_magic(master, 0);
-               if (ret) {
-                       pr_debug("no rootfs before uImage in \"%s\"\n",
-                                master->name);
-                       goto err_free_header;
-               }
-
-               rootfs_offset = 0;
-               rootfs_size = uimage_offset;
-       }
-
-       if (rootfs_size == 0) {
-               pr_debug("no rootfs found in \"%s\"\n", master->name);
-               ret = -ENODEV;
-               goto err_free_header;
-       }
-
-       parts[uimage_part].name = KERNEL_PART_NAME;
-       parts[uimage_part].offset = uimage_offset;
-       parts[uimage_part].size = uimage_size;
-
-       parts[rf_part].name = ROOTFS_PART_NAME;
-       parts[rf_part].offset = rootfs_offset;
-       parts[rf_part].size = rootfs_size;
-
-       vfree(header);
-
-       *pparts = parts;
-       return nr_parts;
-
-err_free_header:
-       vfree(header);
-
-err_free_parts:
-       kfree(parts);
-       return ret;
-}
-
-static bool uimage_verify_default(struct uimage_header *header)
-{
-       /* default sanity checks */
-       if (be32_to_cpu(header->ih_magic) != IH_MAGIC) {
-               pr_debug("invalid uImage magic: %08x\n",
-                        be32_to_cpu(header->ih_magic));
-               return false;
-       }
-
-       if (header->ih_os != IH_OS_LINUX) {
-               pr_debug("invalid uImage OS: %08x\n",
-                        be32_to_cpu(header->ih_os));
-               return false;
-       }
-
-       if (header->ih_type != IH_TYPE_KERNEL) {
-               pr_debug("invalid uImage type: %08x\n",
-                        be32_to_cpu(header->ih_type));
-               return false;
-       }
-
-       return true;
-}
-
-static int
-mtdsplit_uimage_parse_generic(struct mtd_info *master,
-                             struct mtd_partition **pparts,
-                             struct mtd_part_parser_data *data)
-{
-       return __mtdsplit_parse_uimage(master, pparts, data,
-                                     uimage_verify_default);
-}
-
-static struct mtd_part_parser uimage_generic_parser = {
-       .owner = THIS_MODULE,
-       .name = "uimage-fw",
-       .parse_fn = mtdsplit_uimage_parse_generic,
-       .type = MTD_PARSER_TYPE_FIRMWARE,
-};
-
-#define FW_MAGIC_WNR2000V3     0x32303033
-#define FW_MAGIC_WNR2000V4     0x32303034
-#define FW_MAGIC_WNR2200       0x32323030
-#define FW_MAGIC_WNR612V2      0x32303631
-#define FW_MAGIC_WNDR3700      0x33373030
-#define FW_MAGIC_WNDR3700V2    0x33373031
-
-static bool uimage_verify_wndr3700(struct uimage_header *header)
-{
-       uint8_t expected_type = IH_TYPE_FILESYSTEM;
-       switch be32_to_cpu(header->ih_magic) {
-       case FW_MAGIC_WNR612V2:
-       case FW_MAGIC_WNR2000V3:
-       case FW_MAGIC_WNR2200:
-       case FW_MAGIC_WNDR3700:
-       case FW_MAGIC_WNDR3700V2:
-               break;
-       case FW_MAGIC_WNR2000V4:
-               expected_type = IH_TYPE_KERNEL;
-               break;
-       default:
-               return false;
-       }
-
-       if (header->ih_os != IH_OS_LINUX ||
-           header->ih_type != expected_type)
-               return false;
-
-       return true;
-}
-
-static int
-mtdsplit_uimage_parse_netgear(struct mtd_info *master,
-                             struct mtd_partition **pparts,
-                             struct mtd_part_parser_data *data)
-{
-       return __mtdsplit_parse_uimage(master, pparts, data,
-                                     uimage_verify_wndr3700);
-}
-
-static struct mtd_part_parser uimage_netgear_parser = {
-       .owner = THIS_MODULE,
-       .name = "netgear-fw",
-       .parse_fn = mtdsplit_uimage_parse_netgear,
-       .type = MTD_PARSER_TYPE_FIRMWARE,
-};
-
-static int __init mtdsplit_uimage_init(void)
-{
-       register_mtd_parser(&uimage_generic_parser);
-       register_mtd_parser(&uimage_netgear_parser);
-
-       return 0;
-}
-
-module_init(mtdsplit_uimage_init);
index 6c17b01e53e71754cfd02a7a1a7a703bff5e752c..e14e7c094b5cfd3a4320958c44b7813a59aa4585 100644 (file)
@@ -35,7 +35,7 @@
        depends on m
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -29,6 +29,7 @@
+@@ -29,9 +29,11 @@
  #include <linux/kmod.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
  #include <linux/err.h>
  
  #include "mtdcore.h"
-@@ -45,13 +46,14 @@ struct mtd_part {
++#include "mtdsplit/mtdsplit.h"
+ /* Our partition linked list */
+ static LIST_HEAD(mtd_partitions);
+@@ -45,13 +47,14 @@ struct mtd_part {
        struct list_head list;
  };
  
@@ -59,7 +63,7 @@
  /*
   * MTD methods which simply translate the effective address and pass through
   * to the _real_ device.
-@@ -533,8 +535,10 @@ out_register:
+@@ -533,8 +536,10 @@ out_register:
        return slave;
  }
  
@@ -72,7 +76,7 @@
  {
        struct mtd_partition part;
        struct mtd_part *p, *new;
-@@ -566,21 +570,24 @@ int mtd_add_partition(struct mtd_info *m
+@@ -566,21 +571,24 @@ int mtd_add_partition(struct mtd_info *m
        end = offset + length;
  
        mutex_lock(&mtd_partitions_mutex);
  
        return ret;
  err_inv:
-@@ -590,6 +597,12 @@ err_inv:
+@@ -590,6 +598,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 +626,144 @@ int mtd_del_partition(struct mtd_info *m
+@@ -613,6 +627,144 @@ int mtd_del_partition(struct mtd_info *m
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
  /*
   * 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 +793,7 @@ int add_mtd_partitions(struct mtd_info *
+@@ -642,6 +794,7 @@ int add_mtd_partitions(struct mtd_info *
                mutex_unlock(&mtd_partitions_mutex);
  
                add_mtd_device(&slave->mtd);
index bd35aa7d35388e96178fc1e4ab3b49a9756e7f53..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
-@@ -823,6 +823,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)
  
@@ -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);
-@@ -899,6 +923,38 @@ int parse_mtd_partitions(struct mtd_info
+@@ -900,6 +924,38 @@ int parse_mtd_partitions(struct mtd_info
        return ret;
  }
  
index 649693ff22c2c6c7ac8f7800f9d37c22ec7d6dd7..a614094851c8db0a23be3225724cd28a7d2f1798 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -626,6 +626,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);
  
@@ -38,7 +38,7 @@
  static inline unsigned long
  mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
  {
-@@ -685,6 +716,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;
  
@@ -49,7 +49,7 @@
        ret = split_squashfs(master, part->offset, &split_offset);
        if (ret)
                return;
-@@ -734,6 +769,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)
  {
index c24f34c5cc3a336c74a843d36457d4386d962e39..23cbd6243c6cbfdb6431780ab036039cb5d228a3 100644 (file)
@@ -1,13 +1,10 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -36,6 +36,11 @@ config MTD_UIMAGE_SPLIT
+@@ -36,6 +36,8 @@ config MTD_UIMAGE_SPLIT
        depends on MTD_SPLIT_FIRMWARE
        default y
  
-+config MTD_SPLIT
-+      def_bool n
-+      help 
-+        Generic MTD split support.
++source "drivers/mtd/mtdsplit/Kconfig"
 +
  endmenu
  
@@ -18,7 +15,7 @@
  obj-$(CONFIG_MTD)             += mtd.o
  mtd-y                         := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
  
-+mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
++obj-$(CONFIG_MTD_SPLIT)               += mtdsplit/
 +
  obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
  obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
index 02e4e038c2c875d7d1c92655aad6b8b317e07cb3..e4dd1e4852deeb2ce39635bc97cd6f156310c4bd 100644 (file)
@@ -1,14 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -33,6 +33,7 @@
- #include <linux/err.h>
- #include "mtdcore.h"
-+#include "mtdsplit.h"
- /* Our partition linked list */
- static LIST_HEAD(mtd_partitions);
-@@ -668,43 +669,16 @@ mtd_pad_erasesize(struct mtd_info *mtd, 
+@@ -669,43 +669,16 @@ mtd_pad_erasesize(struct mtd_info *mtd, 
        return len;
  }
  
diff --git a/target/linux/generic/patches-3.10/406-mtd-add-squashfs-parser.patch b/target/linux/generic/patches-3.10/406-mtd-add-squashfs-parser.patch
deleted file mode 100644 (file)
index b3ff9d9..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -37,6 +37,17 @@ config MTD_UIMAGE_SPLIT
-       depends on MTD_SPLIT_FIRMWARE
-       default y
-+comment "Rootfs partition parsers"
-+
-+config MTD_SPLIT_SQUASHFS_ROOT
-+      bool "Squashfs based root partition parser"
-+      select MTD_SPLIT
-+      default n
-+      help
-+        This provides a parsing function which allows to detect the
-+        offset and size of the unused portion of a rootfs partition
-+        containing a squashfs.
-+
- config MTD_SPLIT
-       def_bool n
-       help 
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD)              += mtd.o
- mtd-y                         := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
- mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
-+mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
- obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
- obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
diff --git a/target/linux/generic/patches-3.10/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch b/target/linux/generic/patches-3.10/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch
deleted file mode 100644 (file)
index 02697f6..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -48,6 +48,12 @@ config MTD_SPLIT_SQUASHFS_ROOT
-         offset and size of the unused portion of a rootfs partition
-         containing a squashfs.
-+comment "Firmware partition parsers"
-+
-+config MTD_SPLIT_UIMAGE_FW
-+      bool "uImage based firmware partition parser"
-+      select MTD_SPLIT
-+
- config MTD_SPLIT
-       def_bool n
-       help 
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -8,6 +8,7 @@ mtd-y                          := mtdcore.o mtdsuper.o mtdconc
- mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
- mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
-+mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o
- obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
- obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
diff --git a/target/linux/generic/patches-3.10/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch b/target/linux/generic/patches-3.10/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch
deleted file mode 100644 (file)
index 016a9b6..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -50,6 +50,10 @@ config MTD_SPLIT_SQUASHFS_ROOT
- comment "Firmware partition parsers"
-+config MTD_SPLIT_SEAMA_FW
-+      bool "Seama firmware parser"
-+      select MTD_SPLIT
-+
- config MTD_SPLIT_UIMAGE_FW
-       bool "uImage based firmware partition parser"
-       select MTD_SPLIT
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD)              += mtd.o
- mtd-y                         := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
- mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
-+mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o
- mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
- mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o
diff --git a/target/linux/generic/patches-3.10/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch b/target/linux/generic/patches-3.10/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch
deleted file mode 100644 (file)
index cc9a971..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -58,6 +58,10 @@ config MTD_SPLIT_UIMAGE_FW
-       bool "uImage based firmware partition parser"
-       select MTD_SPLIT
-+config MTD_SPLIT_LZMA_FW
-+      bool "LZMA compressed kernel based firmware partition parser"
-+      select MTD_SPLIT
-+
- config MTD_SPLIT
-       def_bool n
-       help 
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -10,6 +10,7 @@ mtd-$(CONFIG_MTD_SPLIT)              += mtdsplit.o
- mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o
- mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
- mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o
-+mtd-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o
- obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
- obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
index 940741120703954a9c44457602b5ab9bc9316c53..31d126c0a69976e4eb11cbb7b2bddf60d7a7358c 100644 (file)
@@ -2,7 +2,7 @@
 +++ b/drivers/mtd/mtdpart.c
 @@ -35,6 +35,8 @@
  #include "mtdcore.h"
- #include "mtdsplit.h"
+ #include "mtdsplit/mtdsplit.h"
  
 +#define MTD_ERASE_PARTIAL     0x8000 /* partition only covers parts of an erase block */
 +
index fc352d2779f00bd3a083270a91b405f054d8f6b0..b6a6b6e57caa8aad4b5d66dc4db338dfe874a5e0 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -212,6 +212,22 @@ config MTD_BCM47XX_PARTS
+@@ -184,6 +184,22 @@ config MTD_BCM47XX_PARTS
          This provides partitions parser for devices based on BCM47xx
          boards.
  
@@ -25,7 +25,7 @@
  config MTD_BLKDEVS
 --- a/drivers/mtd/Makefile
 +++ b/drivers/mtd/Makefile
-@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_AFS_PARTS)  += afs.o
+@@ -15,6 +15,7 @@ obj-$(CONFIG_MTD_AFS_PARTS)  += afs.o
  obj-$(CONFIG_MTD_AR7_PARTS)   += ar7part.o
  obj-$(CONFIG_MTD_BCM63XX_PARTS)       += bcm63xxpart.o
  obj-$(CONFIG_MTD_BCM47XX_PARTS)       += bcm47xxpart.o
index f97a442cb13f880365243e89948143e343024c90..002a79ab73d12628329c35c9bc072772a7a3f170 100644 (file)
@@ -11,7 +11,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
 
 --- a/drivers/mtd/ubi/build.c
 +++ b/drivers/mtd/ubi/build.c
-@@ -1209,6 +1209,48 @@
+@@ -1207,6 +1207,48 @@ static struct mtd_info * __init open_mtd
        return mtd;
  }
  
@@ -60,7 +60,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  static int __init ubi_init(void)
  {
        int err, i, k;
-@@ -1298,6 +1340,12 @@
+@@ -1290,6 +1332,12 @@ static int __init ubi_init(void)
                }
        }
  
index ce91d7ba5e369063123358f4d62c2f72f336aed0..ae8c45fa9943c2d166c41c564487ba8fd650bd09 100644 (file)
@@ -35,7 +35,7 @@
        depends on m
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -29,6 +29,7 @@
+@@ -29,9 +29,11 @@
  #include <linux/kmod.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
  #include <linux/err.h>
  
  #include "mtdcore.h"
-@@ -45,13 +46,14 @@ struct mtd_part {
++#include "mtdsplit/mtdsplit.h"
+ /* Our partition linked list */
+ static LIST_HEAD(mtd_partitions);
+@@ -45,13 +47,14 @@ struct mtd_part {
        struct list_head list;
  };
  
@@ -59,7 +63,7 @@
  /*
   * MTD methods which simply translate the effective address and pass through
   * to the _real_ device.
-@@ -534,8 +536,10 @@ out_register:
+@@ -534,8 +537,10 @@ out_register:
        return slave;
  }
  
@@ -72,7 +76,7 @@
  {
        struct mtd_partition part;
        struct mtd_part *p, *new;
-@@ -567,21 +571,24 @@ int mtd_add_partition(struct mtd_info *m
+@@ -567,21 +572,24 @@ int mtd_add_partition(struct mtd_info *m
        end = offset + length;
  
        mutex_lock(&mtd_partitions_mutex);
  
        return ret;
  err_inv:
-@@ -591,6 +598,12 @@ err_inv:
+@@ -591,6 +599,12 @@ err_inv:
  }
  EXPORT_SYMBOL_GPL(mtd_add_partition);
  
  int mtd_del_partition(struct mtd_info *master, int partno)
  {
        struct mtd_part *slave, *next;
-@@ -614,6 +627,144 @@ int mtd_del_partition(struct mtd_info *m
+@@ -614,6 +628,144 @@ int mtd_del_partition(struct mtd_info *m
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
  /*
   * 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 +794,7 @@ int add_mtd_partitions(struct mtd_info *
+@@ -643,6 +795,7 @@ int add_mtd_partitions(struct mtd_info *
                mutex_unlock(&mtd_partitions_mutex);
  
                add_mtd_device(&slave->mtd);
index 52b87f56cc903cc84490f0de3dc4ec5744b5bb7f..793005d6e1a452eb8645159d14461beadf73d135 100644 (file)
@@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
 
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -824,6 +824,30 @@ static struct mtd_part_parser *get_parti
+@@ -825,6 +825,30 @@ static struct mtd_part_parser *get_parti
  
  #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);
-@@ -900,6 +924,38 @@ int parse_mtd_partitions(struct mtd_info
+@@ -901,6 +925,38 @@ int parse_mtd_partitions(struct mtd_info
        return ret;
  }
  
index a614094851c8db0a23be3225724cd28a7d2f1798..8d0bda825f460a7c96171d9534480918864eebd2 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -627,6 +627,37 @@ int mtd_del_partition(struct mtd_info *m
+@@ -628,6 +628,37 @@ int mtd_del_partition(struct mtd_info *m
  }
  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)
  {
-@@ -686,6 +717,10 @@ static void split_rootfs_data(struct mtd
+@@ -687,6 +718,10 @@ static void split_rootfs_data(struct mtd
        unsigned int split_size;
        int ret;
  
@@ -49,7 +49,7 @@
        ret = split_squashfs(master, part->offset, &split_offset);
        if (ret)
                return;
-@@ -735,6 +770,12 @@ static void split_uimage(struct mtd_info
+@@ -736,6 +771,12 @@ static void split_uimage(struct mtd_info
  
  static void split_firmware(struct mtd_info *master, struct mtd_part *part)
  {
index c24f34c5cc3a336c74a843d36457d4386d962e39..23cbd6243c6cbfdb6431780ab036039cb5d228a3 100644 (file)
@@ -1,13 +1,10 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -36,6 +36,11 @@ config MTD_UIMAGE_SPLIT
+@@ -36,6 +36,8 @@ config MTD_UIMAGE_SPLIT
        depends on MTD_SPLIT_FIRMWARE
        default y
  
-+config MTD_SPLIT
-+      def_bool n
-+      help 
-+        Generic MTD split support.
++source "drivers/mtd/mtdsplit/Kconfig"
 +
  endmenu
  
@@ -18,7 +15,7 @@
  obj-$(CONFIG_MTD)             += mtd.o
  mtd-y                         := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
  
-+mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
++obj-$(CONFIG_MTD_SPLIT)               += mtdsplit/
 +
  obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
  obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
index a54b97b07c391ba242bbdbeb5b3f7fddd4774ecd..4ae675faf961c72e353e2da6eb5aa04e7c9704b7 100644 (file)
@@ -1,14 +1,6 @@
 --- a/drivers/mtd/mtdpart.c
 +++ b/drivers/mtd/mtdpart.c
-@@ -33,6 +33,7 @@
- #include <linux/err.h>
- #include "mtdcore.h"
-+#include "mtdsplit.h"
- /* Our partition linked list */
- static LIST_HEAD(mtd_partitions);
-@@ -669,43 +670,16 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+@@ -670,43 +670,16 @@ mtd_pad_erasesize(struct mtd_info *mtd, 
        return len;
  }
  
diff --git a/target/linux/generic/patches-3.13/406-mtd-add-squashfs-parser.patch b/target/linux/generic/patches-3.13/406-mtd-add-squashfs-parser.patch
deleted file mode 100644 (file)
index b3ff9d9..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -37,6 +37,17 @@ config MTD_UIMAGE_SPLIT
-       depends on MTD_SPLIT_FIRMWARE
-       default y
-+comment "Rootfs partition parsers"
-+
-+config MTD_SPLIT_SQUASHFS_ROOT
-+      bool "Squashfs based root partition parser"
-+      select MTD_SPLIT
-+      default n
-+      help
-+        This provides a parsing function which allows to detect the
-+        offset and size of the unused portion of a rootfs partition
-+        containing a squashfs.
-+
- config MTD_SPLIT
-       def_bool n
-       help 
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD)              += mtd.o
- mtd-y                         := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
- mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
-+mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
- obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
- obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
diff --git a/target/linux/generic/patches-3.13/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch b/target/linux/generic/patches-3.13/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch
deleted file mode 100644 (file)
index 02697f6..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -48,6 +48,12 @@ config MTD_SPLIT_SQUASHFS_ROOT
-         offset and size of the unused portion of a rootfs partition
-         containing a squashfs.
-+comment "Firmware partition parsers"
-+
-+config MTD_SPLIT_UIMAGE_FW
-+      bool "uImage based firmware partition parser"
-+      select MTD_SPLIT
-+
- config MTD_SPLIT
-       def_bool n
-       help 
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -8,6 +8,7 @@ mtd-y                          := mtdcore.o mtdsuper.o mtdconc
- mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
- mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
-+mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o
- obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
- obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
diff --git a/target/linux/generic/patches-3.13/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch b/target/linux/generic/patches-3.13/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch
deleted file mode 100644 (file)
index 016a9b6..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -50,6 +50,10 @@ config MTD_SPLIT_SQUASHFS_ROOT
- comment "Firmware partition parsers"
-+config MTD_SPLIT_SEAMA_FW
-+      bool "Seama firmware parser"
-+      select MTD_SPLIT
-+
- config MTD_SPLIT_UIMAGE_FW
-       bool "uImage based firmware partition parser"
-       select MTD_SPLIT
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD)              += mtd.o
- mtd-y                         := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
- mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
-+mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o
- mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
- mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o
diff --git a/target/linux/generic/patches-3.13/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch b/target/linux/generic/patches-3.13/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch
deleted file mode 100644 (file)
index cc9a971..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -58,6 +58,10 @@ config MTD_SPLIT_UIMAGE_FW
-       bool "uImage based firmware partition parser"
-       select MTD_SPLIT
-+config MTD_SPLIT_LZMA_FW
-+      bool "LZMA compressed kernel based firmware partition parser"
-+      select MTD_SPLIT
-+
- config MTD_SPLIT
-       def_bool n
-       help 
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -10,6 +10,7 @@ mtd-$(CONFIG_MTD_SPLIT)              += mtdsplit.o
- mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o
- mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
- mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o
-+mtd-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o
- obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
- obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
index 8da080b2ade89e36f1da84e7be28d63a3c572d8d..668b7d7289e13d5521dd7c7f6e3b6bdf61a49786 100644 (file)
@@ -2,7 +2,7 @@
 +++ b/drivers/mtd/mtdpart.c
 @@ -35,6 +35,8 @@
  #include "mtdcore.h"
- #include "mtdsplit.h"
+ #include "mtdsplit/mtdsplit.h"
  
 +#define MTD_ERASE_PARTIAL     0x8000 /* partition only covers parts of an erase block */
 +
index fc352d2779f00bd3a083270a91b405f054d8f6b0..b6a6b6e57caa8aad4b5d66dc4db338dfe874a5e0 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -212,6 +212,22 @@ config MTD_BCM47XX_PARTS
+@@ -184,6 +184,22 @@ config MTD_BCM47XX_PARTS
          This provides partitions parser for devices based on BCM47xx
          boards.
  
@@ -25,7 +25,7 @@
  config MTD_BLKDEVS
 --- a/drivers/mtd/Makefile
 +++ b/drivers/mtd/Makefile
-@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_AFS_PARTS)  += afs.o
+@@ -15,6 +15,7 @@ obj-$(CONFIG_MTD_AFS_PARTS)  += afs.o
  obj-$(CONFIG_MTD_AR7_PARTS)   += ar7part.o
  obj-$(CONFIG_MTD_BCM63XX_PARTS)       += bcm63xxpart.o
  obj-$(CONFIG_MTD_BCM47XX_PARTS)       += bcm47xxpart.o
index 9bf5e33a08a2761cd9573a323a70d1e87dfec954..372e5783268aa58c15f339561a837ad1c2a63370 100644 (file)
@@ -30,7 +30,7 @@
  /****************************************************************************/
  
  struct m25p {
-@@ -1032,7 +1038,7 @@ static int m25p_probe(struct spi_device
+@@ -1032,7 +1038,7 @@ static int m25p_probe(struct spi_device 
                flash->mtd._write = m25p80_write;
  
        /* prefer "small sector" erase if possible */
index 5b73d3898b42be443494b1a73a85137ed5674b6b..5345678c56498611356ca93681870b7893757837 100644 (file)
@@ -8,7 +8,7 @@
  static struct proc_dir_entry *my_proc_entry;
  
  static char *yaffs_dump_dev_part0(char *buf, struct yaffs_dev *dev)
-@@ -3398,6 +3399,7 @@ static int yaffs_proc_write(struct file
+@@ -3398,6 +3399,7 @@ static int yaffs_proc_write(struct file 
                return yaffs_proc_debug_write(file, buf, count, data);
        return yaffs_proc_write_trace_options(file, buf, count, data);
  }
index 5ffacaf6424ad3ffd1b62ef44f2a2127f33c2dac..94551e247f674ac0faf716a45ab33173b4d243bc 100644 (file)
@@ -34,7 +34,7 @@
  #include <linux/err.h>
  
  #include "mtdcore.h"
-+#include "mtdsplit.h"
++#include "mtdsplit/mtdsplit.h"
  
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
index d897034abd37f82a05c773e81bd8706a4ba85b8d..0cf1c38555110040230fa5781688280df45e6eef 100644 (file)
@@ -1,13 +1,10 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_NAME
+@@ -27,6 +27,8 @@ config MTD_SPLIT_FIRMWARE_NAME
        depends on MTD_SPLIT_FIRMWARE
        default "firmware"
  
-+config MTD_SPLIT
-+      def_bool n
-+      help 
-+        Generic MTD split support.
++source "drivers/mtd/mtdsplit/Kconfig"
 +
  endmenu
  
@@ -18,7 +15,7 @@
  obj-$(CONFIG_MTD)             += mtd.o
  mtd-y                         := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
  
-+mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
++obj-$(CONFIG_MTD_SPLIT)               += mtdsplit/
 +
  obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
  obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
diff --git a/target/linux/generic/patches-3.14/404-mtd-add-more-helper-functions.patch b/target/linux/generic/patches-3.14/404-mtd-add-more-helper-functions.patch
new file mode 100644 (file)
index 0000000..f3f957b
--- /dev/null
@@ -0,0 +1,101 @@
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -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) {
+-              slave->offset = cur_offset;
+-              if (mtd_mod_by_eb(cur_offset, master) != 0) {
+-                      /* Round up to next erasesize */
+-                      slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize;
++              /* Round up to next erasesize */
++              slave->offset = mtd_roundup_to_eb(cur_offset, master);
++              if (slave->offset != cur_offset)
+                       printk(KERN_NOTICE "Moving partition %d: "
+                              "0x%012llx -> 0x%012llx\n", partno,
+                              (unsigned long long)cur_offset, (unsigned long long)slave->offset);
+-              }
+       }
+       if (slave->offset == MTDPART_OFS_RETAIN) {
+               slave->offset = cur_offset;
+@@ -659,6 +657,17 @@ run_parsers_by_type(struct mtd_part *sla
+       return nr_parts;
+ }
++static inline unsigned long
++mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
++{
++      unsigned long mask = mtd->erasesize - 1;
++
++      len += offset & mask;
++      len = (len + mask) & ~mask;
++      len -= offset & mask;
++      return len;
++}
++
+ #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
+ #define SPLIT_FIRMWARE_NAME   CONFIG_MTD_SPLIT_FIRMWARE_NAME
+ #else
+@@ -900,6 +909,24 @@ int mtd_is_partition(const struct mtd_in
+ }
+ EXPORT_SYMBOL_GPL(mtd_is_partition);
++struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd)
++{
++      if (!mtd_is_partition(mtd))
++              return (struct mtd_info *)mtd;
++
++      return PART(mtd)->master;
++}
++EXPORT_SYMBOL_GPL(mtdpart_get_master);
++
++uint64_t mtdpart_get_offset(const struct mtd_info *mtd)
++{
++      if (!mtd_is_partition(mtd))
++              return 0;
++
++      return PART(mtd)->offset;
++}
++EXPORT_SYMBOL_GPL(mtdpart_get_offset);
++
+ /* Returns the size of the entire flash chip */
+ uint64_t mtd_get_device_size(const struct mtd_info *mtd)
+ {
+--- a/include/linux/mtd/partitions.h
++++ b/include/linux/mtd/partitions.h
+@@ -90,6 +90,8 @@ int mtd_is_partition(const struct mtd_in
+ int mtd_add_partition(struct mtd_info *master, const char *name,
+                     long long offset, long long length);
+ int mtd_del_partition(struct mtd_info *master, int partno);
++struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd);
++uint64_t mtdpart_get_offset(const struct mtd_info *mtd);
+ uint64_t mtd_get_device_size(const struct mtd_info *mtd);
+ extern void __weak arch_split_mtd_part(struct mtd_info *master,
+                                      const char *name, int offset, int size);
+--- a/include/linux/mtd/mtd.h
++++ b/include/linux/mtd/mtd.h
+@@ -331,6 +331,24 @@ static inline uint32_t mtd_mod_by_eb(uin
+       return do_div(sz, mtd->erasesize);
+ }
++static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd)
++{
++      if (mtd_mod_by_eb(sz, mtd) == 0)
++              return sz;
++
++      /* Round up to next erase block */
++      return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize;
++}
++
++static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd)
++{
++      if (mtd_mod_by_eb(sz, mtd) == 0)
++              return sz;
++
++      /* Round down to the start of the current erase block */
++      return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize;
++}
++
+ static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
+ {
+       if (mtd->writesize_shift)
diff --git a/target/linux/generic/patches-3.14/405-mtd-add-more-helper-functions.patch b/target/linux/generic/patches-3.14/405-mtd-add-more-helper-functions.patch
deleted file mode 100644 (file)
index f3f957b..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
---- a/drivers/mtd/mtdpart.c
-+++ b/drivers/mtd/mtdpart.c
-@@ -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) {
--              slave->offset = cur_offset;
--              if (mtd_mod_by_eb(cur_offset, master) != 0) {
--                      /* Round up to next erasesize */
--                      slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize;
-+              /* Round up to next erasesize */
-+              slave->offset = mtd_roundup_to_eb(cur_offset, master);
-+              if (slave->offset != cur_offset)
-                       printk(KERN_NOTICE "Moving partition %d: "
-                              "0x%012llx -> 0x%012llx\n", partno,
-                              (unsigned long long)cur_offset, (unsigned long long)slave->offset);
--              }
-       }
-       if (slave->offset == MTDPART_OFS_RETAIN) {
-               slave->offset = cur_offset;
-@@ -659,6 +657,17 @@ run_parsers_by_type(struct mtd_part *sla
-       return nr_parts;
- }
-+static inline unsigned long
-+mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
-+{
-+      unsigned long mask = mtd->erasesize - 1;
-+
-+      len += offset & mask;
-+      len = (len + mask) & ~mask;
-+      len -= offset & mask;
-+      return len;
-+}
-+
- #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
- #define SPLIT_FIRMWARE_NAME   CONFIG_MTD_SPLIT_FIRMWARE_NAME
- #else
-@@ -900,6 +909,24 @@ int mtd_is_partition(const struct mtd_in
- }
- EXPORT_SYMBOL_GPL(mtd_is_partition);
-+struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd)
-+{
-+      if (!mtd_is_partition(mtd))
-+              return (struct mtd_info *)mtd;
-+
-+      return PART(mtd)->master;
-+}
-+EXPORT_SYMBOL_GPL(mtdpart_get_master);
-+
-+uint64_t mtdpart_get_offset(const struct mtd_info *mtd)
-+{
-+      if (!mtd_is_partition(mtd))
-+              return 0;
-+
-+      return PART(mtd)->offset;
-+}
-+EXPORT_SYMBOL_GPL(mtdpart_get_offset);
-+
- /* Returns the size of the entire flash chip */
- uint64_t mtd_get_device_size(const struct mtd_info *mtd)
- {
---- a/include/linux/mtd/partitions.h
-+++ b/include/linux/mtd/partitions.h
-@@ -90,6 +90,8 @@ int mtd_is_partition(const struct mtd_in
- int mtd_add_partition(struct mtd_info *master, const char *name,
-                     long long offset, long long length);
- int mtd_del_partition(struct mtd_info *master, int partno);
-+struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd);
-+uint64_t mtdpart_get_offset(const struct mtd_info *mtd);
- uint64_t mtd_get_device_size(const struct mtd_info *mtd);
- extern void __weak arch_split_mtd_part(struct mtd_info *master,
-                                      const char *name, int offset, int size);
---- a/include/linux/mtd/mtd.h
-+++ b/include/linux/mtd/mtd.h
-@@ -331,6 +331,24 @@ static inline uint32_t mtd_mod_by_eb(uin
-       return do_div(sz, mtd->erasesize);
- }
-+static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd)
-+{
-+      if (mtd_mod_by_eb(sz, mtd) == 0)
-+              return sz;
-+
-+      /* Round up to next erase block */
-+      return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize;
-+}
-+
-+static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd)
-+{
-+      if (mtd_mod_by_eb(sz, mtd) == 0)
-+              return sz;
-+
-+      /* Round down to the start of the current erase block */
-+      return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize;
-+}
-+
- static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
- {
-       if (mtd->writesize_shift)
diff --git a/target/linux/generic/patches-3.14/405-mtd-old-firmware-uimage-splitter.patch b/target/linux/generic/patches-3.14/405-mtd-old-firmware-uimage-splitter.patch
new file mode 100644 (file)
index 0000000..c4ceb82
--- /dev/null
@@ -0,0 +1,70 @@
+--- a/drivers/mtd/Kconfig
++++ b/drivers/mtd/Kconfig
+@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_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
++
+ source "drivers/mtd/mtdsplit/Kconfig"
+ endmenu
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -668,6 +668,37 @@ mtd_pad_erasesize(struct mtd_info *mtd, 
+       return len;
+ }
++#define UBOOT_MAGIC   0x27051956
++
++static void split_uimage(struct mtd_info *master, struct mtd_part *part)
++{
++      struct {
++              __be32 magic;
++              __be32 pad[2];
++              __be32 size;
++      } hdr;
++      size_t len;
++
++      if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr))
++              return;
++
++      if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC))
++              return;
++
++      len = be32_to_cpu(hdr.size) + 0x40;
++      len = mtd_pad_erasesize(master, part->offset, len);
++      if (len + master->erasesize > part->mtd.size)
++              return;
++
++      if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW))
++              pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n");
++      else
++              pr_warn("Support for built-in firmware splitter will be removed, please use CONFIG_MTD_SPLIT_UIMAGE_FW\n");
++
++      __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
+@@ -676,7 +707,14 @@ mtd_pad_erasesize(struct mtd_info *mtd, 
+ static void split_firmware(struct mtd_info *master, struct mtd_part *part)
+ {
+-      run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
++      int ret;
++
++      ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
++      if (ret > 0)
++              return;
++
++      if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
++              split_uimage(master, part);
+ }
+ void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
diff --git a/target/linux/generic/patches-3.14/406-mtd-hook-mtdsplit-into-Kbuild.patch b/target/linux/generic/patches-3.14/406-mtd-hook-mtdsplit-into-Kbuild.patch
deleted file mode 100644 (file)
index 008714b..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -27,6 +27,8 @@ config MTD_SPLIT_FIRMWARE_NAME
-       depends on MTD_SPLIT_FIRMWARE
-       default "firmware"
-+source "drivers/mtd/mtdsplit/Kconfig"
-+
- config MTD_SPLIT
-       def_bool n
-       help 
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -7,6 +7,10 @@ obj-$(CONFIG_MTD)             += mtd.o
- mtd-y                         := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
- mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
-+mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o
-+mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
-+mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o
-+mtd-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o
- obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
- obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
diff --git a/target/linux/generic/patches-3.14/406-mtd-old-rootfs-squashfs-splitter.patch b/target/linux/generic/patches-3.14/406-mtd-old-rootfs-squashfs-splitter.patch
new file mode 100644 (file)
index 0000000..9147d1d
--- /dev/null
@@ -0,0 +1,76 @@
+--- a/drivers/mtd/Kconfig
++++ b/drivers/mtd/Kconfig
+@@ -18,6 +18,11 @@ config MTD_ROOTFS_ROOT_DEV
+       bool "Automatically set 'rootfs' partition to be root filesystem"
+       default y
++config MTD_ROOTFS_SPLIT
++      bool "Automatically split 'rootfs' partition for squashfs"
++      select MTD_SPLIT
++      default y
++
+ config MTD_SPLIT_FIRMWARE
+       bool "Automatically split firmware partition for kernel+rootfs"
+       default y
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -668,6 +668,47 @@ mtd_pad_erasesize(struct mtd_info *mtd, 
+       return len;
+ }
++static int split_squashfs(struct mtd_info *master, int offset, int *split_offset)
++{
++      size_t squashfs_len;
++      int len, ret;
++
++      ret = mtd_get_squashfs_len(master, offset, &squashfs_len);
++      if (ret)
++              return ret;
++
++      len = mtd_pad_erasesize(master, offset, squashfs_len);
++      *split_offset = offset + len;
++
++      return 0;
++}
++
++static void split_rootfs_data(struct mtd_info *master, struct mtd_part *part)
++{
++      unsigned int split_offset = 0;
++      unsigned int split_size;
++      int ret;
++
++      ret = split_squashfs(master, part->offset, &split_offset);
++      if (ret)
++              return;
++
++      if (split_offset <= 0)
++              return;
++
++      if (config_enabled(CONFIG_MTD_SPLIT_SQUASHFS_ROOT))
++              pr_err("Dedicated partitioner didn't create \"rootfs_data\" partition, please fill a bug report!\n");
++      else
++              pr_warn("Support for built-in \"rootfs_data\" splitter will be removed, please use CONFIG_MTD_SPLIT_SQUASHFS_ROOT\n");
++
++      split_size = part->mtd.size - (split_offset - part->offset);
++      printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=0x%x, len=0x%x\n",
++              ROOTFS_SPLIT_NAME, split_offset, split_size);
++
++      __mtd_add_partition(master, ROOTFS_SPLIT_NAME, split_offset,
++                          split_size, false);
++}
++
+ #define UBOOT_MAGIC   0x27051956
+ static void split_uimage(struct mtd_info *master, struct mtd_part *part)
+@@ -730,7 +771,10 @@ static void mtd_partition_split(struct m
+               return;
+       if (!strcmp(part->mtd.name, "rootfs")) {
+-              run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
++              int num = run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
++
++              if (num <= 0 && config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
++                      split_rootfs_data(master, part);
+               rootfs_found = 1;
+       }
diff --git a/target/linux/generic/patches-3.14/407-mtd-old-firmware-uimage-splitter.patch b/target/linux/generic/patches-3.14/407-mtd-old-firmware-uimage-splitter.patch
deleted file mode 100644 (file)
index 3f7e910..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_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
-+
- source "drivers/mtd/mtdsplit/Kconfig"
- config MTD_SPLIT
---- a/drivers/mtd/mtdpart.c
-+++ b/drivers/mtd/mtdpart.c
-@@ -668,6 +668,37 @@ mtd_pad_erasesize(struct mtd_info *mtd,
-       return len;
- }
-+#define UBOOT_MAGIC   0x27051956
-+
-+static void split_uimage(struct mtd_info *master, struct mtd_part *part)
-+{
-+      struct {
-+              __be32 magic;
-+              __be32 pad[2];
-+              __be32 size;
-+      } hdr;
-+      size_t len;
-+
-+      if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr))
-+              return;
-+
-+      if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC))
-+              return;
-+
-+      len = be32_to_cpu(hdr.size) + 0x40;
-+      len = mtd_pad_erasesize(master, part->offset, len);
-+      if (len + master->erasesize > part->mtd.size)
-+              return;
-+
-+      if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW))
-+              pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n");
-+      else
-+              pr_warn("Support for built-in firmware splitter will be removed, please use CONFIG_MTD_SPLIT_UIMAGE_FW\n");
-+
-+      __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
-@@ -676,7 +707,14 @@ mtd_pad_erasesize(struct mtd_info *mtd,
- static void split_firmware(struct mtd_info *master, struct mtd_part *part)
- {
--      run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
-+      int ret;
-+
-+      ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
-+      if (ret > 0)
-+              return;
-+
-+      if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
-+              split_uimage(master, part);
- }
- void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
diff --git a/target/linux/generic/patches-3.14/408-mtd-old-rootfs-squashfs-splitter.patch b/target/linux/generic/patches-3.14/408-mtd-old-rootfs-squashfs-splitter.patch
deleted file mode 100644 (file)
index c29b137..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -18,6 +18,11 @@ config MTD_ROOTFS_ROOT_DEV
-       bool "Automatically set 'rootfs' partition to be root filesystem"
-       default y
-+config MTD_ROOTFS_SPLIT
-+      bool "Automatically split 'rootfs' partition for squashfs"
-+      select MTD_SPLIT
-+      default y
-+
- config MTD_SPLIT_FIRMWARE
-       bool "Automatically split firmware partition for kernel+rootfs"
-       default y
---- a/drivers/mtd/mtdpart.c
-+++ b/drivers/mtd/mtdpart.c
-@@ -668,6 +668,47 @@ mtd_pad_erasesize(struct mtd_info *mtd,
-       return len;
- }
-+static int split_squashfs(struct mtd_info *master, int offset, int *split_offset)
-+{
-+      size_t squashfs_len;
-+      int len, ret;
-+
-+      ret = mtd_get_squashfs_len(master, offset, &squashfs_len);
-+      if (ret)
-+              return ret;
-+
-+      len = mtd_pad_erasesize(master, offset, squashfs_len);
-+      *split_offset = offset + len;
-+
-+      return 0;
-+}
-+
-+static void split_rootfs_data(struct mtd_info *master, struct mtd_part *part)
-+{
-+      unsigned int split_offset = 0;
-+      unsigned int split_size;
-+      int ret;
-+
-+      ret = split_squashfs(master, part->offset, &split_offset);
-+      if (ret)
-+              return;
-+
-+      if (split_offset <= 0)
-+              return;
-+
-+      if (config_enabled(CONFIG_MTD_SPLIT_SQUASHFS_ROOT))
-+              pr_err("Dedicated partitioner didn't create \"rootfs_data\" partition, please fill a bug report!\n");
-+      else
-+              pr_warn("Support for built-in \"rootfs_data\" splitter will be removed, please use CONFIG_MTD_SPLIT_SQUASHFS_ROOT\n");
-+
-+      split_size = part->mtd.size - (split_offset - part->offset);
-+      printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=0x%x, len=0x%x\n",
-+              ROOTFS_SPLIT_NAME, split_offset, split_size);
-+
-+      __mtd_add_partition(master, ROOTFS_SPLIT_NAME, split_offset,
-+                          split_size, false);
-+}
-+
- #define UBOOT_MAGIC   0x27051956
- static void split_uimage(struct mtd_info *master, struct mtd_part *part)
-@@ -730,7 +771,10 @@ static void mtd_partition_split(struct m
-               return;
-       if (!strcmp(part->mtd.name, "rootfs")) {
--              run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
-+              int num = run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
-+
-+              if (num <= 0 && config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
-+                      split_rootfs_data(master, part);
-               rootfs_found = 1;
-       }
index 8da080b2ade89e36f1da84e7be28d63a3c572d8d..668b7d7289e13d5521dd7c7f6e3b6bdf61a49786 100644 (file)
@@ -2,7 +2,7 @@
 +++ b/drivers/mtd/mtdpart.c
 @@ -35,6 +35,8 @@
  #include "mtdcore.h"
- #include "mtdsplit.h"
+ #include "mtdsplit/mtdsplit.h"
  
 +#define MTD_ERASE_PARTIAL     0x8000 /* partition only covers parts of an erase block */
 +
index ffc9e2199cf78b8bb63fb62d05ff435206ffa591..45af25dd61271244e899fd2293aa8051e19ca16c 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -189,6 +189,22 @@ config MTD_BCM47XX_PARTS
+@@ -184,6 +184,22 @@ config MTD_BCM47XX_PARTS
          This provides partitions parser for devices based on BCM47xx
          boards.
  
@@ -25,7 +25,7 @@
  #
 --- a/drivers/mtd/Makefile
 +++ b/drivers/mtd/Makefile
-@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_AFS_PARTS)  += afs.o
+@@ -15,6 +15,7 @@ obj-$(CONFIG_MTD_AFS_PARTS)  += afs.o
  obj-$(CONFIG_MTD_AR7_PARTS)   += ar7part.o
  obj-$(CONFIG_MTD_BCM63XX_PARTS)       += bcm63xxpart.o
  obj-$(CONFIG_MTD_BCM47XX_PARTS)       += bcm47xxpart.o
index 4c4720341efe4d6afb516793fe63fde85f43ad9f..46881fca2c9419c39540070df53e499715afcedb 100644 (file)
@@ -17,7 +17,7 @@
                                 u64 offset, uint32_t mask_flags)
  {
        part->name = name;
-@@ -58,6 +59,26 @@ static void bcm47xxpart_add_part(struct
+@@ -58,6 +59,26 @@ static void bcm47xxpart_add_part(struct 
        part->mask_flags = mask_flags;
  }
  
index eec90fa413600320bf79dfa000f3b018b80f0936..4f2f4e658636251b07d37fad627095dde4b7644c 100644 (file)
@@ -30,7 +30,7 @@
  /****************************************************************************/
  
  enum read_type {
-@@ -1192,7 +1198,7 @@ static int m25p_probe(struct spi_device
+@@ -1192,7 +1198,7 @@ static int m25p_probe(struct spi_device 
                flash->mtd._write = m25p80_write;
  
        /* prefer "small sector" erase if possible */
index 597adf5445506bbe7faaa3a3dc40d44af703b7c1..bf69a3509dc6ef839c2524a51a81f3117d16008d 100644 (file)
@@ -34,7 +34,7 @@
  #include <linux/err.h>
  
  #include "mtdcore.h"
-+#include "mtdsplit.h"
++#include "mtdsplit/mtdsplit.h"
  
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
index d897034abd37f82a05c773e81bd8706a4ba85b8d..0cf1c38555110040230fa5781688280df45e6eef 100644 (file)
@@ -1,13 +1,10 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_NAME
+@@ -27,6 +27,8 @@ config MTD_SPLIT_FIRMWARE_NAME
        depends on MTD_SPLIT_FIRMWARE
        default "firmware"
  
-+config MTD_SPLIT
-+      def_bool n
-+      help 
-+        Generic MTD split support.
++source "drivers/mtd/mtdsplit/Kconfig"
 +
  endmenu
  
@@ -18,7 +15,7 @@
  obj-$(CONFIG_MTD)             += mtd.o
  mtd-y                         := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
  
-+mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
++obj-$(CONFIG_MTD_SPLIT)               += mtdsplit/
 +
  obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
  obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
diff --git a/target/linux/generic/patches-3.18/404-mtd-add-more-helper-functions.patch b/target/linux/generic/patches-3.18/404-mtd-add-more-helper-functions.patch
new file mode 100644 (file)
index 0000000..d7c3801
--- /dev/null
@@ -0,0 +1,101 @@
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -445,14 +445,12 @@ static struct mtd_part *allocate_partiti
+       if (slave->offset == MTDPART_OFS_APPEND)
+               slave->offset = cur_offset;
+       if (slave->offset == MTDPART_OFS_NXTBLK) {
+-              slave->offset = cur_offset;
+-              if (mtd_mod_by_eb(cur_offset, master) != 0) {
+-                      /* Round up to next erasesize */
+-                      slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize;
++              /* Round up to next erasesize */
++              slave->offset = mtd_roundup_to_eb(cur_offset, master);
++              if (slave->offset != cur_offset)
+                       printk(KERN_NOTICE "Moving partition %d: "
+                              "0x%012llx -> 0x%012llx\n", partno,
+                              (unsigned long long)cur_offset, (unsigned long long)slave->offset);
+-              }
+       }
+       if (slave->offset == MTDPART_OFS_RETAIN) {
+               slave->offset = cur_offset;
+@@ -672,6 +670,17 @@ run_parsers_by_type(struct mtd_part *sla
+       return nr_parts;
+ }
++static inline unsigned long
++mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
++{
++      unsigned long mask = mtd->erasesize - 1;
++
++      len += offset & mask;
++      len = (len + mask) & ~mask;
++      len -= offset & mask;
++      return len;
++}
++
+ #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
+ #define SPLIT_FIRMWARE_NAME   CONFIG_MTD_SPLIT_FIRMWARE_NAME
+ #else
+@@ -913,6 +922,24 @@ int mtd_is_partition(const struct mtd_in
+ }
+ EXPORT_SYMBOL_GPL(mtd_is_partition);
++struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd)
++{
++      if (!mtd_is_partition(mtd))
++              return (struct mtd_info *)mtd;
++
++      return PART(mtd)->master;
++}
++EXPORT_SYMBOL_GPL(mtdpart_get_master);
++
++uint64_t mtdpart_get_offset(const struct mtd_info *mtd)
++{
++      if (!mtd_is_partition(mtd))
++              return 0;
++
++      return PART(mtd)->offset;
++}
++EXPORT_SYMBOL_GPL(mtdpart_get_offset);
++
+ /* Returns the size of the entire flash chip */
+ uint64_t mtd_get_device_size(const struct mtd_info *mtd)
+ {
+--- a/include/linux/mtd/partitions.h
++++ b/include/linux/mtd/partitions.h
+@@ -90,6 +90,8 @@ int mtd_is_partition(const struct mtd_in
+ int mtd_add_partition(struct mtd_info *master, const char *name,
+                     long long offset, long long length);
+ int mtd_del_partition(struct mtd_info *master, int partno);
++struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd);
++uint64_t mtdpart_get_offset(const struct mtd_info *mtd);
+ uint64_t mtd_get_device_size(const struct mtd_info *mtd);
+ extern void __weak arch_split_mtd_part(struct mtd_info *master,
+                                      const char *name, int offset, int size);
+--- a/include/linux/mtd/mtd.h
++++ b/include/linux/mtd/mtd.h
+@@ -333,6 +333,24 @@ static inline uint32_t mtd_mod_by_eb(uin
+       return do_div(sz, mtd->erasesize);
+ }
++static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd)
++{
++      if (mtd_mod_by_eb(sz, mtd) == 0)
++              return sz;
++
++      /* Round up to next erase block */
++      return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize;
++}
++
++static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd)
++{
++      if (mtd_mod_by_eb(sz, mtd) == 0)
++              return sz;
++
++      /* Round down to the start of the current erase block */
++      return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize;
++}
++
+ static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
+ {
+       if (mtd->writesize_shift)
diff --git a/target/linux/generic/patches-3.18/405-mtd-add-more-helper-functions.patch b/target/linux/generic/patches-3.18/405-mtd-add-more-helper-functions.patch
deleted file mode 100644 (file)
index d7c3801..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
---- a/drivers/mtd/mtdpart.c
-+++ b/drivers/mtd/mtdpart.c
-@@ -445,14 +445,12 @@ static struct mtd_part *allocate_partiti
-       if (slave->offset == MTDPART_OFS_APPEND)
-               slave->offset = cur_offset;
-       if (slave->offset == MTDPART_OFS_NXTBLK) {
--              slave->offset = cur_offset;
--              if (mtd_mod_by_eb(cur_offset, master) != 0) {
--                      /* Round up to next erasesize */
--                      slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize;
-+              /* Round up to next erasesize */
-+              slave->offset = mtd_roundup_to_eb(cur_offset, master);
-+              if (slave->offset != cur_offset)
-                       printk(KERN_NOTICE "Moving partition %d: "
-                              "0x%012llx -> 0x%012llx\n", partno,
-                              (unsigned long long)cur_offset, (unsigned long long)slave->offset);
--              }
-       }
-       if (slave->offset == MTDPART_OFS_RETAIN) {
-               slave->offset = cur_offset;
-@@ -672,6 +670,17 @@ run_parsers_by_type(struct mtd_part *sla
-       return nr_parts;
- }
-+static inline unsigned long
-+mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
-+{
-+      unsigned long mask = mtd->erasesize - 1;
-+
-+      len += offset & mask;
-+      len = (len + mask) & ~mask;
-+      len -= offset & mask;
-+      return len;
-+}
-+
- #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
- #define SPLIT_FIRMWARE_NAME   CONFIG_MTD_SPLIT_FIRMWARE_NAME
- #else
-@@ -913,6 +922,24 @@ int mtd_is_partition(const struct mtd_in
- }
- EXPORT_SYMBOL_GPL(mtd_is_partition);
-+struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd)
-+{
-+      if (!mtd_is_partition(mtd))
-+              return (struct mtd_info *)mtd;
-+
-+      return PART(mtd)->master;
-+}
-+EXPORT_SYMBOL_GPL(mtdpart_get_master);
-+
-+uint64_t mtdpart_get_offset(const struct mtd_info *mtd)
-+{
-+      if (!mtd_is_partition(mtd))
-+              return 0;
-+
-+      return PART(mtd)->offset;
-+}
-+EXPORT_SYMBOL_GPL(mtdpart_get_offset);
-+
- /* Returns the size of the entire flash chip */
- uint64_t mtd_get_device_size(const struct mtd_info *mtd)
- {
---- a/include/linux/mtd/partitions.h
-+++ b/include/linux/mtd/partitions.h
-@@ -90,6 +90,8 @@ int mtd_is_partition(const struct mtd_in
- int mtd_add_partition(struct mtd_info *master, const char *name,
-                     long long offset, long long length);
- int mtd_del_partition(struct mtd_info *master, int partno);
-+struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd);
-+uint64_t mtdpart_get_offset(const struct mtd_info *mtd);
- uint64_t mtd_get_device_size(const struct mtd_info *mtd);
- extern void __weak arch_split_mtd_part(struct mtd_info *master,
-                                      const char *name, int offset, int size);
---- a/include/linux/mtd/mtd.h
-+++ b/include/linux/mtd/mtd.h
-@@ -333,6 +333,24 @@ static inline uint32_t mtd_mod_by_eb(uin
-       return do_div(sz, mtd->erasesize);
- }
-+static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd)
-+{
-+      if (mtd_mod_by_eb(sz, mtd) == 0)
-+              return sz;
-+
-+      /* Round up to next erase block */
-+      return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize;
-+}
-+
-+static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd)
-+{
-+      if (mtd_mod_by_eb(sz, mtd) == 0)
-+              return sz;
-+
-+      /* Round down to the start of the current erase block */
-+      return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize;
-+}
-+
- static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
- {
-       if (mtd->writesize_shift)
diff --git a/target/linux/generic/patches-3.18/405-mtd-old-firmware-uimage-splitter.patch b/target/linux/generic/patches-3.18/405-mtd-old-firmware-uimage-splitter.patch
new file mode 100644 (file)
index 0000000..a19202a
--- /dev/null
@@ -0,0 +1,70 @@
+--- a/drivers/mtd/Kconfig
++++ b/drivers/mtd/Kconfig
+@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_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
++
+ source "drivers/mtd/mtdsplit/Kconfig"
+ endmenu
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -681,6 +681,37 @@ mtd_pad_erasesize(struct mtd_info *mtd, 
+       return len;
+ }
++#define UBOOT_MAGIC   0x27051956
++
++static void split_uimage(struct mtd_info *master, struct mtd_part *part)
++{
++      struct {
++              __be32 magic;
++              __be32 pad[2];
++              __be32 size;
++      } hdr;
++      size_t len;
++
++      if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr))
++              return;
++
++      if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC))
++              return;
++
++      len = be32_to_cpu(hdr.size) + 0x40;
++      len = mtd_pad_erasesize(master, part->offset, len);
++      if (len + master->erasesize > part->mtd.size)
++              return;
++
++      if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW))
++              pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n");
++      else
++              pr_warn("Support for built-in firmware splitter will be removed, please use CONFIG_MTD_SPLIT_UIMAGE_FW\n");
++
++      __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
+@@ -689,7 +720,14 @@ mtd_pad_erasesize(struct mtd_info *mtd, 
+ static void split_firmware(struct mtd_info *master, struct mtd_part *part)
+ {
+-      run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
++      int ret;
++
++      ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
++      if (ret > 0)
++              return;
++
++      if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
++              split_uimage(master, part);
+ }
+ void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
diff --git a/target/linux/generic/patches-3.18/406-mtd-hook-mtdsplit-into-Kbuild.patch b/target/linux/generic/patches-3.18/406-mtd-hook-mtdsplit-into-Kbuild.patch
deleted file mode 100644 (file)
index 008714b..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -27,6 +27,8 @@ config MTD_SPLIT_FIRMWARE_NAME
-       depends on MTD_SPLIT_FIRMWARE
-       default "firmware"
-+source "drivers/mtd/mtdsplit/Kconfig"
-+
- config MTD_SPLIT
-       def_bool n
-       help 
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -7,6 +7,10 @@ obj-$(CONFIG_MTD)             += mtd.o
- mtd-y                         := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
- mtd-$(CONFIG_MTD_SPLIT)               += mtdsplit.o
-+mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o
-+mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
-+mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o
-+mtd-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o
- obj-$(CONFIG_MTD_OF_PARTS)    += ofpart.o
- obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
diff --git a/target/linux/generic/patches-3.18/406-mtd-old-rootfs-squashfs-splitter.patch b/target/linux/generic/patches-3.18/406-mtd-old-rootfs-squashfs-splitter.patch
new file mode 100644 (file)
index 0000000..d48a681
--- /dev/null
@@ -0,0 +1,76 @@
+--- a/drivers/mtd/Kconfig
++++ b/drivers/mtd/Kconfig
+@@ -18,6 +18,11 @@ config MTD_ROOTFS_ROOT_DEV
+       bool "Automatically set 'rootfs' partition to be root filesystem"
+       default y
++config MTD_ROOTFS_SPLIT
++      bool "Automatically split 'rootfs' partition for squashfs"
++      select MTD_SPLIT
++      default y
++
+ config MTD_SPLIT_FIRMWARE
+       bool "Automatically split firmware partition for kernel+rootfs"
+       default y
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -681,6 +681,47 @@ mtd_pad_erasesize(struct mtd_info *mtd, 
+       return len;
+ }
++static int split_squashfs(struct mtd_info *master, int offset, int *split_offset)
++{
++      size_t squashfs_len;
++      int len, ret;
++
++      ret = mtd_get_squashfs_len(master, offset, &squashfs_len);
++      if (ret)
++              return ret;
++
++      len = mtd_pad_erasesize(master, offset, squashfs_len);
++      *split_offset = offset + len;
++
++      return 0;
++}
++
++static void split_rootfs_data(struct mtd_info *master, struct mtd_part *part)
++{
++      unsigned int split_offset = 0;
++      unsigned int split_size;
++      int ret;
++
++      ret = split_squashfs(master, part->offset, &split_offset);
++      if (ret)
++              return;
++
++      if (split_offset <= 0)
++              return;
++
++      if (config_enabled(CONFIG_MTD_SPLIT_SQUASHFS_ROOT))
++              pr_err("Dedicated partitioner didn't create \"rootfs_data\" partition, please fill a bug report!\n");
++      else
++              pr_warn("Support for built-in \"rootfs_data\" splitter will be removed, please use CONFIG_MTD_SPLIT_SQUASHFS_ROOT\n");
++
++      split_size = part->mtd.size - (split_offset - part->offset);
++      printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=0x%x, len=0x%x\n",
++              ROOTFS_SPLIT_NAME, split_offset, split_size);
++
++      __mtd_add_partition(master, ROOTFS_SPLIT_NAME, split_offset,
++                          split_size, false);
++}
++
+ #define UBOOT_MAGIC   0x27051956
+ static void split_uimage(struct mtd_info *master, struct mtd_part *part)
+@@ -743,7 +784,10 @@ static void mtd_partition_split(struct m
+               return;
+       if (!strcmp(part->mtd.name, "rootfs")) {
+-              run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
++              int num = run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
++
++              if (num <= 0 && config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
++                      split_rootfs_data(master, part);
+               rootfs_found = 1;
+       }
diff --git a/target/linux/generic/patches-3.18/407-mtd-old-firmware-uimage-splitter.patch b/target/linux/generic/patches-3.18/407-mtd-old-firmware-uimage-splitter.patch
deleted file mode 100644 (file)
index 34a4b1a..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_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
-+
- source "drivers/mtd/mtdsplit/Kconfig"
- config MTD_SPLIT
---- a/drivers/mtd/mtdpart.c
-+++ b/drivers/mtd/mtdpart.c
-@@ -681,6 +681,37 @@ mtd_pad_erasesize(struct mtd_info *mtd,
-       return len;
- }
-+#define UBOOT_MAGIC   0x27051956
-+
-+static void split_uimage(struct mtd_info *master, struct mtd_part *part)
-+{
-+      struct {
-+              __be32 magic;
-+              __be32 pad[2];
-+              __be32 size;
-+      } hdr;
-+      size_t len;
-+
-+      if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr))
-+              return;
-+
-+      if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC))
-+              return;
-+
-+      len = be32_to_cpu(hdr.size) + 0x40;
-+      len = mtd_pad_erasesize(master, part->offset, len);
-+      if (len + master->erasesize > part->mtd.size)
-+              return;
-+
-+      if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW))
-+              pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n");
-+      else
-+              pr_warn("Support for built-in firmware splitter will be removed, please use CONFIG_MTD_SPLIT_UIMAGE_FW\n");
-+
-+      __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
-@@ -689,7 +720,14 @@ mtd_pad_erasesize(struct mtd_info *mtd,
- static void split_firmware(struct mtd_info *master, struct mtd_part *part)
- {
--      run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
-+      int ret;
-+
-+      ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
-+      if (ret > 0)
-+              return;
-+
-+      if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
-+              split_uimage(master, part);
- }
- void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
diff --git a/target/linux/generic/patches-3.18/408-mtd-old-rootfs-squashfs-splitter.patch b/target/linux/generic/patches-3.18/408-mtd-old-rootfs-squashfs-splitter.patch
deleted file mode 100644 (file)
index ca81958..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -18,6 +18,11 @@ config MTD_ROOTFS_ROOT_DEV
-       bool "Automatically set 'rootfs' partition to be root filesystem"
-       default y
-+config MTD_ROOTFS_SPLIT
-+      bool "Automatically split 'rootfs' partition for squashfs"
-+      select MTD_SPLIT
-+      default y
-+
- config MTD_SPLIT_FIRMWARE
-       bool "Automatically split firmware partition for kernel+rootfs"
-       default y
---- a/drivers/mtd/mtdpart.c
-+++ b/drivers/mtd/mtdpart.c
-@@ -681,6 +681,47 @@ mtd_pad_erasesize(struct mtd_info *mtd,
-       return len;
- }
-+static int split_squashfs(struct mtd_info *master, int offset, int *split_offset)
-+{
-+      size_t squashfs_len;
-+      int len, ret;
-+
-+      ret = mtd_get_squashfs_len(master, offset, &squashfs_len);
-+      if (ret)
-+              return ret;
-+
-+      len = mtd_pad_erasesize(master, offset, squashfs_len);
-+      *split_offset = offset + len;
-+
-+      return 0;
-+}
-+
-+static void split_rootfs_data(struct mtd_info *master, struct mtd_part *part)
-+{
-+      unsigned int split_offset = 0;
-+      unsigned int split_size;
-+      int ret;
-+
-+      ret = split_squashfs(master, part->offset, &split_offset);
-+      if (ret)
-+              return;
-+
-+      if (split_offset <= 0)
-+              return;
-+
-+      if (config_enabled(CONFIG_MTD_SPLIT_SQUASHFS_ROOT))
-+              pr_err("Dedicated partitioner didn't create \"rootfs_data\" partition, please fill a bug report!\n");
-+      else
-+              pr_warn("Support for built-in \"rootfs_data\" splitter will be removed, please use CONFIG_MTD_SPLIT_SQUASHFS_ROOT\n");
-+
-+      split_size = part->mtd.size - (split_offset - part->offset);
-+      printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=0x%x, len=0x%x\n",
-+              ROOTFS_SPLIT_NAME, split_offset, split_size);
-+
-+      __mtd_add_partition(master, ROOTFS_SPLIT_NAME, split_offset,
-+                          split_size, false);
-+}
-+
- #define UBOOT_MAGIC   0x27051956
- static void split_uimage(struct mtd_info *master, struct mtd_part *part)
-@@ -743,7 +784,10 @@ static void mtd_partition_split(struct m
-               return;
-       if (!strcmp(part->mtd.name, "rootfs")) {
--              run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
-+              int num = run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
-+
-+              if (num <= 0 && config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
-+                      split_rootfs_data(master, part);
-               rootfs_found = 1;
-       }
index 4a17ccd8d6b5f2e3ed2d8798eeb77849826aa266..0bb7be08484561ea2bbc3477214704c8b1889178 100644 (file)
@@ -2,7 +2,7 @@
 +++ b/drivers/mtd/mtdpart.c
 @@ -35,6 +35,8 @@
  #include "mtdcore.h"
- #include "mtdsplit.h"
+ #include "mtdsplit/mtdsplit.h"
  
 +#define MTD_ERASE_PARTIAL     0x8000 /* partition only covers parts of an erase block */
 +
index ffc9e2199cf78b8bb63fb62d05ff435206ffa591..45af25dd61271244e899fd2293aa8051e19ca16c 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -189,6 +189,22 @@ config MTD_BCM47XX_PARTS
+@@ -184,6 +184,22 @@ config MTD_BCM47XX_PARTS
          This provides partitions parser for devices based on BCM47xx
          boards.
  
@@ -25,7 +25,7 @@
  #
 --- a/drivers/mtd/Makefile
 +++ b/drivers/mtd/Makefile
-@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_AFS_PARTS)  += afs.o
+@@ -15,6 +15,7 @@ obj-$(CONFIG_MTD_AFS_PARTS)  += afs.o
  obj-$(CONFIG_MTD_AR7_PARTS)   += ar7part.o
  obj-$(CONFIG_MTD_BCM63XX_PARTS)       += bcm63xxpart.o
  obj-$(CONFIG_MTD_BCM47XX_PARTS)       += bcm47xxpart.o
index 4c4720341efe4d6afb516793fe63fde85f43ad9f..46881fca2c9419c39540070df53e499715afcedb 100644 (file)
@@ -17,7 +17,7 @@
                                 u64 offset, uint32_t mask_flags)
  {
        part->name = name;
-@@ -58,6 +59,26 @@ static void bcm47xxpart_add_part(struct
+@@ -58,6 +59,26 @@ static void bcm47xxpart_add_part(struct 
        part->mask_flags = mask_flags;
  }
  
index 5b73d3898b42be443494b1a73a85137ed5674b6b..5345678c56498611356ca93681870b7893757837 100644 (file)
@@ -8,7 +8,7 @@
  static struct proc_dir_entry *my_proc_entry;
  
  static char *yaffs_dump_dev_part0(char *buf, struct yaffs_dev *dev)
-@@ -3398,6 +3399,7 @@ static int yaffs_proc_write(struct file
+@@ -3398,6 +3399,7 @@ static int yaffs_proc_write(struct file 
                return yaffs_proc_debug_write(file, buf, count, data);
        return yaffs_proc_write_trace_options(file, buf, count, data);
  }