summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Stein <alexander.stein@ew.tq-group.com>2025-02-20 15:58:07 +0100
committerTom Rini <trini@konsulko.com>2025-02-28 08:37:49 -0600
commit1ca97ee9039293858988dc38ea3a8ff995b4950e (patch)
tree017ee27b4b2ac0cdd9ce81a6a9a394f727700d10
parentd8212740541a4d69f6123730da7654e41e75ab17 (diff)
mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area
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>
-rw-r--r--drivers/mtd/mtdpart.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 88094b81e7a..3f8edeb5093 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -208,7 +208,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;
@@ -237,8 +237,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)) {