401-mtd-nor-support-mtd-name-from-device-tree.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. From f32bc2aa01edcba2f2ed5db151cf183eac9ef919 Mon Sep 17 00:00:00 2001
  2. From: Abhimanyu Vishwakarma <[email protected]>
  3. Date: Sat, 25 Feb 2017 16:42:50 +0000
  4. Subject: mtd: nor: support mtd name from device tree
  5. Signed-off-by: Abhimanyu Vishwakarma <[email protected]>
  6. ---
  7. drivers/mtd/spi-nor/spi-nor.c | 8 +++++++-
  8. 1 file changed, 7 insertions(+), 1 deletion(-)
  9. --- a/drivers/mtd/spi-nor/spi-nor.c
  10. +++ b/drivers/mtd/spi-nor/spi-nor.c
  11. @@ -1541,6 +1541,7 @@ int spi_nor_scan(struct spi_nor *nor, co
  12. struct device *dev = nor->dev;
  13. struct mtd_info *mtd = &nor->mtd;
  14. struct device_node *np = spi_nor_get_flash_node(nor);
  15. + const char __maybe_unused *of_mtd_name = NULL;
  16. int ret;
  17. int i;
  18. @@ -1605,7 +1606,12 @@ int spi_nor_scan(struct spi_nor *nor, co
  19. spi_nor_wait_till_ready(nor);
  20. }
  21. - if (!mtd->name)
  22. +#ifdef CONFIG_MTD_OF_PARTS
  23. + of_property_read_string(np, "linux,mtd-name", &of_mtd_name);
  24. +#endif
  25. + if (of_mtd_name)
  26. + mtd->name = of_mtd_name;
  27. + else if (!mtd->name)
  28. mtd->name = dev_name(dev);
  29. mtd->priv = nor;
  30. mtd->type = MTD_NORFLASH;