summaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2021-02-03 20:37:03 +0100
committerDaniel Golle <daniel@makrotopia.org>2021-02-28 00:46:11 +0000
commit7a6d0748247e23fe976bc400e9802db903d20b47 (patch)
treeeefdaf6630efb50e17ab5c88feaaa0cfb45ecd96 /target
parente230345bbce2f7045989ccf388fa8aa9a9e962d1 (diff)
downloadopenwrt-7a6d0748247e23fe976bc400e9802db903d20b47.tar.gz
openwrt-7a6d0748247e23fe976bc400e9802db903d20b47.tar.bz2
openwrt-7a6d0748247e23fe976bc400e9802db903d20b47.zip
kernel: add support for enabling fit firmware partition parser via cmdline
This is useful for dual-boot setups where the loader sets variables depending on the flash boot partition. For example the Linksys E8450 sets mtdparts=master for the first partition and mtdparts=slave for the second one. Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'target')
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
index 67ee33d085..5cc1658dbd 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
@@ -49,6 +49,8 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
const struct mtd_partition **pparts,
struct mtd_part_parser_data *data)
{
+ struct device_node *np = mtd_get_of_node(mtd);
+ const char *cmdline_match = NULL;
struct fdt_header hdr;
size_t hdr_len, retlen;
size_t offset;
@@ -57,6 +59,10 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
struct mtd_partition *parts;
int ret;
+ of_property_read_string(np, "openwrt,cmdline-match", &cmdline_match);
+ if (cmdline_match && !strstr(saved_command_line, cmdline_match))
+ return -ENODEV;
+
hdr_len = sizeof(struct fdt_header);
/* Parse the MTD device & search for the FIT image location */