Message ID | 20210120143527.14434-6-bjorn@mork.no |
---|---|
State | Changes Requested |
Headers | show |
Series | kernel: mtdsplit_uimage: use device tree properties for non-standard uimage parsing | expand |
On 20.01.2021 15:35, Bjørn Mork wrote: > 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 58c40e9ec70b..32c027d3e979 100644 > --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c > +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c > @@ -429,58 +429,6 @@ static struct mtd_part_parser uimage_edimax_parser = { > .type = MTD_PARSER_TYPE_FIRMWARE, > }; > > -/************************************************** > - * OKLI (OpenWrt Kernel Loader Image) > - **************************************************/ > - > -#define IH_MAGIC_OKLI 0x4f4b4c49 You have that magic value put directly in a few .dts files. What about moving above define to the dt-bindings/mtd/partitions/uimage.h ?
Rafał Miłecki <zajec5@gmail.com> writes: > On 20.01.2021 15:35, Bjørn Mork wrote: >> 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 58c40e9ec70b..32c027d3e979 100644 >> --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c >> +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c >> @@ -429,58 +429,6 @@ static struct mtd_part_parser uimage_edimax_parser = { >> .type = MTD_PARSER_TYPE_FIRMWARE, >> }; >> -/************************************************** >> - * OKLI (OpenWrt Kernel Loader Image) >> - **************************************************/ >> - >> -#define IH_MAGIC_OKLI 0x4f4b4c49 > > You have that magic value put directly in a few .dts files. > > What about moving above define to the dt-bindings/mtd/partitions/uimage.h ? Yes, that is probably a good idea for all the magics which are reused for a number of devices. But I do not want a situation where we have to patch uimage.h for every new Netgear device, so I think we should avoid this for the magics which are unique to only a few devices. Bjørn
On 20.01.2021 16:48, Bjørn Mork wrote: > Rafał Miłecki <zajec5@gmail.com> writes: > >> On 20.01.2021 15:35, Bjørn Mork wrote: >>> 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 58c40e9ec70b..32c027d3e979 100644 >>> --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c >>> +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c >>> @@ -429,58 +429,6 @@ static struct mtd_part_parser uimage_edimax_parser = { >>> .type = MTD_PARSER_TYPE_FIRMWARE, >>> }; >>> -/************************************************** >>> - * OKLI (OpenWrt Kernel Loader Image) >>> - **************************************************/ >>> - >>> -#define IH_MAGIC_OKLI 0x4f4b4c49 >> >> You have that magic value put directly in a few .dts files. >> >> What about moving above define to the dt-bindings/mtd/partitions/uimage.h ? > > Yes, that is probably a good idea for all the magics which are reused > for a number of devices. But I do not want a situation where we have to > patch uimage.h for every new Netgear device, so I think we should avoid > this for the magics which are unique to only a few devices. Sounds good to me!
diff --git a/target/linux/ath79/dts/ar7240_engenius_enh202-v1.dts b/target/linux/ath79/dts/ar7240_engenius_enh202-v1.dts index 1d26a9765b53..5fc8b9985e63 100644 --- a/target/linux/ath79/dts/ar7240_engenius_enh202-v1.dts +++ b/target/linux/ath79/dts/ar7240_engenius_enh202-v1.dts @@ -80,7 +80,8 @@ #size-cells = <1>; partition@0 { - compatible = "openwrt,okli"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,ih-magic = <0x4f4b4c49>; label = "firmware"; reg = <0x0 0x0>; }; diff --git a/target/linux/ath79/dts/ar7242_engenius_eap350-v1.dts b/target/linux/ath79/dts/ar7242_engenius_eap350-v1.dts index 4001897adf4d..3a207f92dbb3 100644 --- a/target/linux/ath79/dts/ar7242_engenius_eap350-v1.dts +++ b/target/linux/ath79/dts/ar7242_engenius_eap350-v1.dts @@ -59,7 +59,8 @@ #size-cells = <1>; partition@0 { - compatible = "openwrt,okli"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,ih-magic = <0x4f4b4c49>; label = "firmware"; reg = <0x0 0x0>; }; diff --git a/target/linux/ath79/dts/ar7242_engenius_ecb350-v1.dts b/target/linux/ath79/dts/ar7242_engenius_ecb350-v1.dts index e73082267c88..d41222b1edac 100644 --- a/target/linux/ath79/dts/ar7242_engenius_ecb350-v1.dts +++ b/target/linux/ath79/dts/ar7242_engenius_ecb350-v1.dts @@ -59,7 +59,8 @@ #size-cells = <1>; partition@0 { - compatible = "openwrt,okli"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,ih-magic = <0x4f4b4c49>; label = "firmware"; reg = <0x0 0x0>; }; diff --git a/target/linux/ath79/dts/ar9341_engenius_eap300-v2.dts b/target/linux/ath79/dts/ar9341_engenius_eap300-v2.dts index 3121ec0e0180..4d1f2270b832 100644 --- a/target/linux/ath79/dts/ar9341_engenius_eap300-v2.dts +++ b/target/linux/ath79/dts/ar9341_engenius_eap300-v2.dts @@ -60,7 +60,8 @@ #size-cells = <1>; partition@0 { - compatible = "openwrt,okli"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,ih-magic = <0x4f4b4c49>; label = "firmware"; reg = <0x0 0x0>; }; diff --git a/target/linux/ath79/dts/ar9341_engenius_ens202ext-v1.dts b/target/linux/ath79/dts/ar9341_engenius_ens202ext-v1.dts index 6e296ab49681..54246428e462 100644 --- a/target/linux/ath79/dts/ar9341_engenius_ens202ext-v1.dts +++ b/target/linux/ath79/dts/ar9341_engenius_ens202ext-v1.dts @@ -70,7 +70,8 @@ #size-cells = <1>; partition@0 { - compatible = "openwrt,okli"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,ih-magic = <0x4f4b4c49>; label = "firmware"; reg = <0x0 0x0>; }; diff --git a/target/linux/ath79/dts/ar9341_pisen_wmb001n.dts b/target/linux/ath79/dts/ar9341_pisen_wmb001n.dts index aaa4d1576bd2..1922887a128c 100644 --- a/target/linux/ath79/dts/ar9341_pisen_wmb001n.dts +++ b/target/linux/ath79/dts/ar9341_pisen_wmb001n.dts @@ -106,7 +106,8 @@ partition@0 { reg = <0x0 0x0>; label = "firmware"; - compatible = "openwrt,okli"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,ih-magic = <0x4f4b4c49>; }; }; }; diff --git a/target/linux/ath79/dts/ar9344_engenius_exx600.dtsi b/target/linux/ath79/dts/ar9344_engenius_exx600.dtsi index 5ae2ea66efac..989ae0949c9f 100644 --- a/target/linux/ath79/dts/ar9344_engenius_exx600.dtsi +++ b/target/linux/ath79/dts/ar9344_engenius_exx600.dtsi @@ -47,7 +47,8 @@ #size-cells = <1>; partition@0 { - compatible = "openwrt,okli"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,ih-magic = <0x4f4b4c49>; label = "firmware"; reg = <0x0 0x0>; }; diff --git a/target/linux/ath79/dts/qca9557_engenius_enstationac-v1.dts b/target/linux/ath79/dts/qca9557_engenius_enstationac-v1.dts index f9801693c57f..ed23e639a79e 100644 --- a/target/linux/ath79/dts/qca9557_engenius_enstationac-v1.dts +++ b/target/linux/ath79/dts/qca9557_engenius_enstationac-v1.dts @@ -70,7 +70,8 @@ #size-cells = <1>; partition@0 { - compatible = "openwrt,okli"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,ih-magic = <0x4f4b4c49>; label = "firmware"; reg = <0x0 0x0>; }; diff --git a/target/linux/ath79/dts/qca9558_belkin_f9x-v2.dtsi b/target/linux/ath79/dts/qca9558_belkin_f9x-v2.dtsi index af22f6681ac2..17acb6fd3211 100644 --- a/target/linux/ath79/dts/qca9558_belkin_f9x-v2.dtsi +++ b/target/linux/ath79/dts/qca9558_belkin_f9x-v2.dtsi @@ -85,7 +85,8 @@ #size-cells = <1>; partition@0 { - compatible = "openwrt,okli"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,ih-magic = <0x4f4b4c49>; label = "firmware"; reg = <0x0 0x0>; }; 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 58c40e9ec70b..32c027d3e979 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c @@ -429,58 +429,6 @@ static struct mtd_part_parser uimage_edimax_parser = { .type = MTD_PARSER_TYPE_FIRMWARE, }; -/************************************************** - * OKLI (OpenWrt Kernel Loader Image) - **************************************************/ - -#define IH_MAGIC_OKLI 0x4f4b4c49 - -static ssize_t uimage_verify_okli(u_char *buf, size_t len, u32 ih_magic) -{ - struct uimage_header *header = (struct uimage_header *)buf; - - /* default sanity checks */ - if (be32_to_cpu(header->ih_magic) != IH_MAGIC_OKLI) { - pr_debug("invalid uImage magic: %08x\n", - be32_to_cpu(header->ih_magic)); - return -EINVAL; - } - - if (header->ih_os != IH_OS_LINUX) { - pr_debug("invalid uImage OS: %08x\n", - be32_to_cpu(header->ih_os)); - return -EINVAL; - } - - if (header->ih_type != IH_TYPE_KERNEL) { - pr_debug("invalid uImage type: %08x\n", - be32_to_cpu(header->ih_type)); - return -EINVAL; - } - - return 0; -} - -static int -mtdsplit_uimage_parse_okli(struct mtd_info *master, - const struct mtd_partition **pparts, - struct mtd_part_parser_data *data) -{ - return __mtdsplit_parse_uimage(master, pparts, data, - uimage_verify_okli); -} - -static const struct of_device_id mtdsplit_uimage_okli_of_match_table[] = { - { .compatible = "openwrt,okli" }, - {}, -}; - -static struct mtd_part_parser uimage_okli_parser = { - .owner = THIS_MODULE, - .name = "okli-fw", - .of_match_table = mtdsplit_uimage_okli_of_match_table, - .parse_fn = mtdsplit_uimage_parse_okli, -}; /************************************************** * Init @@ -492,7 +440,6 @@ static int __init mtdsplit_uimage_init(void) register_mtd_parser(&uimage_netgear_parser); register_mtd_parser(&uimage_allnet_parser); register_mtd_parser(&uimage_edimax_parser); - register_mtd_parser(&uimage_okli_parser); return 0; } diff --git a/target/linux/ramips/dts/mt7620n_sunvalley_filehub.dtsi b/target/linux/ramips/dts/mt7620n_sunvalley_filehub.dtsi index beca2954dc8f..19938a48de52 100644 --- a/target/linux/ramips/dts/mt7620n_sunvalley_filehub.dtsi +++ b/target/linux/ramips/dts/mt7620n_sunvalley_filehub.dtsi @@ -31,7 +31,8 @@ #size-cells = <1>; partition@0 { - compatible = "openwrt,okli"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,ih-magic = <0x4f4b4c49>; label = "firmware"; reg = <0x0 0x0>; };