diff options
author | Rafał Miłecki <rafal@milecki.pl> | 2020-02-06 13:57:11 +0100 |
---|---|---|
committer | Rafał Miłecki <rafal@milecki.pl> | 2020-02-11 16:55:38 +0100 |
commit | 15a0701cdde8eeae2a54880b813cdb8cdc09a384 (patch) | |
tree | 4769ff379de8b738fbde89ea16000e438e31ebf4 /target | |
parent | be3e98ce26da5e737744427e1d59dd1c0508edef (diff) | |
download | upstream-15a0701cdde8eeae2a54880b813cdb8cdc09a384.tar.gz upstream-15a0701cdde8eeae2a54880b813cdb8cdc09a384.tar.bz2 upstream-15a0701cdde8eeae2a54880b813cdb8cdc09a384.zip |
kernel: rewrite run_parsers_by_type() to use add_mtd_partitions()
Make run_parsers_by_type() more similar to the parse_mtd_partitions():
1. Use struct mtd_partitions
2. Use add_mtd_partitions()
This change simplifies run_parsers_by_type() by:
1. Dropping loop
2. Dropping code getting partition properties (name, offset, size)
Moreover this change allows passing more partitions details (e.g.
mask_flags).
One noticeable change introduced by this patch is adding parsed
partitions as children. This results in printing their *relative*
offsets which unifies this code with parse_mtd_partitions() behaviour.
Before:
[ 1.785448] 0x00000018f800-0x000000fb0000 : "rootfs"
[ 1.791642] mtd: device 4 (rootfs) set to be root filesystem
[ 1.797537] 1 squashfs-split partitions found on MTD device rootfs
[ 1.804009] 0x0000004e0000-0x000000fb0000 : "rootfs_data"
After:
[ 1.785376] 0x00000018f800-0x000000fb0000 : "rootfs"
[ 1.791601] mtd: device 4 (rootfs) set to be root filesystem
[ 1.797491] 1 squashfs-split partitions found on MTD device rootfs
[ 1.803936] Creating 1 MTD partitions on "rootfs":
[ 1.808910] 0x000000350800-0x000000e20800 : "rootfs_data"
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'target')
3 files changed, 15 insertions, 24 deletions
diff --git a/target/linux/generic/pending-4.14/401-mtd-add-support-for-different-partition-parser-types.patch b/target/linux/generic/pending-4.14/401-mtd-add-support-for-different-partition-parser-types.patch index 057d473684..ae13112ef6 100644 --- a/target/linux/generic/pending-4.14/401-mtd-add-support-for-different-partition-parser-types.patch +++ b/target/linux/generic/pending-4.14/401-mtd-add-support-for-different-partition-parser-types.patch @@ -20,44 +20,35 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org> /* * Given a pointer to the MTD object in the mtd_part structure, we can retrieve -@@ -762,6 +766,36 @@ int mtd_del_partition(struct mtd_info *m +@@ -762,6 +766,27 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); +static int +run_parsers_by_type(struct mtd_part *slave, enum mtd_parser_type type) +{ -+ struct mtd_partition *parts; -+ int nr_parts; -+ int i; ++ struct mtd_partitions pparts = { }; ++ int err; + -+ nr_parts = parse_mtd_partitions_by_type(&slave->mtd, type, (const struct mtd_partition **)&parts, -+ NULL); -+ if (nr_parts <= 0) -+ return nr_parts; ++ pparts.nr_parts = parse_mtd_partitions_by_type(&slave->mtd, type, ++ &pparts.parts, NULL); ++ if (pparts.nr_parts <= 0) ++ return pparts.nr_parts; + -+ if (WARN_ON(!parts)) ++ if (WARN_ON(!pparts.parts)) + return 0; + -+ for (i = 0; i < nr_parts; i++) { -+ /* adjust partition offsets */ -+ parts[i].offset += slave->offset; ++ err = add_mtd_partitions(&slave->mtd, pparts.parts, pparts.nr_parts); + -+ mtd_add_partition(slave->parent, -+ parts[i].name, -+ parts[i].offset, -+ parts[i].size); -+ } -+ -+ kfree(parts); ++ kfree(pparts.parts); + -+ return nr_parts; ++ return err ? err : pparts.nr_parts; +} + #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME #else -@@ -1147,6 +1181,61 @@ void mtd_part_parser_cleanup(struct mtd_ +@@ -1147,6 +1172,61 @@ void mtd_part_parser_cleanup(struct mtd_ } } diff --git a/target/linux/generic/pending-4.14/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch b/target/linux/generic/pending-4.14/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch index 2cc06dd463..149c328ac4 100644 --- a/target/linux/generic/pending-4.14/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch +++ b/target/linux/generic/pending-4.14/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch @@ -10,7 +10,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org> --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -804,6 +804,7 @@ run_parsers_by_type(struct mtd_part *sla +@@ -795,6 +795,7 @@ run_parsers_by_type(struct mtd_part *sla static void split_firmware(struct mtd_info *master, struct mtd_part *part) { @@ -18,7 +18,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org> } static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part) -@@ -813,6 +814,12 @@ static void mtd_partition_split(struct m +@@ -804,6 +805,12 @@ static void mtd_partition_split(struct m if (rootfs_found) return; diff --git a/target/linux/generic/pending-4.14/404-mtd-add-more-helper-functions.patch b/target/linux/generic/pending-4.14/404-mtd-add-more-helper-functions.patch index 7b481ffb47..d1a32872af 100644 --- a/target/linux/generic/pending-4.14/404-mtd-add-more-helper-functions.patch +++ b/target/linux/generic/pending-4.14/404-mtd-add-more-helper-functions.patch @@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org> --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -1260,6 +1260,24 @@ int mtd_is_partition(const struct mtd_in +@@ -1251,6 +1251,24 @@ int mtd_is_partition(const struct mtd_in } EXPORT_SYMBOL_GPL(mtd_is_partition); |