kernel: split patches folder up into backport, pending and hack folders
[openwrt/openwrt.git] / target / linux / generic / pending-4.9 / 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 diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
14 index d46e4adf6d2b..4d62d898dadc 100644
15 --- a/drivers/mtd/mtdcore.c
16 +++ b/drivers/mtd/mtdcore.c
17 @@ -40,6 +40,7 @@
18 #include <linux/slab.h>
19 #include <linux/reboot.h>
20 #include <linux/leds.h>
21 +#include <linux/root_dev.h>
22
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/partitions.h>
25 @@ -570,6 +571,15 @@ int add_mtd_device(struct mtd_info *mtd)
26 of this try_ nonsense, and no bitching about it
27 either. :) */
28 __module_get(THIS_MODULE);
29 +
30 + if (!strcmp(mtd->name, "rootfs") &&
31 + IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
32 + ROOT_DEV == 0) {
33 + pr_notice("mtd: device %d (%s) set to be root filesystem\n",
34 + mtd->index, mtd->name);
35 + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
36 + }
37 +
38 return 0;
39
40 fail_added:
41 --
42 2.11.0
43