All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Add a "label" property to the mtd device
@ 2017-01-16 13:27 ` Cédric Le Goater
  0 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 13:27 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, Boris Brezillon, devicetree, Richard Weinberger,
	Marek Vasut, Rob Herring, Cédric Le Goater, Cyrille Pitchen,
	Brian Norris, David Woodhouse

Hello,

Herer are a couple of patches adding a "label" property to the mtd
device, which can be used to identify a specific chip on a system with
multiple chips. This is common on the OpenPower boards, there can be
four chips holding the firmware for the BMC and the firmware for the
host, plus chips with golden images for recovery.

Also included a patch from Robert adding dual data read to the
mx66l51235l chip. It was tested on a Zaius board which has a AST2500
SoC for BMC.

Thanks,

C.


Cédric Le Goater (2):
  mtd: name the mtd device with an optional label property
  dt-bindings: mtd: add a common label property to all mtd devices

Robert Lippert (1):
  mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l

 Documentation/devicetree/bindings/mtd/common.txt | 12 ++++++++++++
 drivers/mtd/mtdcore.c                            |  7 +++++++
 drivers/mtd/spi-nor/spi-nor.c                    |  2 +-
 3 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/common.txt

-- 
2.7.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* [PATCH 0/3] Add a "label" property to the mtd device
@ 2017-01-16 13:27 ` Cédric Le Goater
  0 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 13:27 UTC (permalink / raw)
  To: linux-mtd
  Cc: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland, Cédric Le Goater

Hello,

Herer are a couple of patches adding a "label" property to the mtd
device, which can be used to identify a specific chip on a system with
multiple chips. This is common on the OpenPower boards, there can be
four chips holding the firmware for the BMC and the firmware for the
host, plus chips with golden images for recovery.

Also included a patch from Robert adding dual data read to the
mx66l51235l chip. It was tested on a Zaius board which has a AST2500
SoC for BMC.

Thanks,

C.


Cédric Le Goater (2):
  mtd: name the mtd device with an optional label property
  dt-bindings: mtd: add a common label property to all mtd devices

Robert Lippert (1):
  mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l

 Documentation/devicetree/bindings/mtd/common.txt | 12 ++++++++++++
 drivers/mtd/mtdcore.c                            |  7 +++++++
 drivers/mtd/spi-nor/spi-nor.c                    |  2 +-
 3 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/common.txt

-- 
2.7.4

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

* [PATCH 1/3] mtd: name the mtd device with an optional label property
  2017-01-16 13:27 ` Cédric Le Goater
@ 2017-01-16 13:27   ` Cédric Le Goater
  -1 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 13:27 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, Boris Brezillon, devicetree, Richard Weinberger,
	Marek Vasut, Rob Herring, Cédric Le Goater, Cyrille Pitchen,
	Brian Norris, David Woodhouse

This can be used to easily identify a specific chip on a system with
multiple chips.

Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/mtd/mtdcore.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 052772f7caef..bf61557b599d 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
  */
 static void mtd_set_dev_defaults(struct mtd_info *mtd)
 {
+	/*
+	 * If DT support is enabled and we have a valid of_node pointer, try to
+	 * extract the MTD name from the label property.
+	 */
+	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
+		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
+
 	if (mtd->dev.parent) {
 		if (!mtd->owner && mtd->dev.parent->driver)
 			mtd->owner = mtd->dev.parent->driver->owner;
-- 
2.7.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* [PATCH 1/3] mtd: name the mtd device with an optional label property
@ 2017-01-16 13:27   ` Cédric Le Goater
  0 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 13:27 UTC (permalink / raw)
  To: linux-mtd
  Cc: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland, Cédric Le Goater

This can be used to easily identify a specific chip on a system with
multiple chips.

Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/mtd/mtdcore.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 052772f7caef..bf61557b599d 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
  */
 static void mtd_set_dev_defaults(struct mtd_info *mtd)
 {
+	/*
+	 * If DT support is enabled and we have a valid of_node pointer, try to
+	 * extract the MTD name from the label property.
+	 */
+	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
+		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
+
 	if (mtd->dev.parent) {
 		if (!mtd->owner && mtd->dev.parent->driver)
 			mtd->owner = mtd->dev.parent->driver->owner;
-- 
2.7.4

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

* [PATCH 2/3] dt-bindings: mtd: add a common label property to all mtd devices
  2017-01-16 13:27 ` Cédric Le Goater
@ 2017-01-16 13:27   ` Cédric Le Goater
  -1 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 13:27 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, Boris Brezillon, devicetree, Richard Weinberger,
	Marek Vasut, Rob Herring, Cédric Le Goater, Cyrille Pitchen,
	Brian Norris, David Woodhouse

This can be used to easily identify a specific chip on a system with
multiple chips.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 Documentation/devicetree/bindings/mtd/common.txt | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/common.txt

diff --git a/Documentation/devicetree/bindings/mtd/common.txt b/Documentation/devicetree/bindings/mtd/common.txt
new file mode 100644
index 000000000000..a781641a3b00
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/common.txt
@@ -0,0 +1,12 @@
+* Common properties of all MTD devices
+
+Optional properties:
+- label : name to assign to mtd. If omitted, the label is the MTD device name.
+
+Example:
+
+	flash@0 {
+		label = "System-firmware";
+
+		/* flash type specific properties */
+	};
-- 
2.7.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* [PATCH 2/3] dt-bindings: mtd: add a common label property to all mtd devices
@ 2017-01-16 13:27   ` Cédric Le Goater
  0 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 13:27 UTC (permalink / raw)
  To: linux-mtd
  Cc: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland, Cédric Le Goater

This can be used to easily identify a specific chip on a system with
multiple chips.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 Documentation/devicetree/bindings/mtd/common.txt | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/common.txt

diff --git a/Documentation/devicetree/bindings/mtd/common.txt b/Documentation/devicetree/bindings/mtd/common.txt
new file mode 100644
index 000000000000..a781641a3b00
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/common.txt
@@ -0,0 +1,12 @@
+* Common properties of all MTD devices
+
+Optional properties:
+- label : name to assign to mtd. If omitted, the label is the MTD device name.
+
+Example:
+
+	flash@0 {
+		label = "System-firmware";
+
+		/* flash type specific properties */
+	};
-- 
2.7.4

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

* [PATCH 3/3] mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l
  2017-01-16 13:27 ` Cédric Le Goater
@ 2017-01-16 13:27   ` Cédric Le Goater
  -1 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 13:27 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, Boris Brezillon, Robert Lippert, devicetree,
	Richard Weinberger, Marek Vasut, Robert Lippert, Rob Herring,
	Cédric Le Goater, Cyrille Pitchen, Brian Norris,
	David Woodhouse

From: Robert Lippert <roblip@gmail.com>

Signed-off-by: Robert Lippert <rlippert@google.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/mtd/spi-nor/spi-nor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index da7cd69d4857..775788f9828a 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -876,7 +876,7 @@ static const struct flash_info spi_nor_ids[] = {
 	{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
 	{ "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SECT_4K) },
 	{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
-	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ) },
+	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 	{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },
 
 	/* Micron */
-- 
2.7.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* [PATCH 3/3] mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l
@ 2017-01-16 13:27   ` Cédric Le Goater
  0 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 13:27 UTC (permalink / raw)
  To: linux-mtd
  Cc: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland, Robert Lippert, Robert Lippert,
	Cédric Le Goater

From: Robert Lippert <roblip@gmail.com>

Signed-off-by: Robert Lippert <rlippert@google.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/mtd/spi-nor/spi-nor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index da7cd69d4857..775788f9828a 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -876,7 +876,7 @@ static const struct flash_info spi_nor_ids[] = {
 	{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
 	{ "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SECT_4K) },
 	{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
-	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ) },
+	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 	{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },
 
 	/* Micron */
-- 
2.7.4

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
  2017-01-16 13:27   ` Cédric Le Goater
@ 2017-01-16 13:32       ` Boris Brezillon
  -1 siblings, 0 replies; 34+ messages in thread
From: Boris Brezillon @ 2017-01-16 13:32 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, David Woodhouse,
	Brian Norris, Marek Vasut, Richard Weinberger, Cyrille Pitchen,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland

On Mon, 16 Jan 2017 14:27:03 +0100
Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org> wrote:

> This can be used to easily identify a specific chip on a system with
> multiple chips.
> 
> Suggested-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Signed-off-by: Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org>

Acked-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

> ---
>  drivers/mtd/mtdcore.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 052772f7caef..bf61557b599d 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
>   */
>  static void mtd_set_dev_defaults(struct mtd_info *mtd)
>  {
> +	/*
> +	 * If DT support is enabled and we have a valid of_node pointer, try to
> +	 * extract the MTD name from the label property.
> +	 */
> +	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
> +		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
> +
>  	if (mtd->dev.parent) {
>  		if (!mtd->owner && mtd->dev.parent->driver)
>  			mtd->owner = mtd->dev.parent->driver->owner;

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
@ 2017-01-16 13:32       ` Boris Brezillon
  0 siblings, 0 replies; 34+ messages in thread
From: Boris Brezillon @ 2017-01-16 13:32 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-mtd, David Woodhouse, Brian Norris, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland

On Mon, 16 Jan 2017 14:27:03 +0100
Cédric Le Goater <clg@kaod.org> wrote:

> This can be used to easily identify a specific chip on a system with
> multiple chips.
> 
> Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> ---
>  drivers/mtd/mtdcore.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 052772f7caef..bf61557b599d 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
>   */
>  static void mtd_set_dev_defaults(struct mtd_info *mtd)
>  {
> +	/*
> +	 * If DT support is enabled and we have a valid of_node pointer, try to
> +	 * extract the MTD name from the label property.
> +	 */
> +	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
> +		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
> +
>  	if (mtd->dev.parent) {
>  		if (!mtd->owner && mtd->dev.parent->driver)
>  			mtd->owner = mtd->dev.parent->driver->owner;

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

* Re: [PATCH 2/3] dt-bindings: mtd: add a common label property to all mtd devices
  2017-01-16 13:27   ` Cédric Le Goater
@ 2017-01-16 13:52       ` Boris Brezillon
  -1 siblings, 0 replies; 34+ messages in thread
From: Boris Brezillon @ 2017-01-16 13:52 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, David Woodhouse,
	Brian Norris, Marek Vasut, Richard Weinberger, Cyrille Pitchen,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland

On Mon, 16 Jan 2017 14:27:04 +0100
Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org> wrote:

> This can be used to easily identify a specific chip on a system with
> multiple chips.
> 
> Signed-off-by: Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/mtd/common.txt | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mtd/common.txt
> 
> diff --git a/Documentation/devicetree/bindings/mtd/common.txt b/Documentation/devicetree/bindings/mtd/common.txt
> new file mode 100644
> index 000000000000..a781641a3b00
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/common.txt
> @@ -0,0 +1,12 @@
> +* Common properties of all MTD devices
> +
> +Optional properties:
> +- label : name to assign to mtd. If omitted, the label is the MTD device name.

Hm, the description is not really clear. How about:

"
- label: user-defined MTD device name. Can be used to assign user
  friendly names to MTD devices (instead of the flash model or flash
  controller based name) in order to ease flash device identification
  and/or describe what they are used for.
"

Otherwise,

Acked-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Thanks,

Boris

> +
> +Example:
> +
> +	flash@0 {
> +		label = "System-firmware";
> +
> +		/* flash type specific properties */
> +	};

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/3] dt-bindings: mtd: add a common label property to all mtd devices
@ 2017-01-16 13:52       ` Boris Brezillon
  0 siblings, 0 replies; 34+ messages in thread
From: Boris Brezillon @ 2017-01-16 13:52 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-mtd, David Woodhouse, Brian Norris, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland

On Mon, 16 Jan 2017 14:27:04 +0100
Cédric Le Goater <clg@kaod.org> wrote:

> This can be used to easily identify a specific chip on a system with
> multiple chips.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  Documentation/devicetree/bindings/mtd/common.txt | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mtd/common.txt
> 
> diff --git a/Documentation/devicetree/bindings/mtd/common.txt b/Documentation/devicetree/bindings/mtd/common.txt
> new file mode 100644
> index 000000000000..a781641a3b00
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/common.txt
> @@ -0,0 +1,12 @@
> +* Common properties of all MTD devices
> +
> +Optional properties:
> +- label : name to assign to mtd. If omitted, the label is the MTD device name.

Hm, the description is not really clear. How about:

"
- label: user-defined MTD device name. Can be used to assign user
  friendly names to MTD devices (instead of the flash model or flash
  controller based name) in order to ease flash device identification
  and/or describe what they are used for.
"

Otherwise,

Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>

Thanks,

Boris

> +
> +Example:
> +
> +	flash@0 {
> +		label = "System-firmware";
> +
> +		/* flash type specific properties */
> +	};

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

* Re: [PATCH 2/3] dt-bindings: mtd: add a common label property to all mtd devices
  2017-01-16 13:52       ` Boris Brezillon
@ 2017-01-16 14:39         ` Cédric Le Goater
  -1 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 14:39 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, David Woodhouse,
	Brian Norris, Marek Vasut, Richard Weinberger, Cyrille Pitchen,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland

On 01/16/2017 02:52 PM, Boris Brezillon wrote:
> On Mon, 16 Jan 2017 14:27:04 +0100
> Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org> wrote:
> 
>> This can be used to easily identify a specific chip on a system with
>> multiple chips.
>>
>> Signed-off-by: Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org>
>> ---
>>  Documentation/devicetree/bindings/mtd/common.txt | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/mtd/common.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mtd/common.txt b/Documentation/devicetree/bindings/mtd/common.txt
>> new file mode 100644
>> index 000000000000..a781641a3b00
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mtd/common.txt
>> @@ -0,0 +1,12 @@
>> +* Common properties of all MTD devices
>> +
>> +Optional properties:
>> +- label : name to assign to mtd. If omitted, the label is the MTD device name.
> 
> Hm, the description is not really clear. How about:
> 
> "
> - label: user-defined MTD device name. Can be used to assign user
>   friendly names to MTD devices (instead of the flash model or flash
>   controller based name) in order to ease flash device identification
>   and/or describe what they are used for.
> "

yes. I will use that in a v2.
 
Thanks,

C. 

> Otherwise,
> 
> Acked-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> 
> Thanks,
> 
> Boris
> 
>> +
>> +Example:
>> +
>> +	flash@0 {
>> +		label = "System-firmware";
>> +
>> +		/* flash type specific properties */
>> +	};
> 

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/3] dt-bindings: mtd: add a common label property to all mtd devices
@ 2017-01-16 14:39         ` Cédric Le Goater
  0 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 14:39 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: linux-mtd, David Woodhouse, Brian Norris, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland

On 01/16/2017 02:52 PM, Boris Brezillon wrote:
> On Mon, 16 Jan 2017 14:27:04 +0100
> Cédric Le Goater <clg@kaod.org> wrote:
> 
>> This can be used to easily identify a specific chip on a system with
>> multiple chips.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>  Documentation/devicetree/bindings/mtd/common.txt | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/mtd/common.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mtd/common.txt b/Documentation/devicetree/bindings/mtd/common.txt
>> new file mode 100644
>> index 000000000000..a781641a3b00
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mtd/common.txt
>> @@ -0,0 +1,12 @@
>> +* Common properties of all MTD devices
>> +
>> +Optional properties:
>> +- label : name to assign to mtd. If omitted, the label is the MTD device name.
> 
> Hm, the description is not really clear. How about:
> 
> "
> - label: user-defined MTD device name. Can be used to assign user
>   friendly names to MTD devices (instead of the flash model or flash
>   controller based name) in order to ease flash device identification
>   and/or describe what they are used for.
> "

yes. I will use that in a v2.
 
Thanks,

C. 

> Otherwise,
> 
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> 
> Thanks,
> 
> Boris
> 
>> +
>> +Example:
>> +
>> +	flash@0 {
>> +		label = "System-firmware";
>> +
>> +		/* flash type specific properties */
>> +	};
> 

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

* [PATCH v2 2/3] dt-bindings: mtd: add a common label property to all mtd devices
  2017-01-16 13:27   ` Cédric Le Goater
@ 2017-01-16 14:56     ` Cédric Le Goater
  -1 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 14:56 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, Boris Brezillon, devicetree, Richard Weinberger,
	Marek Vasut, Rob Herring, Cédric Le Goater, Cyrille Pitchen,
	Brian Norris, David Woodhouse

This can be used to easily identify a specific chip on a system with
multiple chips.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 Documentation/devicetree/bindings/mtd/common.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/common.txt

diff --git a/Documentation/devicetree/bindings/mtd/common.txt b/Documentation/devicetree/bindings/mtd/common.txt
new file mode 100644
index 000000000000..fc068b923d7a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/common.txt
@@ -0,0 +1,15 @@
+* Common properties of all MTD devices
+
+Optional properties:
+- label: user-defined MTD device name. Can be used to assign user
+  friendly names to MTD devices (instead of the flash model or flash
+  controller based name) in order to ease flash device identification
+  and/or describe what they are used for.
+
+Example:
+
+	flash@0 {
+		label = "System-firmware";
+
+		/* flash type specific properties */
+	};
-- 
2.7.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* [PATCH v2 2/3] dt-bindings: mtd: add a common label property to all mtd devices
@ 2017-01-16 14:56     ` Cédric Le Goater
  0 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 14:56 UTC (permalink / raw)
  To: linux-mtd
  Cc: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland, Cédric Le Goater

This can be used to easily identify a specific chip on a system with
multiple chips.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 Documentation/devicetree/bindings/mtd/common.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/common.txt

diff --git a/Documentation/devicetree/bindings/mtd/common.txt b/Documentation/devicetree/bindings/mtd/common.txt
new file mode 100644
index 000000000000..fc068b923d7a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/common.txt
@@ -0,0 +1,15 @@
+* Common properties of all MTD devices
+
+Optional properties:
+- label: user-defined MTD device name. Can be used to assign user
+  friendly names to MTD devices (instead of the flash model or flash
+  controller based name) in order to ease flash device identification
+  and/or describe what they are used for.
+
+Example:
+
+	flash@0 {
+		label = "System-firmware";
+
+		/* flash type specific properties */
+	};
-- 
2.7.4

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

* Re: [PATCH 3/3] mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l
  2017-01-16 13:27   ` Cédric Le Goater
@ 2017-01-16 16:15       ` Marek Vasut
  -1 siblings, 0 replies; 34+ messages in thread
From: Marek Vasut @ 2017-01-16 16:15 UTC (permalink / raw)
  To: Cédric Le Goater, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: David Woodhouse, Brian Norris, Boris Brezillon,
	Richard Weinberger, Cyrille Pitchen,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland,
	Robert Lippert, Robert Lippert

On 01/16/2017 02:27 PM, Cédric Le Goater wrote:
> From: Robert Lippert <roblip-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

1) Commit message missing
2) This is unrelated to the rest of the series, send separately please

> Signed-off-by: Robert Lippert <rlippert-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org>
> ---
>  drivers/mtd/spi-nor/spi-nor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index da7cd69d4857..775788f9828a 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -876,7 +876,7 @@ static const struct flash_info spi_nor_ids[] = {
>  	{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
>  	{ "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SECT_4K) },
>  	{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
> -	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ) },
> +	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
>  	{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },
>  
>  	/* Micron */
> 


-- 
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 3/3] mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l
@ 2017-01-16 16:15       ` Marek Vasut
  0 siblings, 0 replies; 34+ messages in thread
From: Marek Vasut @ 2017-01-16 16:15 UTC (permalink / raw)
  To: Cédric Le Goater, linux-mtd
  Cc: David Woodhouse, Brian Norris, Boris Brezillon,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland, Robert Lippert, Robert Lippert

On 01/16/2017 02:27 PM, Cédric Le Goater wrote:
> From: Robert Lippert <roblip@gmail.com>

1) Commit message missing
2) This is unrelated to the rest of the series, send separately please

> Signed-off-by: Robert Lippert <rlippert@google.com>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  drivers/mtd/spi-nor/spi-nor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index da7cd69d4857..775788f9828a 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -876,7 +876,7 @@ static const struct flash_info spi_nor_ids[] = {
>  	{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
>  	{ "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SECT_4K) },
>  	{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
> -	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ) },
> +	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
>  	{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },
>  
>  	/* Micron */
> 


-- 
Best regards,
Marek Vasut

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

* Re: [PATCH 3/3] mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l
  2017-01-16 16:15       ` Marek Vasut
@ 2017-01-16 16:39         ` Cédric Le Goater
  -1 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 16:39 UTC (permalink / raw)
  To: Marek Vasut, linux-mtd
  Cc: Mark Rutland, Boris Brezillon, Robert Lippert, devicetree,
	Richard Weinberger, Robert Lippert, Rob Herring, Cyrille Pitchen,
	Brian Norris, David Woodhouse

Hello Marek,

On 01/16/2017 05:15 PM, Marek Vasut wrote:
> On 01/16/2017 02:27 PM, Cédric Le Goater wrote:
>> From: Robert Lippert <roblip@gmail.com>
> 
> 1) Commit message missing
> 2) This is unrelated to the rest of the series, send separately please

ok. I will do that. Rob, I will take ownership if you don't mind.

Thanks,

C.


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH 3/3] mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l
@ 2017-01-16 16:39         ` Cédric Le Goater
  0 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-16 16:39 UTC (permalink / raw)
  To: Marek Vasut, linux-mtd
  Cc: David Woodhouse, Brian Norris, Boris Brezillon,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland, Robert Lippert, Robert Lippert

Hello Marek,

On 01/16/2017 05:15 PM, Marek Vasut wrote:
> On 01/16/2017 02:27 PM, Cédric Le Goater wrote:
>> From: Robert Lippert <roblip@gmail.com>
> 
> 1) Commit message missing
> 2) This is unrelated to the rest of the series, send separately please

ok. I will do that. Rob, I will take ownership if you don't mind.

Thanks,

C.

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

* Re: [PATCH 3/3] mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l
  2017-01-16 16:39         ` Cédric Le Goater
@ 2017-01-17 18:19             ` Rob Lippert
  -1 siblings, 0 replies; 34+ messages in thread
From: Rob Lippert @ 2017-01-17 18:19 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Marek Vasut, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	David Woodhouse, Brian Norris, Boris Brezillon,
	Richard Weinberger, Cyrille Pitchen,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland,
	Robert Lippert

On Mon, Jan 16, 2017 at 8:39 AM, Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org> wrote:
>
> Hello Marek,
>
> On 01/16/2017 05:15 PM, Marek Vasut wrote:
> > On 01/16/2017 02:27 PM, Cédric Le Goater wrote:
> >> From: Robert Lippert <roblip-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> >
> > 1) Commit message missing
> > 2) This is unrelated to the rest of the series, send separately please
>
> ok. I will do that. Rob, I will take ownership if you don't mind.

Yep that sounds great to me, thanks for your help!

-Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 3/3] mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l
@ 2017-01-17 18:19             ` Rob Lippert
  0 siblings, 0 replies; 34+ messages in thread
From: Rob Lippert @ 2017-01-17 18:19 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Marek Vasut, linux-mtd, David Woodhouse, Brian Norris,
	Boris Brezillon, Richard Weinberger, Cyrille Pitchen, devicetree,
	Rob Herring, Mark Rutland, Robert Lippert

On Mon, Jan 16, 2017 at 8:39 AM, Cédric Le Goater <clg@kaod.org> wrote:
>
> Hello Marek,
>
> On 01/16/2017 05:15 PM, Marek Vasut wrote:
> > On 01/16/2017 02:27 PM, Cédric Le Goater wrote:
> >> From: Robert Lippert <roblip@gmail.com>
> >
> > 1) Commit message missing
> > 2) This is unrelated to the rest of the series, send separately please
>
> ok. I will do that. Rob, I will take ownership if you don't mind.

Yep that sounds great to me, thanks for your help!

-Rob

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

* Re: [PATCH v2 2/3] dt-bindings: mtd: add a common label property to all mtd devices
  2017-01-16 14:56     ` Cédric Le Goater
@ 2017-01-19 16:42       ` Rob Herring
  -1 siblings, 0 replies; 34+ messages in thread
From: Rob Herring @ 2017-01-19 16:42 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Mark Rutland, Boris Brezillon, devicetree, Richard Weinberger,
	Marek Vasut, linux-mtd, Cyrille Pitchen, Brian Norris,
	David Woodhouse

On Mon, Jan 16, 2017 at 03:56:40PM +0100, Cédric Le Goater wrote:
> This can be used to easily identify a specific chip on a system with
> multiple chips.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
>  Documentation/devicetree/bindings/mtd/common.txt | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mtd/common.txt

Acked-by: Rob Herring <robh@kernel.org>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH v2 2/3] dt-bindings: mtd: add a common label property to all mtd devices
@ 2017-01-19 16:42       ` Rob Herring
  0 siblings, 0 replies; 34+ messages in thread
From: Rob Herring @ 2017-01-19 16:42 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-mtd, David Woodhouse, Brian Norris, Boris Brezillon,
	Marek Vasut, Richard Weinberger, Cyrille Pitchen, devicetree,
	Mark Rutland

On Mon, Jan 16, 2017 at 03:56:40PM +0100, Cédric Le Goater wrote:
> This can be used to easily identify a specific chip on a system with
> multiple chips.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
>  Documentation/devicetree/bindings/mtd/common.txt | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mtd/common.txt

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
  2017-01-16 13:27   ` Cédric Le Goater
@ 2017-01-24 14:13       ` Boris Brezillon
  -1 siblings, 0 replies; 34+ messages in thread
From: Boris Brezillon @ 2017-01-24 14:13 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, David Woodhouse,
	Brian Norris, Marek Vasut, Richard Weinberger, Cyrille Pitchen,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland

Hi Cédric,

On Mon, 16 Jan 2017 14:27:03 +0100
Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org> wrote:

> This can be used to easily identify a specific chip on a system with
> multiple chips.
> 
> Suggested-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Signed-off-by: Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org>
> ---
>  drivers/mtd/mtdcore.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 052772f7caef..bf61557b599d 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
>   */
>  static void mtd_set_dev_defaults(struct mtd_info *mtd)
>  {
> +	/*
> +	 * If DT support is enabled and we have a valid of_node pointer, try to
> +	 * extract the MTD name from the label property.
> +	 */
> +	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
> +		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
> +

I realize this kind of thing would be better placed in mtd_set_of_node()
(see the patch below). Modifying the mtd->name pointer in the back of
MTD drivers is not such a good idea (suppose the driver allocated the
memory with a regular kmalloc() and tries to free mtd->name in the remove
path).

If we move that to mtd_set_of_node(), drivers that wants to support this
label property just have to check if mtd->name is NULL (after calling
mtd_set_of_node() or nand_set_flash_node()) before assigning a default
name.
For unmodified drivers we keep the existing behavior: they'll just
unconditionally override mtd->name with their own value (which might or
might not be dynamically allocated).

>  	if (mtd->dev.parent) {
>  		if (!mtd->owner && mtd->dev.parent->driver)
>  			mtd->owner = mtd->dev.parent->driver->owner;

--->8---
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 13f8052b9ff9..a12b68f941e3 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -385,6 +385,8 @@ static inline void mtd_set_of_node(struct mtd_info *mtd,
                                   struct device_node *np)
 {
        mtd->dev.of_node = np;
+
+       of_property_read_string(np, "label", mtd->name);
 }
 
 static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
@ 2017-01-24 14:13       ` Boris Brezillon
  0 siblings, 0 replies; 34+ messages in thread
From: Boris Brezillon @ 2017-01-24 14:13 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-mtd, David Woodhouse, Brian Norris, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland

Hi Cédric,

On Mon, 16 Jan 2017 14:27:03 +0100
Cédric Le Goater <clg@kaod.org> wrote:

> This can be used to easily identify a specific chip on a system with
> multiple chips.
> 
> Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  drivers/mtd/mtdcore.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 052772f7caef..bf61557b599d 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
>   */
>  static void mtd_set_dev_defaults(struct mtd_info *mtd)
>  {
> +	/*
> +	 * If DT support is enabled and we have a valid of_node pointer, try to
> +	 * extract the MTD name from the label property.
> +	 */
> +	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
> +		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
> +

I realize this kind of thing would be better placed in mtd_set_of_node()
(see the patch below). Modifying the mtd->name pointer in the back of
MTD drivers is not such a good idea (suppose the driver allocated the
memory with a regular kmalloc() and tries to free mtd->name in the remove
path).

If we move that to mtd_set_of_node(), drivers that wants to support this
label property just have to check if mtd->name is NULL (after calling
mtd_set_of_node() or nand_set_flash_node()) before assigning a default
name.
For unmodified drivers we keep the existing behavior: they'll just
unconditionally override mtd->name with their own value (which might or
might not be dynamically allocated).

>  	if (mtd->dev.parent) {
>  		if (!mtd->owner && mtd->dev.parent->driver)
>  			mtd->owner = mtd->dev.parent->driver->owner;

--->8---
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 13f8052b9ff9..a12b68f941e3 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -385,6 +385,8 @@ static inline void mtd_set_of_node(struct mtd_info *mtd,
                                   struct device_node *np)
 {
        mtd->dev.of_node = np;
+
+       of_property_read_string(np, "label", mtd->name);
 }
 
 static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
  2017-01-24 14:13       ` Boris Brezillon
@ 2017-01-24 14:27         ` Boris Brezillon
  -1 siblings, 0 replies; 34+ messages in thread
From: Boris Brezillon @ 2017-01-24 14:27 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Mark Rutland, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Richard Weinberger, Marek Vasut, Rob Herring,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Cyrille Pitchen,
	Brian Norris, David Woodhouse

On Tue, 24 Jan 2017 15:13:53 +0100
Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> wrote:

> >  	if (mtd->dev.parent) {
> >  		if (!mtd->owner && mtd->dev.parent->driver)
> >  			mtd->owner = mtd->dev.parent->driver->owner;  
> 
> --->8---  
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 13f8052b9ff9..a12b68f941e3 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -385,6 +385,8 @@ static inline void mtd_set_of_node(struct mtd_info *mtd,
>                                    struct device_node *np)
>  {
>         mtd->dev.of_node = np;
> +
> +       of_property_read_string(np, "label", mtd->name);
>  }
>  
>  static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)

Sorry, I forgot to compile test this change. Here is a valid version:

--->8---
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 13f8052b9ff9..581057f8d9a5 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -24,6 +24,7 @@
 #include <linux/uio.h>
 #include <linux/notifier.h>
 #include <linux/device.h>
+#include <linux/of.h>
 
 #include <mtd/mtd-abi.h>
 
@@ -385,6 +386,8 @@ static inline void mtd_set_of_node(struct mtd_info *mtd,
                                   struct device_node *np)
 {
        mtd->dev.of_node = np;
+
+       of_property_read_string(np, "label", &mtd->name);
 }
 
 static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
@ 2017-01-24 14:27         ` Boris Brezillon
  0 siblings, 0 replies; 34+ messages in thread
From: Boris Brezillon @ 2017-01-24 14:27 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Mark Rutland, devicetree, Richard Weinberger, Marek Vasut,
	Rob Herring, linux-mtd, Cyrille Pitchen, Brian Norris,
	David Woodhouse

On Tue, 24 Jan 2017 15:13:53 +0100
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:

> >  	if (mtd->dev.parent) {
> >  		if (!mtd->owner && mtd->dev.parent->driver)
> >  			mtd->owner = mtd->dev.parent->driver->owner;  
> 
> --->8---  
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 13f8052b9ff9..a12b68f941e3 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -385,6 +385,8 @@ static inline void mtd_set_of_node(struct mtd_info *mtd,
>                                    struct device_node *np)
>  {
>         mtd->dev.of_node = np;
> +
> +       of_property_read_string(np, "label", mtd->name);
>  }
>  
>  static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)

Sorry, I forgot to compile test this change. Here is a valid version:

--->8---
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 13f8052b9ff9..581057f8d9a5 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -24,6 +24,7 @@
 #include <linux/uio.h>
 #include <linux/notifier.h>
 #include <linux/device.h>
+#include <linux/of.h>
 
 #include <mtd/mtd-abi.h>
 
@@ -385,6 +386,8 @@ static inline void mtd_set_of_node(struct mtd_info *mtd,
                                   struct device_node *np)
 {
        mtd->dev.of_node = np;
+
+       of_property_read_string(np, "label", &mtd->name);
 }
 
 static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
  2017-01-24 14:13       ` Boris Brezillon
@ 2017-01-25 16:47         ` Cédric Le Goater
  -1 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-25 16:47 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Mark Rutland, devicetree, Richard Weinberger, Marek Vasut,
	Rob Herring, linux-mtd, Cyrille Pitchen, Brian Norris,
	David Woodhouse

On 01/24/2017 03:13 PM, Boris Brezillon wrote:
> Hi Cédric,
> 
> On Mon, 16 Jan 2017 14:27:03 +0100
> Cédric Le Goater <clg@kaod.org> wrote:
> 
>> This can be used to easily identify a specific chip on a system with
>> multiple chips.
>>
>> Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>  drivers/mtd/mtdcore.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
>> index 052772f7caef..bf61557b599d 100644
>> --- a/drivers/mtd/mtdcore.c
>> +++ b/drivers/mtd/mtdcore.c
>> @@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
>>   */
>>  static void mtd_set_dev_defaults(struct mtd_info *mtd)
>>  {
>> +	/*
>> +	 * If DT support is enabled and we have a valid of_node pointer, try to
>> +	 * extract the MTD name from the label property.
>> +	 */
>> +	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
>> +		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
>> +
> 
> I realize this kind of thing would be better placed in mtd_set_of_node()
> (see the patch below). Modifying the mtd->name pointer in the back of
> MTD drivers is not such a good idea (suppose the driver allocated the
> memory with a regular kmalloc() and tries to free mtd->name in the remove
> path).
> 
> If we move that to mtd_set_of_node(), drivers that wants to support this
> label property just have to check if mtd->name is NULL (after calling
> mtd_set_of_node() or nand_set_flash_node()) before assigning a default
> name.
> For unmodified drivers we keep the existing behavior: they'll just
> unconditionally override mtd->name with their own value (which might or
> might not be dynamically allocated).

ok. So the expected behavior looks correct to me, but adding a call to 
of_property_read_string() in the inline below feels a little hacky. 
Doesn't it ? 

May be we need an extra check on IS_ENABLED(CONFIG_OF) also ? 

Thanks,

C.

>>  	if (mtd->dev.parent) {
>>  		if (!mtd->owner && mtd->dev.parent->driver)
>>  			mtd->owner = mtd->dev.parent->driver->owner;
> 
> --->8---
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 13f8052b9ff9..a12b68f941e3 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -385,6 +385,8 @@ static inline void mtd_set_of_node(struct mtd_info *mtd,
>                                    struct device_node *np)
>  {
>         mtd->dev.of_node = np;
> +
> +       of_property_read_string(np, "label", mtd->name);
>  }
>  
>  static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
> 
> 


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
@ 2017-01-25 16:47         ` Cédric Le Goater
  0 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-25 16:47 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: linux-mtd, David Woodhouse, Brian Norris, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland

On 01/24/2017 03:13 PM, Boris Brezillon wrote:
> Hi Cédric,
> 
> On Mon, 16 Jan 2017 14:27:03 +0100
> Cédric Le Goater <clg@kaod.org> wrote:
> 
>> This can be used to easily identify a specific chip on a system with
>> multiple chips.
>>
>> Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>  drivers/mtd/mtdcore.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
>> index 052772f7caef..bf61557b599d 100644
>> --- a/drivers/mtd/mtdcore.c
>> +++ b/drivers/mtd/mtdcore.c
>> @@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
>>   */
>>  static void mtd_set_dev_defaults(struct mtd_info *mtd)
>>  {
>> +	/*
>> +	 * If DT support is enabled and we have a valid of_node pointer, try to
>> +	 * extract the MTD name from the label property.
>> +	 */
>> +	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
>> +		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
>> +
> 
> I realize this kind of thing would be better placed in mtd_set_of_node()
> (see the patch below). Modifying the mtd->name pointer in the back of
> MTD drivers is not such a good idea (suppose the driver allocated the
> memory with a regular kmalloc() and tries to free mtd->name in the remove
> path).
> 
> If we move that to mtd_set_of_node(), drivers that wants to support this
> label property just have to check if mtd->name is NULL (after calling
> mtd_set_of_node() or nand_set_flash_node()) before assigning a default
> name.
> For unmodified drivers we keep the existing behavior: they'll just
> unconditionally override mtd->name with their own value (which might or
> might not be dynamically allocated).

ok. So the expected behavior looks correct to me, but adding a call to 
of_property_read_string() in the inline below feels a little hacky. 
Doesn't it ? 

May be we need an extra check on IS_ENABLED(CONFIG_OF) also ? 

Thanks,

C.

>>  	if (mtd->dev.parent) {
>>  		if (!mtd->owner && mtd->dev.parent->driver)
>>  			mtd->owner = mtd->dev.parent->driver->owner;
> 
> --->8---
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 13f8052b9ff9..a12b68f941e3 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -385,6 +385,8 @@ static inline void mtd_set_of_node(struct mtd_info *mtd,
>                                    struct device_node *np)
>  {
>         mtd->dev.of_node = np;
> +
> +       of_property_read_string(np, "label", mtd->name);
>  }
>  
>  static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
> 
> 

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
  2017-01-25 16:47         ` Cédric Le Goater
@ 2017-01-25 16:51           ` Boris Brezillon
  -1 siblings, 0 replies; 34+ messages in thread
From: Boris Brezillon @ 2017-01-25 16:51 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Mark Rutland, devicetree, Richard Weinberger, Marek Vasut,
	Rob Herring, linux-mtd, Cyrille Pitchen, Brian Norris,
	David Woodhouse

On Wed, 25 Jan 2017 17:47:13 +0100
Cédric Le Goater <clg@kaod.org> wrote:

> On 01/24/2017 03:13 PM, Boris Brezillon wrote:
> > Hi Cédric,
> > 
> > On Mon, 16 Jan 2017 14:27:03 +0100
> > Cédric Le Goater <clg@kaod.org> wrote:
> >   
> >> This can be used to easily identify a specific chip on a system with
> >> multiple chips.
> >>
> >> Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> >> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> >> ---
> >>  drivers/mtd/mtdcore.c | 7 +++++++
> >>  1 file changed, 7 insertions(+)
> >>
> >> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> >> index 052772f7caef..bf61557b599d 100644
> >> --- a/drivers/mtd/mtdcore.c
> >> +++ b/drivers/mtd/mtdcore.c
> >> @@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
> >>   */
> >>  static void mtd_set_dev_defaults(struct mtd_info *mtd)
> >>  {
> >> +	/*
> >> +	 * If DT support is enabled and we have a valid of_node pointer, try to
> >> +	 * extract the MTD name from the label property.
> >> +	 */
> >> +	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
> >> +		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
> >> +  
> > 
> > I realize this kind of thing would be better placed in mtd_set_of_node()
> > (see the patch below). Modifying the mtd->name pointer in the back of
> > MTD drivers is not such a good idea (suppose the driver allocated the
> > memory with a regular kmalloc() and tries to free mtd->name in the remove
> > path).
> > 
> > If we move that to mtd_set_of_node(), drivers that wants to support this
> > label property just have to check if mtd->name is NULL (after calling
> > mtd_set_of_node() or nand_set_flash_node()) before assigning a default
> > name.
> > For unmodified drivers we keep the existing behavior: they'll just
> > unconditionally override mtd->name with their own value (which might or
> > might not be dynamically allocated).  
> 
> ok. So the expected behavior looks correct to me, but adding a call to 
> of_property_read_string() in the inline below feels a little hacky. 
> Doesn't it ? 
> 
> May be we need an extra check on IS_ENABLED(CONFIG_OF) also ? 

This is all safe, because the of.h header defines stubs if CONFIG_OF is
not set. That just means the name will be unchanged, but you shouldn't
have any problem (neither as compilation time nor at runtime).

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
@ 2017-01-25 16:51           ` Boris Brezillon
  0 siblings, 0 replies; 34+ messages in thread
From: Boris Brezillon @ 2017-01-25 16:51 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-mtd, David Woodhouse, Brian Norris, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland

On Wed, 25 Jan 2017 17:47:13 +0100
Cédric Le Goater <clg@kaod.org> wrote:

> On 01/24/2017 03:13 PM, Boris Brezillon wrote:
> > Hi Cédric,
> > 
> > On Mon, 16 Jan 2017 14:27:03 +0100
> > Cédric Le Goater <clg@kaod.org> wrote:
> >   
> >> This can be used to easily identify a specific chip on a system with
> >> multiple chips.
> >>
> >> Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> >> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> >> ---
> >>  drivers/mtd/mtdcore.c | 7 +++++++
> >>  1 file changed, 7 insertions(+)
> >>
> >> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> >> index 052772f7caef..bf61557b599d 100644
> >> --- a/drivers/mtd/mtdcore.c
> >> +++ b/drivers/mtd/mtdcore.c
> >> @@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
> >>   */
> >>  static void mtd_set_dev_defaults(struct mtd_info *mtd)
> >>  {
> >> +	/*
> >> +	 * If DT support is enabled and we have a valid of_node pointer, try to
> >> +	 * extract the MTD name from the label property.
> >> +	 */
> >> +	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
> >> +		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
> >> +  
> > 
> > I realize this kind of thing would be better placed in mtd_set_of_node()
> > (see the patch below). Modifying the mtd->name pointer in the back of
> > MTD drivers is not such a good idea (suppose the driver allocated the
> > memory with a regular kmalloc() and tries to free mtd->name in the remove
> > path).
> > 
> > If we move that to mtd_set_of_node(), drivers that wants to support this
> > label property just have to check if mtd->name is NULL (after calling
> > mtd_set_of_node() or nand_set_flash_node()) before assigning a default
> > name.
> > For unmodified drivers we keep the existing behavior: they'll just
> > unconditionally override mtd->name with their own value (which might or
> > might not be dynamically allocated).  
> 
> ok. So the expected behavior looks correct to me, but adding a call to 
> of_property_read_string() in the inline below feels a little hacky. 
> Doesn't it ? 
> 
> May be we need an extra check on IS_ENABLED(CONFIG_OF) also ? 

This is all safe, because the of.h header defines stubs if CONFIG_OF is
not set. That just means the name will be unchanged, but you shouldn't
have any problem (neither as compilation time nor at runtime).

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
  2017-01-25 16:51           ` Boris Brezillon
@ 2017-01-25 16:53             ` Cédric Le Goater
  -1 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-25 16:53 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, David Woodhouse,
	Brian Norris, Marek Vasut, Richard Weinberger, Cyrille Pitchen,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland

On 01/25/2017 05:51 PM, Boris Brezillon wrote:
> On Wed, 25 Jan 2017 17:47:13 +0100
> Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org> wrote:
> 
>> On 01/24/2017 03:13 PM, Boris Brezillon wrote:
>>> Hi Cédric,
>>>
>>> On Mon, 16 Jan 2017 14:27:03 +0100
>>> Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org> wrote:
>>>   
>>>> This can be used to easily identify a specific chip on a system with
>>>> multiple chips.
>>>>
>>>> Suggested-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>>>> Signed-off-by: Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org>
>>>> ---
>>>>  drivers/mtd/mtdcore.c | 7 +++++++
>>>>  1 file changed, 7 insertions(+)
>>>>
>>>> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
>>>> index 052772f7caef..bf61557b599d 100644
>>>> --- a/drivers/mtd/mtdcore.c
>>>> +++ b/drivers/mtd/mtdcore.c
>>>> @@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
>>>>   */
>>>>  static void mtd_set_dev_defaults(struct mtd_info *mtd)
>>>>  {
>>>> +	/*
>>>> +	 * If DT support is enabled and we have a valid of_node pointer, try to
>>>> +	 * extract the MTD name from the label property.
>>>> +	 */
>>>> +	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
>>>> +		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
>>>> +  
>>>
>>> I realize this kind of thing would be better placed in mtd_set_of_node()
>>> (see the patch below). Modifying the mtd->name pointer in the back of
>>> MTD drivers is not such a good idea (suppose the driver allocated the
>>> memory with a regular kmalloc() and tries to free mtd->name in the remove
>>> path).
>>>
>>> If we move that to mtd_set_of_node(), drivers that wants to support this
>>> label property just have to check if mtd->name is NULL (after calling
>>> mtd_set_of_node() or nand_set_flash_node()) before assigning a default
>>> name.
>>> For unmodified drivers we keep the existing behavior: they'll just
>>> unconditionally override mtd->name with their own value (which might or
>>> might not be dynamically allocated).  
>>
>> ok. So the expected behavior looks correct to me, but adding a call to 
>> of_property_read_string() in the inline below feels a little hacky. 
>> Doesn't it ? 
>>
>> May be we need an extra check on IS_ENABLED(CONFIG_OF) also ? 
> 
> This is all safe, because the of.h header defines stubs if CONFIG_OF is
> not set. That just means the name will be unchanged, but you shouldn't
> have any problem (neither as compilation time nor at runtime).
> 

ok. I will cook a v2 with your proposal then.

Thanks,

C.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/3] mtd: name the mtd device with an optional label property
@ 2017-01-25 16:53             ` Cédric Le Goater
  0 siblings, 0 replies; 34+ messages in thread
From: Cédric Le Goater @ 2017-01-25 16:53 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: linux-mtd, David Woodhouse, Brian Norris, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, devicetree, Rob Herring,
	Mark Rutland

On 01/25/2017 05:51 PM, Boris Brezillon wrote:
> On Wed, 25 Jan 2017 17:47:13 +0100
> Cédric Le Goater <clg@kaod.org> wrote:
> 
>> On 01/24/2017 03:13 PM, Boris Brezillon wrote:
>>> Hi Cédric,
>>>
>>> On Mon, 16 Jan 2017 14:27:03 +0100
>>> Cédric Le Goater <clg@kaod.org> wrote:
>>>   
>>>> This can be used to easily identify a specific chip on a system with
>>>> multiple chips.
>>>>
>>>> Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
>>>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>>>> ---
>>>>  drivers/mtd/mtdcore.c | 7 +++++++
>>>>  1 file changed, 7 insertions(+)
>>>>
>>>> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
>>>> index 052772f7caef..bf61557b599d 100644
>>>> --- a/drivers/mtd/mtdcore.c
>>>> +++ b/drivers/mtd/mtdcore.c
>>>> @@ -654,6 +654,13 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
>>>>   */
>>>>  static void mtd_set_dev_defaults(struct mtd_info *mtd)
>>>>  {
>>>> +	/*
>>>> +	 * If DT support is enabled and we have a valid of_node pointer, try to
>>>> +	 * extract the MTD name from the label property.
>>>> +	 */
>>>> +	if (IS_ENABLED(CONFIG_OF) && mtd->dev.of_node)
>>>> +		of_property_read_string(mtd->dev.of_node, "label", &mtd->name);
>>>> +  
>>>
>>> I realize this kind of thing would be better placed in mtd_set_of_node()
>>> (see the patch below). Modifying the mtd->name pointer in the back of
>>> MTD drivers is not such a good idea (suppose the driver allocated the
>>> memory with a regular kmalloc() and tries to free mtd->name in the remove
>>> path).
>>>
>>> If we move that to mtd_set_of_node(), drivers that wants to support this
>>> label property just have to check if mtd->name is NULL (after calling
>>> mtd_set_of_node() or nand_set_flash_node()) before assigning a default
>>> name.
>>> For unmodified drivers we keep the existing behavior: they'll just
>>> unconditionally override mtd->name with their own value (which might or
>>> might not be dynamically allocated).  
>>
>> ok. So the expected behavior looks correct to me, but adding a call to 
>> of_property_read_string() in the inline below feels a little hacky. 
>> Doesn't it ? 
>>
>> May be we need an extra check on IS_ENABLED(CONFIG_OF) also ? 
> 
> This is all safe, because the of.h header defines stubs if CONFIG_OF is
> not set. That just means the name will be unchanged, but you shouldn't
> have any problem (neither as compilation time nor at runtime).
> 

ok. I will cook a v2 with your proposal then.

Thanks,

C.

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

end of thread, other threads:[~2017-01-25 16:54 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-16 13:27 [PATCH 0/3] Add a "label" property to the mtd device Cédric Le Goater
2017-01-16 13:27 ` Cédric Le Goater
2017-01-16 13:27 ` [PATCH 1/3] mtd: name the mtd device with an optional label property Cédric Le Goater
2017-01-16 13:27   ` Cédric Le Goater
     [not found]   ` <1484573225-19095-2-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2017-01-16 13:32     ` Boris Brezillon
2017-01-16 13:32       ` Boris Brezillon
2017-01-24 14:13     ` Boris Brezillon
2017-01-24 14:13       ` Boris Brezillon
2017-01-24 14:27       ` Boris Brezillon
2017-01-24 14:27         ` Boris Brezillon
2017-01-25 16:47       ` Cédric Le Goater
2017-01-25 16:47         ` Cédric Le Goater
2017-01-25 16:51         ` Boris Brezillon
2017-01-25 16:51           ` Boris Brezillon
2017-01-25 16:53           ` Cédric Le Goater
2017-01-25 16:53             ` Cédric Le Goater
2017-01-16 13:27 ` [PATCH 2/3] dt-bindings: mtd: add a common label property to all mtd devices Cédric Le Goater
2017-01-16 13:27   ` Cédric Le Goater
     [not found]   ` <1484573225-19095-3-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2017-01-16 13:52     ` Boris Brezillon
2017-01-16 13:52       ` Boris Brezillon
2017-01-16 14:39       ` Cédric Le Goater
2017-01-16 14:39         ` Cédric Le Goater
2017-01-16 14:56   ` [PATCH v2 " Cédric Le Goater
2017-01-16 14:56     ` Cédric Le Goater
2017-01-19 16:42     ` Rob Herring
2017-01-19 16:42       ` Rob Herring
2017-01-16 13:27 ` [PATCH 3/3] mtd: spi-nor: add SPI_NOR_DUAL_READ to mx66l51235l Cédric Le Goater
2017-01-16 13:27   ` Cédric Le Goater
     [not found]   ` <1484573225-19095-4-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2017-01-16 16:15     ` Marek Vasut
2017-01-16 16:15       ` Marek Vasut
2017-01-16 16:39       ` Cédric Le Goater
2017-01-16 16:39         ` Cédric Le Goater
     [not found]         ` <77542f12-781d-73a4-4b72-01a00c5abdd0-Bxea+6Xhats@public.gmane.org>
2017-01-17 18:19           ` Rob Lippert
2017-01-17 18:19             ` Rob Lippert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.