1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sat Apr 10 17:00:57 2021 +0200
3 Subject: [PATCH] mtd: fix squashfs root on targets with CONFIG_FIT_PARTITION
5 Fix assumption about the block device index
8 --- a/drivers/mtd/mtdcore.c
9 +++ b/drivers/mtd/mtdcore.c
10 @@ -758,12 +758,18 @@ int add_mtd_device(struct mtd_info *mtd)
12 if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL) ||
13 (IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) && !strcmp(mtd->name, "rootfs") && ROOT_DEV == 0)) {
14 + unsigned int index = mtd->index;
16 +#ifdef CONFIG_FIT_PARTITION
20 if (IS_BUILTIN(CONFIG_MTD)) {
21 - pr_info("mtd: setting mtd%d (%s) as root device\n", mtd->index, mtd->name);
22 - ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
23 + pr_info("mtd: setting mtd%d (%s) as root device\n", index, mtd->name);
24 + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, index);
26 pr_warn("mtd: can't set mtd%d (%s) as root device - mtd must be builtin\n",
27 - mtd->index, mtd->name);