aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/hack-5.15
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/generic/hack-5.15')
-rw-r--r--target/linux/generic/hack-5.15/401-mtd-super-don-t-reply-on-mtdblock-device-minor.patch84
-rw-r--r--target/linux/generic/hack-5.15/402-mtd-blktrans-call-add-disks-after-mtd-device.patch14
-rw-r--r--target/linux/generic/hack-5.15/410-block-fit-partition-parser.patch67
-rw-r--r--target/linux/generic/hack-5.15/420-mtd-set-rootfs-to-be-root-dev.patch5
4 files changed, 23 insertions, 147 deletions
diff --git a/target/linux/generic/hack-5.15/401-mtd-super-don-t-reply-on-mtdblock-device-minor.patch b/target/linux/generic/hack-5.15/401-mtd-super-don-t-reply-on-mtdblock-device-minor.patch
deleted file mode 100644
index 8f985c0b8f..0000000000
--- a/target/linux/generic/hack-5.15/401-mtd-super-don-t-reply-on-mtdblock-device-minor.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-From f9760b158f610b1792a222cc924073724c061bfb Mon Sep 17 00:00:00 2001
-From: Daniel Golle <daniel@makrotopia.org>
-Date: Wed, 7 Apr 2021 22:37:57 +0100
-Subject: [PATCH 1/2] mtd: super: don't reply on mtdblock device minor
-To: linux-mtd@lists.infradead.org
-Cc: Vignesh Raghavendra <vigneshr@ti.com>,
- Richard Weinberger <richard@nod.at>,
- Miquel Raynal <miquel.raynal@bootlin.com>,
- David Woodhouse <dwmw2@infradead.org>
-
-For blktrans devices with partitions (ie. part_bits != 0) the
-assumption that the minor number of the mtdblock device matches
-the mtdnum doesn't hold true.
-Properly resolve mtd device from blktrans layer instead.
-
-Signed-off-by: Daniel Golle <daniel@makrotopia.org>
----
- drivers/mtd/mtdsuper.c | 33 ++++++++++++++++++++++++++-------
- 1 file changed, 26 insertions(+), 7 deletions(-)
-
---- a/drivers/mtd/mtdsuper.c
-+++ b/drivers/mtd/mtdsuper.c
-@@ -9,6 +9,7 @@
- */
-
- #include <linux/mtd/super.h>
-+#include <linux/mtd/blktrans.h>
- #include <linux/namei.h>
- #include <linux/export.h>
- #include <linux/ctype.h>
-@@ -120,8 +121,9 @@ int get_tree_mtd(struct fs_context *fc,
- struct fs_context *fc))
- {
- #ifdef CONFIG_BLOCK
-- dev_t dev;
-- int ret;
-+ struct mtd_blktrans_dev *blktrans_dev;
-+ struct block_device *bdev;
-+ int ret, part_bits;
- #endif
- int mtdnr;
-
-@@ -169,16 +171,36 @@ int get_tree_mtd(struct fs_context *fc,
- /* try the old way - the hack where we allowed users to mount
- * /dev/mtdblock$(n) but didn't actually _use_ the blockdev
- */
-- ret = lookup_bdev(fc->source, &dev);
-- if (ret) {
-+ bdev = blkdev_get_by_path(fc->source, FMODE_READ, NULL);
-+ if (IS_ERR(bdev)) {
-+ ret = PTR_ERR(bdev);
- errorf(fc, "MTD: Couldn't look up '%s': %d", fc->source, ret);
- return ret;
- }
-- pr_debug("MTDSB: lookup_bdev() returned 0\n");
-+ pr_debug("MTDSB: blkdev_get_by_path() returned 0\n");
-
-- if (MAJOR(dev) == MTD_BLOCK_MAJOR)
-- return mtd_get_sb_by_nr(fc, MINOR(dev), fill_super);
-+ if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
-+ if (!bdev->bd_disk) {
-+ blkdev_put(bdev, FMODE_READ);
-+ BUG();
-+ return -EINVAL;
-+ }
-
-+ blktrans_dev = (struct mtd_blktrans_dev *)(bdev->bd_disk->private_data);
-+ if (!blktrans_dev || !blktrans_dev->tr) {
-+ blkdev_put(bdev, FMODE_READ);
-+ BUG();
-+ return -EINVAL;
-+ }
-+ mtdnr = blktrans_dev->devnum;
-+ part_bits = blktrans_dev->tr->part_bits;
-+ blkdev_put(bdev, FMODE_READ);
-+ if (MINOR(bdev->bd_dev) != (mtdnr << part_bits))
-+ return -EINVAL;
-+
-+ return mtd_get_sb_by_nr(fc, mtdnr, fill_super);
-+ }
-+ blkdev_put(bdev, FMODE_READ);
- #endif /* CONFIG_BLOCK */
-
- if (!(fc->sb_flags & SB_SILENT))
diff --git a/target/linux/generic/hack-5.15/402-mtd-blktrans-call-add-disks-after-mtd-device.patch b/target/linux/generic/hack-5.15/402-mtd-blktrans-call-add-disks-after-mtd-device.patch
index a715d17f3b..c9821b57eb 100644
--- a/target/linux/generic/hack-5.15/402-mtd-blktrans-call-add-disks-after-mtd-device.patch
+++ b/target/linux/generic/hack-5.15/402-mtd-blktrans-call-add-disks-after-mtd-device.patch
@@ -25,7 +25,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
-@@ -457,13 +457,6 @@ int add_mtd_blktrans_dev(struct mtd_blkt
+@@ -384,13 +384,6 @@ int add_mtd_blktrans_dev(struct mtd_blkt
if (new->readonly)
set_disk_ro(gd, 1);
@@ -37,9 +37,9 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
- WARN_ON(ret);
- }
return 0;
- error4:
- kfree(new->tag_set);
-@@ -475,6 +468,27 @@ error1:
+
+ out_free_tag_set:
+@@ -402,6 +395,27 @@ out_list_del:
return ret;
}
@@ -77,9 +77,9 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
#include "mtdcore.h"
-@@ -851,6 +852,8 @@ int mtd_device_parse_register(struct mtd
- register_reboot_notifier(&mtd->reboot_notifier);
- }
+@@ -1000,6 +1001,8 @@ int mtd_device_parse_register(struct mtd
+
+ ret = mtd_otp_nvmem_add(mtd);
+ register_mtd_blktrans_devs();
+
diff --git a/target/linux/generic/hack-5.15/410-block-fit-partition-parser.patch b/target/linux/generic/hack-5.15/410-block-fit-partition-parser.patch
index b8cada98e6..65438807de 100644
--- a/target/linux/generic/hack-5.15/410-block-fit-partition-parser.patch
+++ b/target/linux/generic/hack-5.15/410-block-fit-partition-parser.patch
@@ -80,10 +80,10 @@
+#ifdef CONFIG_FIT_PARTITION
+ if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0)
-+ ROOT_DEV = part_to_dev(part)->devt;
++ ROOT_DEV = part->bd_dev;
+
+ if (state->parts[p].flags & ADDPART_FLAG_READONLY)
-+ part->policy = true;
++ set_disk_ro(disk, true);
+#endif
+
return true;
@@ -91,20 +91,8 @@
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
-@@ -396,7 +396,11 @@ int ubiblock_create(struct ubi_volume_in
-
- gd->fops = &ubiblock_ops;
- gd->major = ubiblock_major;
-+#ifdef CONFIG_FIT_PARTITION
-+ gd->minors = 0;
-+#else
- gd->minors = 1;
-+#endif
- gd->first_minor = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL);
- if (gd->first_minor < 0) {
- dev_err(disk_to_dev(gd),
@@ -413,6 +417,9 @@ int ubiblock_create(struct ubi_volume_in
- goto out_put_disk;
+ goto out_cleanup_disk;
}
gd->private_data = dev;
+#ifdef CONFIG_FIT_PARTITION
@@ -113,6 +101,18 @@
sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
set_capacity(gd, disk_capacity);
dev->gd = gd;
+--- a/drivers/mtd/mtd_blkdevs.c
++++ b/drivers/mtd/mtd_blkdevs.c
+@@ -345,6 +345,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
+ gd->first_minor = (new->devnum) << tr->part_bits;
+ gd->minors = 1 << tr->part_bits;
+ gd->fops = &mtd_block_ops;
++#ifdef CONFIG_FIT_PARTITION
++ gd->flags |= GENHD_FL_EXT_DEVT;
++#endif
+
+ if (tr->part_bits)
+ if (new->devnum < 26)
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -706,6 +706,9 @@ int efi_partition(struct parsed_partitio
@@ -149,43 +149,6 @@
typedef struct _gpt_header {
__le64 signature;
---- a/drivers/mtd/mtdblock.c
-+++ b/drivers/mtd/mtdblock.c
-@@ -334,7 +334,11 @@ static void mtdblock_remove_dev(struct m
- static struct mtd_blktrans_ops mtdblock_tr = {
- .name = "mtdblock",
- .major = MTD_BLOCK_MAJOR,
-+#ifdef CONFIG_FIT_PARTITION
-+ .part_bits = 2,
-+#else
- .part_bits = 0,
-+#endif
- .blksize = 512,
- .open = mtdblock_open,
- .flush = mtdblock_flush,
---- a/drivers/mtd/mtd_blkdevs.c
-+++ b/drivers/mtd/mtd_blkdevs.c
-@@ -407,18 +407,8 @@ int add_mtd_blktrans_dev(struct mtd_blkt
- gd->first_minor = (new->devnum) << tr->part_bits;
- gd->fops = &mtd_block_ops;
-
-- if (tr->part_bits)
-- if (new->devnum < 26)
-- snprintf(gd->disk_name, sizeof(gd->disk_name),
-- "%s%c", tr->name, 'a' + new->devnum);
-- else
-- snprintf(gd->disk_name, sizeof(gd->disk_name),
-- "%s%c%c", tr->name,
-- 'a' - 1 + new->devnum / 26,
-- 'a' + new->devnum % 26);
-- else
-- snprintf(gd->disk_name, sizeof(gd->disk_name),
-- "%s%d", tr->name, new->devnum);
-+ snprintf(gd->disk_name, sizeof(gd->disk_name),
-+ "%s%d", tr->name, new->devnum);
-
- set_capacity(gd, ((u64)new->size * tr->blksize) >> 9);
-
--- a/block/partitions/msdos.c
+++ b/block/partitions/msdos.c
@@ -563,6 +563,15 @@ static void parse_minix(struct parsed_pa
diff --git a/target/linux/generic/hack-5.15/420-mtd-set-rootfs-to-be-root-dev.patch b/target/linux/generic/hack-5.15/420-mtd-set-rootfs-to-be-root-dev.patch
index b071ac61ec..80122277e9 100644
--- a/target/linux/generic/hack-5.15/420-mtd-set-rootfs-to-be-root-dev.patch
+++ b/target/linux/generic/hack-5.15/420-mtd-set-rootfs-to-be-root-dev.patch
@@ -20,7 +20,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
#include <linux/nvmem-provider.h>
#include <linux/mtd/mtd.h>
-@@ -694,6 +695,19 @@ int add_mtd_device(struct mtd_info *mtd)
+@@ -694,6 +695,16 @@ int add_mtd_device(struct mtd_info *mtd)
of this try_ nonsense, and no bitching about it
either. :) */
__module_get(THIS_MODULE);
@@ -31,9 +31,6 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+ unsigned int index = mtd->index;
+ pr_notice("mtd: device %d (%s) set to be root filesystem\n",
+ mtd->index, mtd->name);
-+#ifdef CONFIG_FIT_PARTITION
-+ index <<= 2;
-+#endif
+ ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, index);
+ }
+