dce0432fac130ddfd397fb5e0ad8c44edb72f6a7
[librecmc/librecmc.git] / target / linux / generic / pending-4.19 / 480-mtd-set-rootfs-to-be-root-dev.patch
1 From: Gabor Juhos <juhosg@openwrt.org>
2 Subject: kernel/3.1[02]: move MTD root device setup code to mtdcore
3
4 The current code only allows to automatically set
5 root device on MTD partitions. Move the code to MTD
6 core to allow to use it with all MTD devices.
7
8 Signed-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 @@ -41,6 +41,7 @@
16  #include <linux/reboot.h>
17  #include <linux/leds.h>
18  #include <linux/debugfs.h>
19 +#include <linux/root_dev.h>
20  
21  #include <linux/mtd/mtd.h>
22  #include <linux/mtd/partitions.h>
23 @@ -593,6 +594,15 @@ int add_mtd_device(struct mtd_info *mtd)
24            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_added: