diff mbox series

[1/8] kernel: mtdsplit_uimage: read extralen from device tree

Message ID 20201125114511.26663-2-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
An "extralen" property in device tree can replace two device
specific parsers.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 .../files/drivers/mtd/mtdsplit/mtdsplit_uimage.c   | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
diff mbox series

Patch

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 281175bae74e..b31b5bdd8c53 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -76,6 +76,15 @@  read_uimage_header(struct mtd_info *mtd, size_t offset, u_char *buf,
 	return 0;
 }
 
+static void uimage_parse_dt(struct mtd_info *master, int *extralen)
+{
+	struct device_node *np = mtd_get_of_node(master);
+
+	if (!np)
+		return;
+	of_property_read_u32(np, "extralen", extralen);
+}
+
 /**
  * __mtdsplit_parse_uimage - scan partition and create kernel + rootfs parts
  *
@@ -97,7 +106,7 @@  static int __mtdsplit_parse_uimage(struct mtd_info *master,
 	size_t rootfs_size = 0;
 	int uimage_part, rf_part;
 	int ret;
-	int extralen;
+	int extralen = 0;
 	enum mtdsplit_part_type type;
 
 	nr_parts = 2;
@@ -111,6 +120,8 @@  static int __mtdsplit_parse_uimage(struct mtd_info *master,
 		goto err_free_parts;
 	}
 
+	uimage_parse_dt(master, &extralen);
+
 	/* find uImage on erase block boundaries */
 	for (offset = 0; offset < master->size; offset += master->erasesize) {
 		struct uimage_header *header;
@@ -121,7 +132,6 @@  static int __mtdsplit_parse_uimage(struct mtd_info *master,
 		if (ret)
 			continue;
 
-		extralen = 0;
 		ret = find_header(buf, MAX_HEADER_LEN, &extralen);
 		if (ret < 0) {
 			pr_debug("no valid uImage found in \"%s\" at offset %llx\n",