developer | ec4ebe4 | 2022-04-12 11:17:45 +0800 | [diff] [blame] | 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 | @@ -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> |
developer | 30584bd | 2023-01-30 13:12:50 +0800 | [diff] [blame] | 23 | @@ -756,6 +757,15 @@ int add_mtd_device(struct mtd_info *mtd) |
developer | ec4ebe4 | 2022-04-12 11:17:45 +0800 | [diff] [blame] | 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_nvmem_add: |