[PATCH] mtd: parsers: ofpart: allow 0xff size cells to denote 'rest-of-flash'

Alexander Vickberg wickbergster at gmail.com
Wed Jun 15 01:27:41 PDT 2022


In cmdlinepart it's possible to use '-' as partition size to denote rest of
available flash size. This patch brings this functionality to ofpart. If all
size cells are set to all 0xff's ofpart will use rest of available flash size.

Signed-off-by: Alexander Vickberg <wickbergster at gmail.com>
---
 drivers/mtd/parsers/ofpart_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/parsers/ofpart_core.c b/drivers/mtd/parsers/ofpart_core.c
index 192190c42fc8..33372ba018d8 100644
--- a/drivers/mtd/parsers/ofpart_core.c
+++ b/drivers/mtd/parsers/ofpart_core.c
@@ -133,6 +133,9 @@ static int parse_fixed_partitions(struct mtd_info *master,
 		parts[i].size = of_read_number(reg + a_cells, s_cells);
 		parts[i].of_node = pp;
 
+		if (!memchr_inv(reg + a_cells, 0xff, s_cells<<2))
+			parts[i].size = master->size - parts[i].offset;
+
 		partname = of_get_property(pp, "label", &len);
 		if (!partname)
 			partname = of_get_property(pp, "name", &len);
-- 
2.34.1




More information about the linux-mtd mailing list