mediatek: patch block2mtd to allow cmdlineparts to work
authorJohn Crispin <john@openwrt.org>
Wed, 23 Mar 2016 11:12:34 +0000 (11:12 +0000)
committerJohn Crispin <john@openwrt.org>
Wed, 23 Mar 2016 11:12:34 +0000 (11:12 +0000)
Signed-off-by: John Crispin <blogic@openwrt.org>
SVN-Revision: 49067

target/linux/mediatek/config-4.4
target/linux/mediatek/patches-4.4/0100-block2mtd.patch [new file with mode: 0644]

index 259e65cb36ba55498178862cc5427628a188d51d..f9d5d0676505c1c579c8fdfac6637f69863a5c81 100644 (file)
@@ -56,7 +56,7 @@ CONFIG_CLKSRC_MMIO=y
 CONFIG_CLKSRC_OF=y
 CONFIG_CLKSRC_PROBE=y
 CONFIG_CLONE_BACKWARDS=y
-CONFIG_CMDLINE="earlyprintk console=ttyS0,115200 block2mtd=/dev/mmcblk0,65536,eMMC,5 mtdparts=eMMC:256k(mbr),512k(uboot),256k(config),256k(factory),32M(bootimg),32M(recovery),1024M(rootfs),2048M(usrdata),-(bmtpool)"
+CONFIG_CMDLINE="earlyprintk console=ttyS0,115200 block2mtd.block2mtd=/dev/mmcblk0,65536,eMMC,5 mtdparts=eMMC:256k(mbr)ro,512k(uboot)ro,256k(config)ro,256k(factory)ro,32M(bootimg),32M(recovery),1024M(rootfs),2048M(usrdata),-(bmtpool)"
 CONFIG_CMDLINE_FORCE=y
 CONFIG_COMMON_CLK=y
 CONFIG_COMMON_CLK_MEDIATEK=y
@@ -279,6 +279,7 @@ CONFIG_MMC_SDHCI_PLTFM=y
 # CONFIG_MMC_TIFM_SD is not set
 CONFIG_MODULES_USE_ELF_REL=y
 CONFIG_MTD_BLOCK2MTD=y
+CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_M25P80=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTK_INFRACFG=y
diff --git a/target/linux/mediatek/patches-4.4/0100-block2mtd.patch b/target/linux/mediatek/patches-4.4/0100-block2mtd.patch
new file mode 100644 (file)
index 0000000..7fbd6d4
--- /dev/null
@@ -0,0 +1,32 @@
+--- a/drivers/mtd/devices/block2mtd.c
++++ b/drivers/mtd/devices/block2mtd.c
+@@ -32,6 +32,8 @@
+ #include <linux/slab.h>
+ #include <linux/major.h>
++static const char * const block2mtd_probe_types[] = { "cmdlinepart", NULL };
++
+ /* Info for the block device */
+ struct block2mtd_dev {
+       struct list_head list;
+@@ -227,6 +229,7 @@
+ #endif
+       const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
+       struct block_device *bdev = ERR_PTR(-ENODEV);
++      struct mtd_part_parser_data ppdata = { 0 };
+       struct block2mtd_dev *dev;
+       struct mtd_partition *part;
+       char *name;
+@@ -307,11 +310,7 @@
+       dev->mtd.priv = dev;
+       dev->mtd.owner = THIS_MODULE;
+-      part = kzalloc(sizeof(struct mtd_partition), GFP_KERNEL);
+-      part->name = name;
+-      part->offset = 0;
+-      part->size = dev->mtd.size;
+-      if (mtd_device_register(&dev->mtd, part, 1)) {
++      if (mtd_device_parse_register(&dev->mtd, block2mtd_probe_types, &ppdata, NULL, 0)) {
+               /* Device didn't get added, so free the entry */
+               goto err_destroy_mutex;
+       }