blob: 21b98e0d5f0c0ccef3b833cdb6b48564a4fd328d [file] [log] [blame]
developerec4ebe42022-04-12 11:17:45 +08001From: Gabor Juhos <juhosg@openwrt.org>
2Subject: kernel/3.1[02]: move MTD root device setup code to mtdcore
3
4The current code only allows to automatically set
5root device on MTD partitions. Move the code to MTD
6core to allow to use it with all MTD devices.
7
8Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
9---
10 drivers/mtd/mtdcore.c | 10 ++++++++++
11 1 file changed, 10 insertions(+)
12
13--- a/drivers/mtd/mtdcore.c
14+++ b/drivers/mtd/mtdcore.c
15@@ -27,6 +27,7 @@
16 #include <linux/reboot.h>
17 #include <linux/leds.h>
18 #include <linux/debugfs.h>
19+#include <linux/root_dev.h>
20 #include <linux/nvmem-provider.h>
21
22 #include <linux/mtd/mtd.h>
developer30584bd2023-01-30 13:12:50 +080023@@ -756,6 +757,15 @@ int add_mtd_device(struct mtd_info *mtd)
developerec4ebe42022-04-12 11:17:45 +080024 of this try_ nonsense, and no bitching about it
25 either. :) */
26 __module_get(THIS_MODULE);
27+
28+ if (!strcmp(mtd->name, "rootfs") &&
29+ IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
30+ ROOT_DEV == 0) {
31+ pr_notice("mtd: device %d (%s) set to be root filesystem\n",
32+ mtd->index, mtd->name);
33+ ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
34+ }
35+
36 return 0;
37
38 fail_nvmem_add: