0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. From 4400e1f593ea40a51912128adb4f53d59e62cad8 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Wed, 10 Sep 2014 22:40:18 +0200
  4. Subject: [PATCH 22/36] MTD: m25p80: allow loading mtd name from OF
  5. In accordance with the physmap flash we should honour the linux,mtd-name
  6. property when deciding what name the mtd device has.
  7. Signed-off-by: Thomas Langer <thomas.langer@lantiq.com>
  8. Signed-off-by: John Crispin <blogic@openwrt.org>
  9. ---
  10. drivers/mtd/devices/m25p80.c | 6 ++++++
  11. 1 file changed, 6 insertions(+)
  12. --- a/drivers/mtd/devices/m25p80.c
  13. +++ b/drivers/mtd/devices/m25p80.c
  14. @@ -19,6 +19,7 @@
  15. #include <linux/errno.h>
  16. #include <linux/module.h>
  17. #include <linux/device.h>
  18. +#include <linux/of.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/partitions.h>
  21. @@ -204,6 +205,10 @@ static int m25p_probe(struct spi_device
  22. enum read_mode mode = SPI_NOR_NORMAL;
  23. char *flash_name = NULL;
  24. int ret;
  25. + const char __maybe_unused *of_mtd_name = NULL;
  26. +
  27. + of_property_read_string(spi->dev.of_node,
  28. + "linux,mtd-name", &of_mtd_name);
  29. data = dev_get_platdata(&spi->dev);
  30. @@ -234,6 +239,8 @@ static int m25p_probe(struct spi_device
  31. if (data && data->name)
  32. nor->mtd.name = data->name;
  33. + else if (of_mtd_name)
  34. + nor->mtd.name = of_mtd_name;
  35. /* For some (historical?) reason many platforms provide two different
  36. * names in flash_platform_data: "name" and "type". Quite often name is