kernel: backport support for "linux,rootfs" in DT
[openwrt/staging/hauke.git] / target / linux / generic / hack-5.15 / 420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
2 Date: Mon, 7 Nov 2022 23:48:24 +0100
3 Subject: [PATCH] mtd: support OpenWrt's MTD_ROOTFS_ROOT_DEV
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 This allows setting ROOT_DEV to MTD partition named "rootfs".
9
10 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
11 ---
12
13 --- a/drivers/mtd/mtdcore.c
14 +++ b/drivers/mtd/mtdcore.c
15 @@ -759,7 +759,8 @@ int add_mtd_device(struct mtd_info *mtd)
16
17 mutex_unlock(&mtd_table_mutex);
18
19 - if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL)) {
20 + if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL) ||
21 + (IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) && !strcmp(mtd->name, "rootfs") && ROOT_DEV == 0)) {
22 if (IS_BUILTIN(CONFIG_MTD)) {
23 pr_info("mtd: setting mtd%d (%s) as root device\n", mtd->index, mtd->name);
24 ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);