aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/hack-5.10/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch
blob: 08e4193c600b75ba41923a0e081e5811f7e011c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Mon, 7 Nov 2022 23:48:24 +0100
Subject: [PATCH] mtd: support OpenWrt's MTD_ROOTFS_ROOT_DEV
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This allows setting ROOT_DEV to MTD partition named "rootfs".

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---

--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -758,7 +758,8 @@ int add_mtd_device(struct mtd_info *mtd)
 
 	mutex_unlock(&mtd_table_mutex);
 
-	if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL)) {
+	if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL) ||
+	    (IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) && !strcmp(mtd->name, "rootfs") && ROOT_DEV == 0)) {
 		if (IS_BUILTIN(CONFIG_MTD)) {
 			pr_info("mtd: setting mtd%d (%s) as root device\n", mtd->index, mtd->name);
 			ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);