mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* spi/mtd/m25p80 patches
@ 2013-10-28 12:01 Sascha Hauer
  2013-10-28 12:01 ` [PATCH 1/7] spi: Call spi_of_register_slaves from core Sascha Hauer
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-10-28 12:01 UTC (permalink / raw)
  To: barebox; +Cc: jbe

The following series fixes usage of multiple SPI masters probed from
devicetree. Also it adds support for persistent devicenames from
devicetree for the m25p80 driver.

Sascha

----------------------------------------------------------------
Sascha Hauer (7):
      spi: Call spi_of_register_slaves from core
      spi: support dynamic bus ids
      spi: Get bus_num from devicetree
      ARM: i.MX6: Add spi aliases to devicetree
      mtd: raw: rename raw device
      mtd: Pass device_id to add_mtd_device
      mtd: m25p80: Allow to specify devicename via devicetree alias

 arch/arm/boards/mioa701/env/bin/barebox_update |  8 ++++----
 arch/arm/boards/mioa701/env/bin/dps1_update    |  6 +++---
 arch/arm/dts/imx6q.dtsi                        |  4 ++++
 arch/arm/dts/imx6qdl.dtsi                      |  4 ++++
 drivers/mtd/core.c                             | 10 +++++++---
 drivers/mtd/devices/docg3.c                    |  2 +-
 drivers/mtd/devices/m25p80.c                   | 23 ++++++++++++++++-------
 drivers/mtd/devices/mtd_dataflash.c            |  2 +-
 drivers/mtd/mtdraw.c                           |  2 +-
 drivers/mtd/nand/nand_base.c                   |  2 +-
 drivers/mtd/nor/cfi_flash.c                    |  2 +-
 drivers/spi/imx_spi.c                          |  2 --
 drivers/spi/mvebu_spi.c                        |  3 ---
 drivers/spi/spi.c                              | 16 +++++++++++++++-
 include/linux/mtd/mtd.h                        |  2 +-
 include/spi/spi.h                              |  2 --
 16 files changed, 59 insertions(+), 31 deletions(-)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/7] spi: Call spi_of_register_slaves from core
  2013-10-28 12:01 spi/mtd/m25p80 patches Sascha Hauer
@ 2013-10-28 12:01 ` Sascha Hauer
  2013-10-28 12:01 ` [PATCH 2/7] spi: support dynamic bus ids Sascha Hauer
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-10-28 12:01 UTC (permalink / raw)
  To: barebox; +Cc: jbe

Makes individual handling of OF spi slaves unnecessary in the bus drivers.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/spi/imx_spi.c   | 2 --
 drivers/spi/mvebu_spi.c | 3 ---
 drivers/spi/spi.c       | 8 +++++++-
 include/spi/spi.h       | 2 --
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index 6f942bf..1c6b684 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -517,8 +517,6 @@ static int imx_spi_dt_probe(struct imx_spi *imx)
 		imx->cs_array[i] = cs_gpio;
 	}
 
-	spi_of_register_slaves(&imx->master, node);
-
 	return 0;
 }
 
diff --git a/drivers/spi/mvebu_spi.c b/drivers/spi/mvebu_spi.c
index 7aaa9fe..4a6d96f 100644
--- a/drivers/spi/mvebu_spi.c
+++ b/drivers/spi/mvebu_spi.c
@@ -361,9 +361,6 @@ static int mvebu_spi_probe(struct device_d *dev)
 	master->transfer = mvebu_spi_transfer;
 	master->num_chipselect = 1;
 
-	if (dev->device_node)
-		spi_of_register_slaves(master, dev->device_node);
-
 	ret = spi_register_master(master);
 	if (!ret)
 		return 0;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 55bebe0..d273050 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -101,11 +101,15 @@ fail:
 EXPORT_SYMBOL(spi_new_device);
 
 #ifdef CONFIG_OFDEVICE
-void spi_of_register_slaves(struct spi_master *master, struct device_node *node)
+static void spi_of_register_slaves(struct spi_master *master)
 {
 	struct device_node *n;
 	struct spi_board_info chip;
 	struct property *reg;
+	struct device_node *node = master->dev->device_node;
+
+	if (!node)
+		return;
 
 	for_each_child_of_node(node, n) {
 		memset(&chip, 0, sizeof(chip));
@@ -222,6 +226,8 @@ int spi_register_master(struct spi_master *master)
 
 	list_add_tail(&master->list, &spi_master_list);
 
+	spi_of_register_slaves(master);
+
 	/* populate children from any spi device tables */
 	scan_boardinfo(master);
 	status = 0;
diff --git a/include/spi/spi.h b/include/spi/spi.h
index 45fd22c..b4358a8 100644
--- a/include/spi/spi.h
+++ b/include/spi/spi.h
@@ -446,6 +446,4 @@ static inline int spi_driver_register(struct driver_d *drv)
 #define device_spi_driver(drv)	\
 	register_driver_macro(device,spi,drv)
 
-void spi_of_register_slaves(struct spi_master *master, struct device_node *node);
-
 #endif /* __INCLUDE_SPI_H */
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/7] spi: support dynamic bus ids
  2013-10-28 12:01 spi/mtd/m25p80 patches Sascha Hauer
  2013-10-28 12:01 ` [PATCH 1/7] spi: Call spi_of_register_slaves from core Sascha Hauer
@ 2013-10-28 12:01 ` Sascha Hauer
  2013-10-28 12:01 ` [PATCH 3/7] spi: Get bus_num from devicetree Sascha Hauer
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-10-28 12:01 UTC (permalink / raw)
  To: barebox; +Cc: jbe

When probing spi bus masters from devicetree they got a bus_num
of -1. This works with a single bus master only since all bus masters
had the same bus_num. Detect this and dynamically assign a valid
bus_num.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/spi/spi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index d273050..f035cc2 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -214,6 +214,7 @@ static LIST_HEAD(spi_master_list);
  */
 int spi_register_master(struct spi_master *master)
 {
+	static int dyn_bus_id = (1 << 15) - 1;
 	int			status = -ENODEV;
 
 	debug("%s: %s:%d\n", __func__, master->dev->name, master->dev->id);
@@ -224,6 +225,10 @@ int spi_register_master(struct spi_master *master)
 	if (master->num_chipselect == 0)
 		return -EINVAL;
 
+	/* convention:  dynamically assigned bus IDs count down from the max */
+	if (master->bus_num < 0)
+		master->bus_num = dyn_bus_id--;
+
 	list_add_tail(&master->list, &spi_master_list);
 
 	spi_of_register_slaves(master);
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/7] spi: Get bus_num from devicetree
  2013-10-28 12:01 spi/mtd/m25p80 patches Sascha Hauer
  2013-10-28 12:01 ` [PATCH 1/7] spi: Call spi_of_register_slaves from core Sascha Hauer
  2013-10-28 12:01 ` [PATCH 2/7] spi: support dynamic bus ids Sascha Hauer
@ 2013-10-28 12:01 ` Sascha Hauer
  2013-10-28 12:01 ` [PATCH 4/7] ARM: i.MX6: Add spi aliases to devicetree Sascha Hauer
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-10-28 12:01 UTC (permalink / raw)
  To: barebox; +Cc: jbe

Get the bus_num from devicetree if a "spi" alias exists.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/spi/spi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f035cc2..b9397ad 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -225,6 +225,9 @@ int spi_register_master(struct spi_master *master)
 	if (master->num_chipselect == 0)
 		return -EINVAL;
 
+	if ((master->bus_num < 0) && master->dev->device_node)
+		master->bus_num = of_alias_get_id(master->dev->device_node, "spi");
+
 	/* convention:  dynamically assigned bus IDs count down from the max */
 	if (master->bus_num < 0)
 		master->bus_num = dyn_bus_id--;
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/7] ARM: i.MX6: Add spi aliases to devicetree
  2013-10-28 12:01 spi/mtd/m25p80 patches Sascha Hauer
                   ` (2 preceding siblings ...)
  2013-10-28 12:01 ` [PATCH 3/7] spi: Get bus_num from devicetree Sascha Hauer
@ 2013-10-28 12:01 ` Sascha Hauer
  2013-10-28 12:01 ` [PATCH 5/7] mtd: raw: rename raw device Sascha Hauer
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-10-28 12:01 UTC (permalink / raw)
  To: barebox; +Cc: jbe

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/dts/imx6q.dtsi   | 4 ++++
 arch/arm/dts/imx6qdl.dtsi | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/dts/imx6q.dtsi b/arch/arm/dts/imx6q.dtsi
index beb8946..0377cce 100644
--- a/arch/arm/dts/imx6q.dtsi
+++ b/arch/arm/dts/imx6q.dtsi
@@ -12,6 +12,10 @@
 #include "imx6qdl.dtsi"
 
 / {
+	aliases {
+		spi4 = &ecspi5;
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
diff --git a/arch/arm/dts/imx6qdl.dtsi b/arch/arm/dts/imx6qdl.dtsi
index d9bacfa..a574958 100644
--- a/arch/arm/dts/imx6qdl.dtsi
+++ b/arch/arm/dts/imx6qdl.dtsi
@@ -30,6 +30,10 @@
 		mmc1 = &usdhc2;
 		mmc2 = &usdhc3;
 		mmc3 = &usdhc4;
+		spi0 = &ecspi1;
+		spi1 = &ecspi2;
+		spi2 = &ecspi3;
+		spi3 = &ecspi4;
 	};
 
 	intc: interrupt-controller@00a01000 {
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 5/7] mtd: raw: rename raw device
  2013-10-28 12:01 spi/mtd/m25p80 patches Sascha Hauer
                   ` (3 preceding siblings ...)
  2013-10-28 12:01 ` [PATCH 4/7] ARM: i.MX6: Add spi aliases to devicetree Sascha Hauer
@ 2013-10-28 12:01 ` Sascha Hauer
  2013-10-28 12:01 ` [PATCH 6/7] mtd: Pass device_id to add_mtd_device Sascha Hauer
  2013-10-28 12:01 ` [PATCH 7/7] mtd: m25p80: Allow to specify devicename via devicetree alias Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-10-28 12:01 UTC (permalink / raw)
  To: barebox; +Cc: jbe

The name of the raw device is mtdraw<num> which is inconsistent to other
mtd devices which are named mtd<num>.<partname>. Rename it to mtd<num>.raw.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/mioa701/env/bin/barebox_update | 8 ++++----
 arch/arm/boards/mioa701/env/bin/dps1_update    | 6 +++---
 drivers/mtd/mtdraw.c                           | 2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boards/mioa701/env/bin/barebox_update b/arch/arm/boards/mioa701/env/bin/barebox_update
index b544563..1023770 100644
--- a/arch/arm/boards/mioa701/env/bin/barebox_update
+++ b/arch/arm/boards/mioa701/env/bin/barebox_update
@@ -1,10 +1,10 @@
 #!/bin/sh
 
 # Page+OOB specific partitions
-addpart /dev/mtdraw0 1081344@3649536(msipl)
-addpart /dev/mtdraw0 270336@3649536(barebox)
+addpart /dev/mtd0.raw 1081344@3649536(msipl)
+addpart /dev/mtd0.raw 270336@3649536(barebox)
 
 if [ -r /barebox.BIP0 ]; then
-	erase /dev/mtdraw0.barebox
-	cp -v /barebox.BIP0 /dev/mtdraw0.barebox
+	erase /dev/mtd0.raw.barebox
+	cp -v /barebox.BIP0 /dev/mtd0.raw.barebox
 fi
diff --git a/arch/arm/boards/mioa701/env/bin/dps1_update b/arch/arm/boards/mioa701/env/bin/dps1_update
index a9d72da..e6535ed 100644
--- a/arch/arm/boards/mioa701/env/bin/dps1_update
+++ b/arch/arm/boards/mioa701/env/bin/dps1_update
@@ -1,12 +1,12 @@
 #!/bin/sh
 
 # Page+OOB specific partitions
-addpart /dev/mtdraw0 67584@202752(dps1)
+addpart /dev/mtd0.raw 67584@202752(dps1)
 uncompress /env/data/dps1.raw.gz /dps1.raw
 
 if [ -r /dps1.raw ]; then
 	dps1_unlock
-	erase /dev/mtdraw0.dps1
-	cp -v /dps1.raw /dev/mtdraw0.dps1
+	erase /dev/mtd0.raw.dps1
+	cp -v /dps1.raw /dev/mtd0.raw.dps1
 	dps1_unlock
 fi
diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
index 1a4711e..2acd51f 100644
--- a/drivers/mtd/mtdraw.c
+++ b/drivers/mtd/mtdraw.c
@@ -293,7 +293,7 @@ static int add_mtdraw_device(struct mtd_info *mtd, char *devname, void **priv)
 	mtdraw->cdev.ops = (struct file_operations *)&mtd_raw_fops;
 	mtdraw->cdev.size = mtd->size / mtd->writesize *
 		(mtd->writesize + mtd->oobsize);
-	mtdraw->cdev.name = asprintf("%sraw%d", devname, mtd->class_dev.id);
+	mtdraw->cdev.name = asprintf("%s.raw", mtd->cdev.name);
 	mtdraw->cdev.priv = mtdraw;
 	mtdraw->cdev.dev = &mtd->class_dev;
 	mtdraw->cdev.mtd = mtd;
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6/7] mtd: Pass device_id to add_mtd_device
  2013-10-28 12:01 spi/mtd/m25p80 patches Sascha Hauer
                   ` (4 preceding siblings ...)
  2013-10-28 12:01 ` [PATCH 5/7] mtd: raw: rename raw device Sascha Hauer
@ 2013-10-28 12:01 ` Sascha Hauer
  2013-10-28 12:01 ` [PATCH 7/7] mtd: m25p80: Allow to specify devicename via devicetree alias Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-10-28 12:01 UTC (permalink / raw)
  To: barebox; +Cc: jbe

Right now we do not support persistent names for mtd devices. The
base name can be passed to add_mtd_device, but this is always appended
with a dynamic number. With this patch add_mtd_device takes a device_id
argument which can be used to create a mtd device with an exact name.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/core.c                  | 10 +++++++---
 drivers/mtd/devices/docg3.c         |  2 +-
 drivers/mtd/devices/m25p80.c        |  4 +---
 drivers/mtd/devices/mtd_dataflash.c |  2 +-
 drivers/mtd/nand/nand_base.c        |  2 +-
 drivers/mtd/nor/cfi_flash.c         |  2 +-
 include/linux/mtd/mtd.h             |  2 +-
 7 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 70036aa..f63b10e 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -359,21 +359,25 @@ static struct file_operations mtd_ops = {
 	.lseek  = dev_lseek_default,
 };
 
-int add_mtd_device(struct mtd_info *mtd, char *devname)
+int add_mtd_device(struct mtd_info *mtd, char *devname, int device_id)
 {
 	struct mtddev_hook *hook;
 
 	if (!devname)
 		devname = "mtd";
 	strcpy(mtd->class_dev.name, devname);
-	mtd->class_dev.id = DEVICE_ID_DYNAMIC;
+	mtd->class_dev.id = device_id;
 	if (mtd->parent)
 		mtd->class_dev.parent = mtd->parent;
 	register_device(&mtd->class_dev);
 
 	mtd->cdev.ops = &mtd_ops;
 	mtd->cdev.size = mtd->size;
-	mtd->cdev.name = asprintf("%s%d", devname, mtd->class_dev.id);
+	if (device_id == DEVICE_ID_SINGLE)
+		mtd->cdev.name = xstrdup(devname);
+	else
+		mtd->cdev.name = asprintf("%s%d", devname, mtd->class_dev.id);
+
 	mtd->cdev.priv = mtd;
 	mtd->cdev.dev = &mtd->class_dev;
 	mtd->cdev.mtd = mtd;
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index e15c809..9ae606b 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -1173,7 +1173,7 @@ static int __init docg3_probe(struct device_d *dev)
 		}
 		docg3_floors[floor] = mtd;
 		mtd->parent = dev;
-		ret = add_mtd_device(mtd, NULL);
+		ret = add_mtd_device(mtd, NULL, DEVICE_ID_DYNAMIC);
 		if (ret)
 			goto err_probe;
 		found++;
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 57fe1f2..429ddf6 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -942,9 +942,7 @@ static int m25p_probe(struct device_d *dev)
 				flash->mtd.eraseregions[i].erasesize / 1024,
 				flash->mtd.eraseregions[i].numblocks);
 
-
-
-	return add_mtd_device(&flash->mtd, flash->mtd.name);
+	return add_mtd_device(&flash->mtd, flash->mtd.name, DEVICE_ID_DYNAMIC);
 }
 
 static __maybe_unused struct of_device_id m25p80_dt_ids[] = {
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 52bd842..d785e33 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -643,7 +643,7 @@ add_dataflash_otp(struct spi_device *spi, char *name,
 			name, (long long)((device->size + 1023) >> 10),
 			pagesize, otp_tag);
 
-	err = add_mtd_device(device, device->name);
+	err = add_mtd_device(device, device->name, DEVICE_ID_DYNAMIC);
 
 	if (!err)
 		return 0;
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index c252a2a..d249565 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3687,7 +3687,7 @@ int add_mtd_nand_device(struct mtd_info *mtd, char *devname)
 {
 	int ret;
 
-	ret = add_mtd_device(mtd, devname);
+	ret = add_mtd_device(mtd, devname, DEVICE_ID_DYNAMIC);
 	if (ret)
 		return ret;
 
diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
index 51fc6bc..71dd3c8 100644
--- a/drivers/mtd/nor/cfi_flash.c
+++ b/drivers/mtd/nor/cfi_flash.c
@@ -965,7 +965,7 @@ static void cfi_init_mtd(struct flash_info *info)
 	mtd->type = MTD_NORFLASH;
 	mtd->parent = info->dev;
 
-	add_mtd_device(mtd, "nor");
+	add_mtd_device(mtd, "nor", DEVICE_ID_DYNAMIC);
 }
 
 static int cfi_probe (struct device_d *dev)
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index ed8722e..1735b49 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -254,7 +254,7 @@ static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd)
 }
 	/* Kernel-side ioctl definitions */
 
-extern int add_mtd_device(struct mtd_info *mtd, char *devname);
+extern int add_mtd_device(struct mtd_info *mtd, char *devname, int device_id);
 extern int del_mtd_device (struct mtd_info *mtd);
 
 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 7/7] mtd: m25p80: Allow to specify devicename via devicetree alias
  2013-10-28 12:01 spi/mtd/m25p80 patches Sascha Hauer
                   ` (5 preceding siblings ...)
  2013-10-28 12:01 ` [PATCH 6/7] mtd: Pass device_id to add_mtd_device Sascha Hauer
@ 2013-10-28 12:01 ` Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-10-28 12:01 UTC (permalink / raw)
  To: barebox; +Cc: jbe

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/devices/m25p80.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 429ddf6..1e3bc93 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -808,6 +808,8 @@ static int m25p_probe(struct device_d *dev)
 	struct flash_info		*info = NULL;
 	unsigned			i;
 	unsigned			do_jdec_probe = 1;
+	char				*flashname = NULL;
+	int				device_id;
 
 	/* Platform data helps sort out which chip type we have, as
 	 * well as how this board partitions it.  If we don't have
@@ -876,10 +878,19 @@ static int m25p_probe(struct device_d *dev)
 		write_sr(flash, 0);
 	}
 
-	if (data && data->name)
-		flash->mtd.name = data->name;
-	else
-		flash->mtd.name = "m25p";
+	device_id = DEVICE_ID_SINGLE;
+	if (dev->device_node) {
+		const char *alias = of_alias_get(dev->device_node);
+		if (alias)
+			flashname = xstrdup(alias);
+	} else if (data && data->name) {
+		flashname = data->name;
+	}
+
+	if (!flashname) {
+		device_id = DEVICE_ID_DYNAMIC;
+		flashname = "m25p";
+	}
 
 	flash->mtd.type = MTD_NORFLASH;
 	flash->mtd.writesize = 1;
@@ -942,7 +953,7 @@ static int m25p_probe(struct device_d *dev)
 				flash->mtd.eraseregions[i].erasesize / 1024,
 				flash->mtd.eraseregions[i].numblocks);
 
-	return add_mtd_device(&flash->mtd, flash->mtd.name, DEVICE_ID_DYNAMIC);
+	return add_mtd_device(&flash->mtd, flashname, device_id);
 }
 
 static __maybe_unused struct of_device_id m25p80_dt_ids[] = {
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-10-28 12:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-28 12:01 spi/mtd/m25p80 patches Sascha Hauer
2013-10-28 12:01 ` [PATCH 1/7] spi: Call spi_of_register_slaves from core Sascha Hauer
2013-10-28 12:01 ` [PATCH 2/7] spi: support dynamic bus ids Sascha Hauer
2013-10-28 12:01 ` [PATCH 3/7] spi: Get bus_num from devicetree Sascha Hauer
2013-10-28 12:01 ` [PATCH 4/7] ARM: i.MX6: Add spi aliases to devicetree Sascha Hauer
2013-10-28 12:01 ` [PATCH 5/7] mtd: raw: rename raw device Sascha Hauer
2013-10-28 12:01 ` [PATCH 6/7] mtd: Pass device_id to add_mtd_device Sascha Hauer
2013-10-28 12:01 ` [PATCH 7/7] mtd: m25p80: Allow to specify devicename via devicetree alias Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox