diff options
author | NOGUCHI Hiroshi <drvlabo@gmail.com> | 2019-08-03 19:46:10 +0900 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2019-08-04 22:09:20 +0200 |
commit | e92a14709d37f64dcba8c81fa51e61e5f10f439a (patch) | |
tree | 8732924a4c8af070c8d7f9f6259f999bf5264a29 /target/linux/generic/files | |
parent | ea1acaf5a697a3b3e0cd5c778d2c3930d7d6812b (diff) | |
download | upstream-e92a14709d37f64dcba8c81fa51e61e5f10f439a.tar.gz upstream-e92a14709d37f64dcba8c81fa51e61e5f10f439a.tar.bz2 upstream-e92a14709d37f64dcba8c81fa51e61e5f10f439a.zip |
kernel: generic: fix fonfxc uimage parser
We cannot distinguish between fonfxc uImage and generic uImage because
fonfxc uImage header is almost same as generic uImage, except padding
length after image name.
The fonfxc uImage parser is available when specifying directly with DT
compatible property. So this patch adds check if the partition DT node
is compatible with the parser.
Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2413
Fixes: a1c6a316d299 ("ramips: add support for Fon FON2601")
Signed-off-by: NOGUCHI Hiroshi <drvlabo@gmail.com>
[commit light touches and removed C code comment]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'target/linux/generic/files')
-rw-r--r-- | target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c index 091403ae91..2ac559a3f3 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c @@ -398,22 +398,29 @@ static ssize_t uimage_find_fonfxc(u_char *buf, size_t len, int *extralen) return 0; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) +static const struct of_device_id mtdsplit_uimage_fonfxc_of_match_table[] = { + { .compatible = "fonfxc,uimage" }, + {}, +}; +#endif + static int mtdsplit_uimage_parse_fonfxc(struct mtd_info *master, const struct mtd_partition **pparts, struct mtd_part_parser_data *data) { + struct device_node *np_mtd; + + np_mtd = mtd_get_of_node(master); + if (!np_mtd || + !of_match_node(mtdsplit_uimage_fonfxc_of_match_table, np_mtd)) + return -ENODEV; + return __mtdsplit_parse_uimage(master, pparts, data, uimage_find_fonfxc); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) -static const struct of_device_id mtdsplit_uimage_fonfxc_of_match_table[] = { - { .compatible = "fonfxc,uimage" }, - {}, -}; -#endif - static struct mtd_part_parser uimage_fonfxc_parser = { .owner = THIS_MODULE, .name = "fonfxc-fw", |