2024-03-19 22:27:08 +00:00
|
|
|
From f32bc2aa01edcba2f2ed5db151cf183eac9ef919 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
|
|
|
|
Date: Sat, 25 Feb 2017 16:42:50 +0000
|
|
|
|
Subject: mtd: nor: support mtd name from device tree
|
|
|
|
|
|
|
|
Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
|
|
|
|
---
|
|
|
|
drivers/mtd/spi-nor/spi-nor.c | 8 +++++++-
|
|
|
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
|
|
|
2024-06-26 22:12:43 +00:00
|
|
|
--- a/drivers/spi/spi-mem.c
|
|
|
|
+++ b/drivers/spi/spi-mem.c
|
|
|
|
@@ -846,7 +846,9 @@ static int spi_mem_probe(struct spi_devi
|
2024-03-19 22:28:53 +00:00
|
|
|
{
|
2024-06-26 22:12:43 +00:00
|
|
|
struct spi_mem_driver *memdrv = to_spi_mem_drv(spi->dev.driver);
|
|
|
|
struct spi_controller *ctlr = spi->controller;
|
2024-03-19 22:27:08 +00:00
|
|
|
+ const char __maybe_unused *of_mtd_name = NULL;
|
2024-06-26 22:12:43 +00:00
|
|
|
struct spi_mem *mem;
|
|
|
|
+ int ret;
|
2024-03-19 22:27:08 +00:00
|
|
|
|
2024-06-26 22:12:43 +00:00
|
|
|
mem = devm_kzalloc(&spi->dev, sizeof(*mem), GFP_KERNEL);
|
|
|
|
if (!mem)
|
|
|
|
@@ -854,10 +856,15 @@ static int spi_mem_probe(struct spi_devi
|
2024-03-19 22:27:08 +00:00
|
|
|
|
2024-06-26 22:12:43 +00:00
|
|
|
mem->spi = spi;
|
|
|
|
|
|
|
|
- if (ctlr->mem_ops && ctlr->mem_ops->get_name)
|
|
|
|
+ if (ctlr->mem_ops && ctlr->mem_ops->get_name) {
|
|
|
|
mem->name = ctlr->mem_ops->get_name(mem);
|
|
|
|
- else
|
|
|
|
- mem->name = dev_name(&spi->dev);
|
|
|
|
+ } else {
|
|
|
|
+ ret = device_property_read_string(&spi->dev, "linux,mtd-name", &of_mtd_name);
|
|
|
|
+ if (!ret)
|
|
|
|
+ mem->name = of_mtd_name;
|
|
|
|
+ else
|
|
|
|
+ mem->name = dev_name(&spi->dev);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (IS_ERR_OR_NULL(mem->name))
|
|
|
|
return PTR_ERR_OR_ZERO(mem->name);
|
2024-03-19 22:27:08 +00:00
|
|
|
--- a/drivers/mtd/mtdcore.c
|
|
|
|
+++ b/drivers/mtd/mtdcore.c
|
2024-05-28 21:28:40 +00:00
|
|
|
@@ -870,6 +870,17 @@ out_error:
|
2024-03-19 22:27:08 +00:00
|
|
|
*/
|
|
|
|
static void mtd_set_dev_defaults(struct mtd_info *mtd)
|
|
|
|
{
|
|
|
|
+#ifdef CONFIG_MTD_OF_PARTS
|
|
|
|
+ const char __maybe_unused *of_mtd_name = NULL;
|
|
|
|
+ struct device_node *np;
|
|
|
|
+
|
|
|
|
+ np = mtd_get_of_node(mtd);
|
|
|
|
+ if (np && !mtd->name) {
|
|
|
|
+ of_property_read_string(np, "linux,mtd-name", &of_mtd_name);
|
|
|
|
+ if (of_mtd_name)
|
|
|
|
+ mtd->name = of_mtd_name;
|
|
|
|
+ } else
|
|
|
|
+#endif
|
|
|
|
if (mtd->dev.parent) {
|
|
|
|
if (!mtd->owner && mtd->dev.parent->driver)
|
|
|
|
mtd->owner = mtd->dev.parent->driver->owner;
|