All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area
@ 2025-02-20 14:58 Alexander Stein
  2025-02-28 20:23 ` Tom Rini
  2025-04-22 10:37 ` [REGRESSION] " Francesco Dolcini
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Stein @ 2025-02-20 14:58 UTC (permalink / raw)
  To: u-boot; +Cc: Alexander Stein

If there is an unallocated memory area before the last, filling parting
the size calculation for MTD_SIZE_REMAINING does not take this hole
into account.
Fix this by calculating the remaining size just based on total size
and partition offset.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/mtd/mtdpart.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 4886392a1cf..4bc0960bb3c 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -207,7 +207,7 @@ int mtd_parse_partitions(struct mtd_info *parent, const char **_mtdparts,
 {
 	struct mtd_partition partition = {}, *parts;
 	const char *mtdparts = *_mtdparts;
-	uint64_t cur_off = 0, cur_sz = 0;
+	uint64_t cur_off = 0;
 	int nparts = 0;
 	int ret, idx;
 	u64 sz;
@@ -236,8 +236,7 @@ int mtd_parse_partitions(struct mtd_info *parent, const char **_mtdparts,
 			return ret;
 
 		if (parts[idx].size == MTD_SIZE_REMAINING)
-			parts[idx].size = parent->size - cur_sz;
-		cur_sz += parts[idx].size;
+			parts[idx].size = parent->size - parts[idx].offset;
 
 		sz = parts[idx].size;
 		if (sz < parent->writesize || do_div(sz, parent->writesize)) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-04-25  3:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 14:58 [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area Alexander Stein
2025-02-28 20:23 ` Tom Rini
2025-04-22 10:37 ` [REGRESSION] " Francesco Dolcini
2025-04-22 13:05   ` Alexander Stein
2025-04-22 13:07     ` Francesco Dolcini
2025-04-25  3:31       ` Weijie Gao (高惟杰)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.