diff mbox series

[7/8] kernel: mtdsplit_uimage: replace "netgear,uimage" parser

Message ID 20201125114511.26663-8-bjorn@mork.no
State Superseded
Delegated to: Petr Štetiar
Headers show
Series kernel: mtdsplit_uimage: use device tree properties for non-standard uimage parsing | expand

Commit Message

Bjørn Mork Nov. 25, 2020, 11:45 a.m. UTC
The "netgear,uimage" parser can be replaced by the generic
parser using device specific ih-magic and 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

Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 .../ath79/dts/ar7161_netgear_wndr3700-v2.dts  |  4 +-
 .../ath79/dts/ar7161_netgear_wndr3700.dts     |  4 +-
 .../ath79/dts/ar7161_netgear_wndr3800.dts     |  4 +-
 .../ath79/dts/ar7161_netgear_wndr3800ch.dts   |  4 +-
 .../ath79/dts/ar7161_netgear_wndrmac-v1.dts   |  4 +-
 .../ath79/dts/ar7161_netgear_wndrmac-v2.dts   |  4 +-
 .../ath79/dts/ar7240_netgear_wnr1000-v2.dts   |  4 +-
 .../ath79/dts/ar7240_netgear_wnr612-v2.dtsi   |  4 +-
 .../ath79/dts/ar7241_netgear_wnr2000-v3.dts   |  4 +-
 .../ath79/dts/ar7241_netgear_wnr2200-16m.dts  |  4 +-
 .../ath79/dts/ar7241_netgear_wnr2200-8m.dts   |  4 +-
 .../linux/ath79/dts/ar9344_netgear_wndr.dtsi  |  4 +-
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c    | 66 -------------------
 13 files changed, 36 insertions(+), 78 deletions(-)
diff mbox series

Patch

diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts b/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts
index 0543c471130c..70445b080907 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts
@@ -22,7 +22,9 @@ 
 	partition@70000 {
 		label = "firmware";
 		reg = <0x070000 0xf80000>;
-		compatible = "netgear,uimage";
+		compatible = "denx,uimage";
+		ih-magic = <0x33373031>;
+		ih-type = <7>;
 	};
 
 	art: partition@ff0000 {
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts b/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts
index 955dd2edf0f1..5d89cf5a2bd7 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts
@@ -22,7 +22,9 @@ 
 	partition@70000 {
 		label = "firmware";
 		reg = <0x070000 0x780000>;
-		compatible = "netgear,uimage";
+		compatible = "denx,uimage";
+		ih-magic = <0x33373030>;
+		ih-type = <7>;
 	};
 
 	art: partition@7f0000 {
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts b/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts
index 41fe401ddb01..387374f1769a 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts
@@ -23,7 +23,9 @@ 
 	partition@70000 {
 		label = "firmware";
 		reg = <0x070000 0xf80000>;
-		compatible = "netgear,uimage";
+		compatible = "denx,uimage";
+		ih-magic = <0x33373031>;
+		ih-type = <7>;
 	};
 
 	art: partition@ff0000 {
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts b/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts
index 79569adba87f..d31e98c21c11 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts
@@ -23,7 +23,9 @@ 
 	partition@70000 {
 		label = "firmware";
 		reg = <0x070000 0xf80000>;
-		compatible = "netgear,uimage";
+		compatible = "denx,uimage";
+		ih-magic = <0x33373031>;
+		ih-type = <7>;
 	};
 
 	art: partition@ff0000 {
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts b/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts
index 65d2393c67a3..9cda726b33ae 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts
@@ -22,7 +22,9 @@ 
 	partition@70000 {
 		label = "firmware";
 		reg = <0x070000 0xf80000>;
-		compatible = "netgear,uimage";
+		compatible = "denx,uimage";
+		ih-magic = <0x33373031>;
+		ih-type = <7>;
 	};
 
 	art: partition@ff0000 {
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndrmac-v2.dts b/target/linux/ath79/dts/ar7161_netgear_wndrmac-v2.dts
index f7641203cf01..b0b111ff623f 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndrmac-v2.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndrmac-v2.dts
@@ -23,7 +23,9 @@ 
 	partition@70000 {
 		label = "firmware";
 		reg = <0x070000 0xf80000>;
-		compatible = "netgear,uimage";
+		compatible = "denx,uimage";
+		ih-magic = <0x33373031>;
+		ih-type = <7>;
 	};
 
 	art: partition@ff0000 {
diff --git a/target/linux/ath79/dts/ar7240_netgear_wnr1000-v2.dts b/target/linux/ath79/dts/ar7240_netgear_wnr1000-v2.dts
index d67af04d1cbd..4d6076a68a77 100644
--- a/target/linux/ath79/dts/ar7240_netgear_wnr1000-v2.dts
+++ b/target/linux/ath79/dts/ar7240_netgear_wnr1000-v2.dts
@@ -160,7 +160,9 @@ 
 			partition@50000 {
 				label = "firmware";
 				reg = <0x50000 0x3a0000>;
-				compatible = "netgear,uimage";
+				compatible = "denx,uimage";
+				ih-magic = <0x31303031>;
+				ih-type = <7>;
 			};
 
 			art: partition@3f0000 {
diff --git a/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi b/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi
index 44dbe9c55ec7..a419ef152968 100644
--- a/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi
+++ b/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi
@@ -91,7 +91,9 @@ 
 			};
 
 			partition@50000 {
-				compatible = "netgear,uimage";
+				compatible = "denx,uimage";
+				ih-magic = <0x32303631>;
+				ih-type = <7>;
 				reg = <0x50000 0x3a0000>;
 				label = "firmware";
 			};
diff --git a/target/linux/ath79/dts/ar7241_netgear_wnr2000-v3.dts b/target/linux/ath79/dts/ar7241_netgear_wnr2000-v3.dts
index 1b124f3f2e6b..ef04190182a3 100644
--- a/target/linux/ath79/dts/ar7241_netgear_wnr2000-v3.dts
+++ b/target/linux/ath79/dts/ar7241_netgear_wnr2000-v3.dts
@@ -163,7 +163,9 @@ 
 			partition@50000 {
 				label = "firmware";
 				reg = <0x50000 0x3a0000>;
-				compatible = "netgear,uimage";
+				compatible = "denx,uimage";
+				ih-magic = <0x32303033>;
+				ih-type = <7>;
 			};
 
 			art: partition@3f0000 {
diff --git a/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts b/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts
index 2c7443654788..822bd27b69e1 100644
--- a/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts
+++ b/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts
@@ -22,7 +22,9 @@ 
 	partition@50000 {
 		label = "firmware";
 		reg = <0x50000 0xfa0000>;
-		compatible = "netgear,uimage";
+		compatible = "denx,uimage";
+		ih-magic = <0x32323030>;
+		ih-type = <7>;
 	};
 
 	art: partition@ff0000 {
diff --git a/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts b/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts
index c23cb6e00250..628fd8f4957e 100644
--- a/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts
+++ b/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts
@@ -22,7 +22,9 @@ 
 	partition@50000 {
 		label = "firmware";
 		reg = <0x50000 0x7a0000>;
-		compatible = "netgear,uimage";
+		compatible = "denx,uimage";
+		ih-magic = <0x32323030>;
+		ih-type = <7>;
 	};
 
 	art: partition@7f0000 {
diff --git a/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi b/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi
index 92b0beccd7c9..e594faa98427 100644
--- a/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi
+++ b/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi
@@ -161,7 +161,9 @@ 
 		partition@6c0000 {
 			label = "firmware";
 			reg = <0x6c0000 0x1900000>;
-			compatible = "netgear,uimage";
+			compatible = "denx,uimage";
+			ih-magic = <0x33373033>;
+			ih-type = <7>;
 		};
 
 		partition@1fc0000 {
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 8b07b35d9bd5..20aae10a0a2a 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -34,7 +34,6 @@ 
 #define IH_OS_LINUX		5	/* Linux	*/
 
 #define IH_TYPE_KERNEL		2	/* OS Kernel Image		*/
-#define IH_TYPE_FILESYSTEM	7	/* Filesystem Image		*/
 
 /*
  * Legacy format image header,
@@ -276,70 +275,6 @@  static struct mtd_part_parser uimage_generic_parser = {
 	.type = MTD_PARSER_TYPE_FIRMWARE,
 };
 
-#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_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;
-	case FW_MAGIC_WNR2000V4:
-		expected_type = IH_TYPE_KERNEL;
-		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
  **************************************************/
@@ -396,7 +331,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;