kernel: mtdsplit_uimage: replace "openwrt, okli" parser
authorBjørn Mork <bjorn@mork.no>
Wed, 20 Jan 2021 17:36:48 +0000 (18:36 +0100)
committerPetr Štetiar <ynezz@true.cz>
Fri, 22 Jan 2021 20:03:11 +0000 (21:03 +0100)
The only difference between the "openwrt,okli" and the generic
parser is the magic.  Set this in device tree for all affected
devices and  remove the "openwrt,okli" parser.

Tested-by: Michael Pratt <mcpratt@protonmail.com> # EAP300 v2, ENS202EXT and ENH202
Signed-off-by: Bjørn Mork <bjorn@mork.no>
12 files changed:
target/linux/ath79/dts/ar7240_engenius_enh202-v1.dts
target/linux/ath79/dts/ar7242_engenius_eap350-v1.dts
target/linux/ath79/dts/ar7242_engenius_ecb350-v1.dts
target/linux/ath79/dts/ar9341_engenius_eap300-v2.dts
target/linux/ath79/dts/ar9341_engenius_ens202ext-v1.dts
target/linux/ath79/dts/ar9341_pisen_wmb001n.dts
target/linux/ath79/dts/ar9344_engenius_exx600.dtsi
target/linux/ath79/dts/qca9557_engenius_enstationac-v1.dts
target/linux/ath79/dts/qca9558_belkin_f9x-v2.dtsi
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
target/linux/generic/files/include/dt-bindings/mtd/partitions/uimage.h
target/linux/ramips/dts/mt7620n_sunvalley_filehub.dtsi

index 1d26a9765b53264e1d40790328f2f1bc64250a18..7c819e88e7966d60f9d0ee53a6fb379f0c67ec92 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 = "engenius,enh202-v1", "qca,ar7240";
@@ -80,7 +81,8 @@
                        #size-cells = <1>;
 
                        partition@0 {
-                               compatible = "openwrt,okli";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
                                label = "firmware";
                                reg = <0x0 0x0>;
                        };
index 4001897adf4d19b0df169deda0508684430d7a7b..39a8a7f25f8cf4385aaf54d65a6b1835b30e1929 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 = "engenius,eap350-v1", "qca,ar7242";
@@ -59,7 +60,8 @@
                        #size-cells = <1>;
 
                        partition@0 {
-                               compatible = "openwrt,okli";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
                                label = "firmware";
                                reg = <0x0 0x0>;
                        };
index e73082267c882e2fd69f4eee13b200921263463e..0e06ee0128fb1b2ff7e53bb481de788616d5fd61 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 = "engenius,ecb350-v1", "qca,ar7242";
@@ -59,7 +60,8 @@
                        #size-cells = <1>;
 
                        partition@0 {
-                               compatible = "openwrt,okli";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
                                label = "firmware";
                                reg = <0x0 0x0>;
                        };
index 3121ec0e0180c9dfcb7bea0c569dbd19e96a33cc..7aa89a4cce5c111138b3d7a2cc7a8c3242e272ae 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>
 
 / {
        model = "Engenius EAP300 v2";
@@ -60,7 +61,8 @@
                        #size-cells = <1>;
 
                        partition@0 {
-                               compatible = "openwrt,okli";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
                                label = "firmware";
                                reg = <0x0 0x0>;
                        };
index 6e296ab49681e7bae9ab1ad4b74da36909fe028a..38e9b381c0d8af67df70320a456b3f31f8bad30e 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>
 
 / {
        model = "Engenius ENS202EXT v1";
@@ -70,7 +71,8 @@
                        #size-cells = <1>;
 
                        partition@0 {
-                               compatible = "openwrt,okli";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
                                label = "firmware";
                                reg = <0x0 0x0>;
                        };
index aaa4d1576bd2fe4565591700d314c26a29609315..98236d44a6835010bf1edb287bc4a5785376d77c 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>
 
 / {
        model = "PISEN WMB001N";
                        partition@0 {
                                reg = <0x0 0x0>;
                                label = "firmware";
-                               compatible = "openwrt,okli";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
                        };
                };
        };
index 5ae2ea66efac0a9edea1a6c120b1ccb8e334e80d..340357b8deb2c867a50fdea7cb3d5ce6dcf4fbfd 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 {
@@ -47,7 +48,8 @@
                        #size-cells = <1>;
 
                        partition@0 {
-                               compatible = "openwrt,okli";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
                                label = "firmware";
                                reg = <0x0 0x0>;
                        };
index f9801693c57f7da6a3206ddabc8427fc355b2514..2cf800cddc4c72817492987438b0faef9981edcd 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 = "engenius,enstationac-v1", "qca,qca9557";
@@ -70,7 +71,8 @@
                        #size-cells = <1>;
 
                        partition@0 {
-                               compatible = "openwrt,okli";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
                                label = "firmware";
                                reg = <0x0 0x0>;
                        };
index af22f6681ac235d5bf1c04619600e5793ddeee4b..624e20096f2062711c88602b0685933b60d20105 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 {
@@ -85,7 +86,8 @@
                        #size-cells = <1>;
 
                        partition@0 {
-                               compatible = "openwrt,okli";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
                                label = "firmware";
                                reg = <0x0 0x0>;
                        };
index 58c40e9ec70b5a88452a119c0ad13795a13be443..32c027d3e9795853c5f482f815032713c0fae4da 100644 (file)
@@ -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;
 }
index 29eec38dd2821939e5e1a24677b0550039a838ac..407e46ce2c46e917e53f4f2836f6efddc28ff482 100644 (file)
 #define IH_MAGIC       0x27051956      /* Image Magic Number           */
 #define IH_NMLEN               32      /* Image Name Length            */
 
+/*
+ * Magic values specific to "openwrt,uimage" partitions
+ */
+#define IH_MAGIC_OKLI  0x4f4b4c49      /* 'OKLI'                       */
+
 #endif /* __UIMAGE_H__ */
index beca2954dc8f6ba2154bd3e9ca2a78c61c0845aa..20ff2dbd1c3db91e900e47da72e0d8b8965e01bb 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 {
@@ -31,7 +32,8 @@
                        #size-cells = <1>;
 
                        partition@0 {
-                               compatible = "openwrt,okli";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
                                label = "firmware";
                                reg = <0x0 0x0>;
                        };