kernel: mtdsplit_uimage: replace "netgear, uimage" parser
authorBjørn Mork <bjorn@mork.no>
Wed, 20 Jan 2021 17:36:51 +0000 (18:36 +0100)
committerPetr Štetiar <ynezz@true.cz>
Fri, 22 Jan 2021 20:03:11 +0000 (21:03 +0100)
The "netgear,uimage" parser can be replaced by the generic
parser using device specific openwrt,ih-magic and
openwrt,ih-type properties.

Device tree properties for the following devices have not
been set, as they have been dropped from OpenWrt with the
removal of the ar71xx target:

 FW_MAGIC_WNR2000V1     0x32303031
 FW_MAGIC_WNR2000V4     0x32303034
 FW_MAGIC_WNR1000V2_VC  0x31303030
 FW_MAGIC_WPN824N       0x31313030

Tested-by: Sander Vanheule <sander@svanheule.net> # WNDR3700v2
Tested-by: Stijn Segers <foss@volatilesystems.org> # WNDR3700v1
Signed-off-by: Bjørn Mork <bjorn@mork.no>
16 files changed:
target/linux/ath79/dts/ar7161_netgear_wndr.dtsi
target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts
target/linux/ath79/dts/ar7161_netgear_wndr3700.dts
target/linux/ath79/dts/ar7161_netgear_wndr3800.dts
target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts
target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts
target/linux/ath79/dts/ar7161_netgear_wndrmac-v2.dts
target/linux/ath79/dts/ar7240_netgear_wnr1000-v2.dts
target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi
target/linux/ath79/dts/ar7241_netgear_wnr2000-v3.dts
target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts
target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts
target/linux/ath79/dts/ar7241_netgear_wnr2200.dtsi
target/linux/ath79/dts/ar9344_netgear_wndr.dtsi
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
target/linux/realtek/dts/rtl8380_netgear_gs110tpp-v1.dts

index 61097f967955afa236c8e0f1f30fec3a0a7d5c6a..217128546f91baf799ad2bfe416fe8abfa5d0f7c 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        aliases {
index 0543c471130c2d3104cedcbbd9547693894c7e77..6d78c019dac12973e4bab60f7e0f4876992d5c27 100644 (file)
@@ -22,7 +22,9 @@
        partition@70000 {
                label = "firmware";
                reg = <0x070000 0xf80000>;
-               compatible = "netgear,uimage";
+               compatible = "openwrt,uimage", "denx,uimage";
+               openwrt,ih-magic = <0x33373031>;
+               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
        };
 
        art: partition@ff0000 {
index 955dd2edf0f197c78b66874902c6b97a638e70fe..ad29d256f6d8a65ef35a647a60bd26c7eaaaa02e 100644 (file)
@@ -22,7 +22,9 @@
        partition@70000 {
                label = "firmware";
                reg = <0x070000 0x780000>;
-               compatible = "netgear,uimage";
+               compatible = "openwrt,uimage", "denx,uimage";
+               openwrt,ih-magic = <0x33373030>;
+               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
        };
 
        art: partition@7f0000 {
index 41fe401ddb01d7474c627018498e91b95250bd29..80b25492b1b71b505b7e2a76c8d2126e56c16981 100644 (file)
@@ -23,7 +23,9 @@
        partition@70000 {
                label = "firmware";
                reg = <0x070000 0xf80000>;
-               compatible = "netgear,uimage";
+               compatible = "openwrt,uimage", "denx,uimage";
+               openwrt,ih-magic = <0x33373031>;
+               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
        };
 
        art: partition@ff0000 {
index 79569adba87f065a85ded68f7ef1d6853a9c309d..cc51aca8b6369d9e0468bae2019abc0246cc3b2d 100644 (file)
@@ -23,7 +23,9 @@
        partition@70000 {
                label = "firmware";
                reg = <0x070000 0xf80000>;
-               compatible = "netgear,uimage";
+               compatible = "openwrt,uimage", "denx,uimage";
+               openwrt,ih-magic = <0x33373031>;
+               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
        };
 
        art: partition@ff0000 {
index 65d2393c67a33f01806b23f303efde7a5cc8aaf6..8604414d19982e0c2e50f981ee7c457c938910d9 100644 (file)
@@ -22,7 +22,9 @@
        partition@70000 {
                label = "firmware";
                reg = <0x070000 0xf80000>;
-               compatible = "netgear,uimage";
+               compatible = "openwrt,uimage", "denx,uimage";
+               openwrt,ih-magic = <0x33373031>;
+               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
        };
 
        art: partition@ff0000 {
index f7641203cf0101062ca7b471cee3699017b01edb..bebd96c72f09a91e8594b404d4c0de6f43557892 100644 (file)
@@ -23,7 +23,9 @@
        partition@70000 {
                label = "firmware";
                reg = <0x070000 0xf80000>;
-               compatible = "netgear,uimage";
+               compatible = "openwrt,uimage", "denx,uimage";
+               openwrt,ih-magic = <0x33373031>;
+               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
        };
 
        art: partition@ff0000 {
index d700ea73fa6241a4386ba849021bf8988c30bd8d..0c94c902848704a07880742b39a57b74eb6b5364 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        compatible = "netgear,wnr1000-v2", "qca,ar7240";
                        partition@50000 {
                                label = "firmware";
                                reg = <0x50000 0x3a0000>;
-                               compatible = "netgear,uimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <0x31303031>;
+                               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
                        };
 
                        art: partition@3f0000 {
index 382529b32d0089c337e259c15bd428644e8ad6af..036041259840ecc01f084e1fb666dd7558145e22 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        aliases {
@@ -89,7 +90,9 @@
                        };
 
                        partition@50000 {
-                               compatible = "netgear,uimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <0x32303631>;
+                               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
                                reg = <0x50000 0x3a0000>;
                                label = "firmware";
                        };
index 2e7ea746dff6739c2c7d977cec575c880166e3bf..831f3e9c2501b9c7f1b137648309e7f12fffd7e2 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        compatible = "netgear,wnr2000-v3", "qca,ar7241";
                        partition@50000 {
                                label = "firmware";
                                reg = <0x50000 0x3a0000>;
-                               compatible = "netgear,uimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <0x32303033>;
+                               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
                        };
 
                        art: partition@3f0000 {
index 2c74436547885e01c69ac055b183d47ec8ffd6d9..3842238e540eb0d56bd27351da7e3feb1ceee128 100644 (file)
@@ -22,7 +22,9 @@
        partition@50000 {
                label = "firmware";
                reg = <0x50000 0xfa0000>;
-               compatible = "netgear,uimage";
+               compatible = "openwrt,uimage", "denx,uimage";
+               openwrt,ih-magic = <0x32323030>;
+               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
        };
 
        art: partition@ff0000 {
index c23cb6e00250905a165a012e53fc8125093339a9..4eb15e23136fb9d850b0a784ea5db6be588f1ea6 100644 (file)
@@ -22,7 +22,9 @@
        partition@50000 {
                label = "firmware";
                reg = <0x50000 0x7a0000>;
-               compatible = "netgear,uimage";
+               compatible = "openwrt,uimage", "denx,uimage";
+               openwrt,ih-magic = <0x32323030>;
+               openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
        };
 
        art: partition@7f0000 {
index c61e188e3284031d8c3a2da1fb9476ec514392be..625f4b06847326d0baf80a5a8e3121f691f912f7 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        chosen {
index 26f9db5924fcd9ebe263a8edc381c59e021f6fec..ac012eafb4371d9fdf19d4533f3be5809fcd03ab 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        chosen {
                partition@6c0000 {
                        label = "firmware";
                        reg = <0x6c0000 0x1900000>;
-                       compatible = "netgear,uimage";
+                       compatible = "openwrt,uimage", "denx,uimage";
+                       openwrt,ih-magic = <0x33373033>;
+                       openwrt,ih-type = <IH_TYPE_FILESYSTEM>;
                };
 
                partition@1fc0000 {
index ef2d857abb04b1027354198d9a6c15139ab4ec74..c29eb6234bc2ab412cccb5254d98419cd8c597ad 100644 (file)
@@ -271,72 +271,6 @@ static struct mtd_part_parser uimage_generic_parser = {
        .type = MTD_PARSER_TYPE_FIRMWARE,
 };
 
-#define FW_MAGIC_GS110TPPV1    0x4e474520
-#define FW_MAGIC_WNR2000V1     0x32303031
-#define FW_MAGIC_WNR2000V3     0x32303033
-#define FW_MAGIC_WNR2000V4     0x32303034
-#define FW_MAGIC_WNR2200       0x32323030
-#define FW_MAGIC_WNR612V2      0x32303631
-#define FW_MAGIC_WNR1000V2     0x31303031
-#define FW_MAGIC_WNR1000V2_VC  0x31303030
-#define FW_MAGIC_WNDR3700      0x33373030
-#define FW_MAGIC_WNDR3700V2    0x33373031
-#define FW_MAGIC_WPN824N       0x31313030
-
-static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len, u32 ih_magic, u32 ih_type)
-{
-       struct uimage_header *header = (struct uimage_header *)buf;
-       uint8_t expected_type = IH_TYPE_FILESYSTEM;
-
-       switch (be32_to_cpu(header->ih_magic)) {
-       case FW_MAGIC_GS110TPPV1:
-       case FW_MAGIC_WNR2000V4:
-               expected_type = IH_TYPE_KERNEL;
-               break;
-       case FW_MAGIC_WNR612V2:
-       case FW_MAGIC_WNR1000V2:
-       case FW_MAGIC_WNR1000V2_VC:
-       case FW_MAGIC_WNR2000V1:
-       case FW_MAGIC_WNR2000V3:
-       case FW_MAGIC_WNR2200:
-       case FW_MAGIC_WNDR3700:
-       case FW_MAGIC_WNDR3700V2:
-       case FW_MAGIC_WPN824N:
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       if (header->ih_os != IH_OS_LINUX ||
-           header->ih_type != expected_type)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int
-mtdsplit_uimage_parse_netgear(struct mtd_info *master,
-                             const struct mtd_partition **pparts,
-                             struct mtd_part_parser_data *data)
-{
-       return __mtdsplit_parse_uimage(master, pparts, data,
-                                     uimage_verify_wndr3700);
-}
-
-static const struct of_device_id mtdsplit_uimage_netgear_of_match_table[] = {
-       { .compatible = "netgear,uimage" },
-       {},
-};
-
-static struct mtd_part_parser uimage_netgear_parser = {
-       .owner = THIS_MODULE,
-       .name = "netgear-fw",
-       .of_match_table = mtdsplit_uimage_netgear_of_match_table,
-       .parse_fn = mtdsplit_uimage_parse_netgear,
-       .type = MTD_PARSER_TYPE_FIRMWARE,
-
-};
-
 /**************************************************
  * Edimax
  **************************************************/
@@ -393,7 +327,6 @@ static struct mtd_part_parser uimage_edimax_parser = {
 static int __init mtdsplit_uimage_init(void)
 {
        register_mtd_parser(&uimage_generic_parser);
-       register_mtd_parser(&uimage_netgear_parser);
        register_mtd_parser(&uimage_edimax_parser);
 
        return 0;
index 251585a8dafbdf7b712889fb008525a42e36004d..cd9342f3f13bd890086c75f1af891dea655ec1e9 100644 (file)
@@ -70,7 +70,8 @@
                        };
                        partition@300000{
                                label = "firmware";
-                               compatible = "netgear,uimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <0x4e474520>;
                                reg = <0x0300000 0x1d00000>;
                        };
                };