Skip to contentSkip to conversation

mtd: mtdpart: Support MTDPART_SIZ_FULL in fixed-partitions

PATCH In review Mike Looijmans 3 participants 4 messages Apr 8, 2025 – May 1, 2025 1 message not in the archive Memory technology devices (MTD)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.bc83124b-b53b-4cfa-9911-d8ca2185a06f@emailsignatures365.codetwo.com

#1 lore raw

PATCH v2 1/1 mtd: mtdpart: Support MTDPART_SIZ_FULL in fixed-partitions

Flash partitions may specify MTDPART_SIZ_FULL (=0) as the size of the partition to indicate "the remainder of the flash". Make this work with device-tree "fixed-partitions" as well.

This makes MTD partitioning compatible with the Linux kernel, see:
https://github.com/torvalds/linux/blob/master/include/linux/mtd/partitions.h#L29
https://github.com/torvalds/linux/blob/master/drivers/mtd/mtdpart.c#L123

Previously, this could only be done through MTDPARTS so this change allows boards like topic_miami to migrate from mtdparts/mtdids to devicetree partitions.

---

Changes in v2:
Amend commit text to add links to Linux code and explain the rationale

 drivers/mtd/mtdpart.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/mtdpart.c +4 -2
index 88094b81e7a..5284890bd88 100644
@@ -910,11 +910,13 @@ int add_mtd_partitions_of(struct mtd_info *master)
 			continue;
 
 		offset = ofnode_get_addr_size_index_notrans(child, 0, &size);
-		if (offset == FDT_ADDR_T_NONE || !size) {
-			debug("Missing partition offset/size on \"%s\" partition\n",
+		if (offset == FDT_ADDR_T_NONE) {
+			debug("Missing partition offset on \"%s\" partition\n",
 			      master->name);
 			continue;
 		}
+		if (size == MTDPART_SIZ_FULL)
+			size = master->size - offset;
 
 		part.name = ofnode_read_string(child, "label");
 		if (!part.name)
Signature · 18 lines
2.43.0


Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert


TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: [email protected]
W: www.topic.nl

Please consider the environment before printing this e-mail
Reviewed-by on v2 1/1
#2 lore raw

Hi

Quoted 43 lines · Mike Looijmans

Flash partitions may specify MTDPART_SIZ_FULL (=0) as the size of the partition to indicate "the remainder of the flash". Make this work with device-tree "fixed-partitions" as well.

This makes MTD partitioning compatible with the Linux kernel, see:

https://github.com/torvalds/linux/blob/master/include/linux/mtd/partitions.h#L29
https://github.com/torvalds/linux/blob/master/drivers/mtd/mtdpart.c#L123

Previously, this could only be done through MTDPARTS so this change allows boards like topic_miami to migrate from mtdparts/mtdids to devicetree partitions.

---

Changes in v2:
Amend commit text to add links to Linux code and explain the rationale

 drivers/mtd/mtdpart.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/mtdpart.c +4 -2
index 88094b81e7a..5284890bd88 100644
@@ -910,11 +910,13 @@ int add_mtd_partitions_of(struct mtd_info *master)
                        continue;
 
                offset = ofnode_get_addr_size_index_notrans(child, 0,
 &size);
-               if (offset == FDT_ADDR_T_NONE || !size) {
-                       debug("Missing partition offset/size on \"%s\"
 partition\n",
+               if (offset == FDT_ADDR_T_NONE) {
+                       debug("Missing partition offset on \"%s\"
 partition\n",
                              master->name);
                        continue;
                }
+               if (size == MTDPART_SIZ_FULL)
+                       size = master->size - offset;
Quoted 7 lines
                part.name = ofnode_read_string(child, "label");
                if (!part.name)

--
2.43.0

Quoted 16 lines

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: [email protected]
W: www.topic.nl

Please consider the environment before printing this e-mail

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
author Reviewed-by Michael Trimarchi
#3 lore raw

Gentle ping, anything blocking this?

On 08-04-2025 12:31, Michael Nazzareno Trimarchi wrote:
Hi

On Tue, Apr 8, 2025 at 7:46 AM Mike Looijmans <[email protected]<mailto:[email protected]>> wrote:
Flash partitions may specify MTDPART_SIZ_FULL (=0) as the size of the
partition to indicate "the remainder of the flash". Make this work with
device-tree "fixed-partitions" as well.

This makes MTD partitioning compatible with the Linux kernel, see:
https://github.com/torvalds/linux/blob/master/include/linux/mtd/partitions.h#L29
https://github.com/torvalds/linux/blob/master/drivers/mtd/mtdpart.c#L123

Previously, this could only be done through MTDPARTS so this change allows boards like topic_miami to migrate from mtdparts/mtdids to devicetree partitions.

---

Changes in v2:
Amend commit text to add links to Linux code and explain the rationale

drivers/mtd/mtdpart.c | 6 ++++--

1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/mtdpart.c +4 -2
index 88094b81e7a..5284890bd88 100644
@@ -910,11 +910,13 @@ int add_mtd_partitions_of(struct mtd_info *master)
                       continue;
 
               offset = ofnode_get_addr_size_index_notrans(child, 0, &size);
-               if (offset == FDT_ADDR_T_NONE || !size) {
-                       debug("Missing partition offset/size on \"%s\" partition\n",
+               if (offset == FDT_ADDR_T_NONE) {
+                       debug("Missing partition offset on \"%s\" partition\n",
                             master->name);
                       continue;
               }
+               if (size == MTDPART_SIZ_FULL)
+                       size = master->size - offset;
 
               part.name<http://part.name> = ofnode_read_string(child, "label");
               if (!part.name<http://part.name>)

--
2.43.0

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: [email protected]<mailto:[email protected]>
W: www.topic.nl<http://www.topic.nl>

Please consider the environment before printing this e-mail

--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170 [email protected]<mailto:[email protected]>
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172 [email protected]<mailto:[email protected]> www.amarulasolutions.com<http://www.amarulasolutions.com>

--
Mike Looijmans
System Expert

TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: [email protected]<mailto:[email protected]>
W: www.topic.nl<http://www.topic.nl>

#4 lore raw
In reply to Mike Looijmans
Quoted 9 lines · Mike Looijmans

Flash partitions may specify MTDPART_SIZ_FULL (=0) as the size of the partition to indicate "the remainder of the flash". Make this work with device-tree "fixed-partitions" as well.

This makes MTD partitioning compatible with the Linux kernel, see:
https://github.com/torvalds/linux/blob/master/include/linux/mtd/partitions.h#L29
https://github.com/torvalds/linux/blob/master/drivers/mtd/mtdpart.c#L123

[...]

Applied to u-boot/master, thanks!

[1/1] mtd: mtdpart: Support MTDPART_SIZ_FULL in fixed-partitions

      commit: 98a898e58499c78245e4fe36ee404b1b1208e32b
Signature · 1 line
Tom