420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch 927 B

123456789101112131415161718192021222324
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  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. This allows setting ROOT_DEV to MTD partition named "rootfs".
  8. Signed-off-by: Rafał Miłecki <[email protected]>
  9. ---
  10. --- a/drivers/mtd/mtdcore.c
  11. +++ b/drivers/mtd/mtdcore.c
  12. @@ -784,7 +784,8 @@ int add_mtd_device(struct mtd_info *mtd)
  13. mutex_unlock(&mtd_table_mutex);
  14. - if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL)) {
  15. + if (of_find_property(mtd_get_of_node(mtd), "linux,rootfs", NULL) ||
  16. + (IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) && !strcmp(mtd->name, "rootfs") && ROOT_DEV == 0)) {
  17. if (IS_BUILTIN(CONFIG_MTD)) {
  18. pr_info("mtd: setting mtd%d (%s) as root device\n", mtd->index, mtd->name);
  19. ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);