mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
generic: 5.15: get uImage.FIT partition parser ready
Prepare uImage.FIT partition parser for Linux 5.15 Signed-off-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
This commit is contained in:
parent
967902aff5
commit
a4a0faa748
@ -20,6 +20,7 @@
|
|||||||
#include <linux/of_device.h>
|
#include <linux/of_device.h>
|
||||||
#include <linux/of_fdt.h>
|
#include <linux/of_fdt.h>
|
||||||
#include <linux/libfdt.h>
|
#include <linux/libfdt.h>
|
||||||
|
#include <linux/version.h>
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
|
|
||||||
@ -72,7 +73,12 @@
|
|||||||
|
|
||||||
int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector, u64 sectors, int *slot, int add_remain)
|
int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector, u64 sectors, int *slot, int add_remain)
|
||||||
{
|
{
|
||||||
struct address_space *mapping = state->bdev->bd_inode->i_mapping;
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
|
||||||
|
struct block_device *bdev = state->disk->part0;
|
||||||
|
#else
|
||||||
|
struct block_device *bdev = state->bdev;
|
||||||
|
#endif
|
||||||
|
struct address_space *mapping = bdev->bd_inode->i_mapping;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
void *fit, *init_fit;
|
void *fit, *init_fit;
|
||||||
struct partition_meta_info *info;
|
struct partition_meta_info *info;
|
||||||
@ -107,7 +113,7 @@ int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dsectors = get_capacity(state->bdev->bd_disk);
|
dsectors = get_capacity(bdev->bd_disk);
|
||||||
if (sectors)
|
if (sectors)
|
||||||
dsectors = (dsectors>sectors)?sectors:dsectors;
|
dsectors = (dsectors>sectors)?sectors:dsectors;
|
||||||
|
|
||||||
|
@ -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))
|
|
@ -98,30 +98,6 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
--- a/drivers/mtd/ubi/block.c
|
|
||||||
+++ b/drivers/mtd/ubi/block.c
|
|
||||||
@@ -428,6 +428,9 @@ int ubiblock_create(struct ubi_volume_in
|
|
||||||
goto out_cleanup_disk;
|
|
||||||
}
|
|
||||||
gd->private_data = dev;
|
|
||||||
+#ifdef CONFIG_FIT_PARTITION
|
|
||||||
+ gd->flags |= GENHD_FL_EXT_DEVT;
|
|
||||||
+#endif
|
|
||||||
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_blkt
|
|
||||||
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
|
--- a/block/partitions/efi.c
|
||||||
+++ b/block/partitions/efi.c
|
+++ b/block/partitions/efi.c
|
||||||
@@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitio
|
@@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitio
|
||||||
@ -184,6 +160,29 @@
|
|||||||
{0, NULL},
|
{0, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
--- a/drivers/mtd/mtd_blkdevs.c
|
||||||
|
+++ b/drivers/mtd/mtd_blkdevs.c
|
||||||
|
@@ -345,6 +345,8 @@ int add_mtd_blktrans_dev(struct mtd_blkt
|
||||||
|
gd->first_minor = (new->devnum) << tr->part_bits;
|
||||||
|
gd->minors = 1 << tr->part_bits;
|
||||||
|
gd->fops = &mtd_block_ops;
|
||||||
|
+ if (IS_ENABLED(CONFIG_FIT_PARTITION) && !mtd_type_is_nand(new->mtd))
|
||||||
|
+ gd->flags |= GENHD_FL_EXT_DEVT;
|
||||||
|
|
||||||
|
if (tr->part_bits)
|
||||||
|
if (new->devnum < 26)
|
||||||
|
--- a/drivers/mtd/ubi/block.c
|
||||||
|
+++ b/drivers/mtd/ubi/block.c
|
||||||
|
@@ -428,6 +428,9 @@ int ubiblock_create(struct ubi_volume_in
|
||||||
|
goto out_cleanup_disk;
|
||||||
|
}
|
||||||
|
gd->private_data = dev;
|
||||||
|
+#ifdef CONFIG_FIT_PARTITION
|
||||||
|
+ gd->flags |= GENHD_FL_EXT_DEVT;
|
||||||
|
+#endif
|
||||||
|
sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
|
||||||
|
set_capacity(gd, disk_capacity);
|
||||||
|
dev->gd = gd;
|
||||||
--- a/include/linux/msdos_partition.h
|
--- a/include/linux/msdos_partition.h
|
||||||
+++ b/include/linux/msdos_partition.h
|
+++ b/include/linux/msdos_partition.h
|
||||||
@@ -31,6 +31,7 @@ enum msdos_sys_ind {
|
@@ -31,6 +31,7 @@ enum msdos_sys_ind {
|
||||||
|
Loading…
Reference in New Issue
Block a user