From 9f51c3956a80205006dc6a686d80969bd3b42ecb Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@nbd.name>
Date: Thu, 10 Mar 2022 17:32:20 +0100
Subject: [PATCH 13/14] kernel: mtdsplit: support UBI after FIT images

Change the partition name accordingly. Same behavior as mtdsplit_uimage

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 .../generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c     | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
index 5cc1658dbd..f043428949 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
@@ -57,6 +57,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
 	size_t fit_offset, fit_size;
 	size_t rootfs_offset, rootfs_size;
 	struct mtd_partition *parts;
+	enum mtdsplit_part_type type;
 	int ret;
 
 	of_property_read_string(np, "openwrt,cmdline-match", &cmdline_match);
@@ -101,7 +102,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
 
 	/* Search for the rootfs partition after the FIT image */
 	ret = mtd_find_rootfs_from(mtd, fit_offset + fit_size, mtd->size,
-				   &rootfs_offset, NULL);
+				   &rootfs_offset, &type);
 	if (ret) {
 		pr_info("no rootfs found after FIT image in \"%s\"\n",
 			mtd->name);
@@ -118,7 +119,10 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
 	parts[0].offset = fit_offset;
 	parts[0].size = mtd_rounddown_to_eb(fit_size, mtd) + mtd->erasesize;
 
-	parts[1].name = ROOTFS_PART_NAME;
+	if (type == MTDSPLIT_PART_TYPE_UBI)
+		parts[1].name = UBI_PART_NAME;
+	else
+		parts[1].name = ROOTFS_PART_NAME;
 	parts[1].offset = rootfs_offset;
 	parts[1].size = rootfs_size;
 
-- 
2.25.1

