diff mbox series

[3/4] mtd: spi-nor: sysfs: hide the flash name if not set

Message ID 20231215082138.16063-4-tudor.ambarus@linaro.org
State Accepted
Delegated to: Ambarus Tudor
Headers show
Series mtd: spi-nor: mark the flash name as obsolete | expand

Commit Message

Tudor Ambarus Dec. 15, 2023, 8:21 a.m. UTC
From: JaimeLiao <jaimeliao@mxic.com.tw>

The flash name is not reliable as we saw flash ID collisions.
Hide the flash name if not set.

Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
[ta: update commit subject and description]
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
 Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor | 3 +++
 drivers/mtd/spi-nor/sysfs.c                             | 2 ++
 2 files changed, 5 insertions(+)

Comments

Michael Walle Dec. 18, 2023, 12:11 p.m. UTC | #1
Am 2023-12-15 09:21, schrieb Tudor Ambarus:
> From: JaimeLiao <jaimeliao@mxic.com.tw>
> 
> The flash name is not reliable as we saw flash ID collisions.
> Hide the flash name if not set.
> 
> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
> [ta: update commit subject and description]
> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>

Great!

Reviewed-by: Michael Walle <michael@walle.cc>

-michael
Pratyush Yadav Jan. 29, 2024, 1:24 p.m. UTC | #2
On Fri, Dec 15 2023, Tudor Ambarus wrote:

> From: JaimeLiao <jaimeliao@mxic.com.tw>
>
> The flash name is not reliable as we saw flash ID collisions.
> Hide the flash name if not set.
>
> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
> [ta: update commit subject and description]
> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> ---
>  Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor | 3 +++
>  drivers/mtd/spi-nor/sysfs.c                             | 2 ++
>  2 files changed, 5 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor b/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
> index c800621eff95..6d7be97bf7d1 100644
> --- a/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
> +++ b/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
> @@ -25,6 +25,9 @@ KernelVersion:	5.14
>  Contact:	linux-mtd@lists.infradead.org
>  Description:	(RO) Part name of the SPI NOR flash.
>  
> +		The attribute is not present if the jedec_id founded in
> +		ID table but flash name didn't include in it.

Nitpick: strange sentence construction makes it a bit confusing.
Perhaps:

    The attribute is not present if the JEDEC ID table for the flash
    does not include its name.

> +
>  
>  What:		/sys/bus/spi/devices/.../spi-nor/sfdp
>  Date:		April 2021
> diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c
> index 2dfdc555a69f..96064e4babf0 100644
> --- a/drivers/mtd/spi-nor/sysfs.c
> +++ b/drivers/mtd/spi-nor/sysfs.c
> @@ -78,6 +78,8 @@ static umode_t spi_nor_sysfs_is_visible(struct kobject *kobj,
>  
>  	if (attr == &dev_attr_manufacturer.attr && !nor->manufacturer)
>  		return 0;
> +	if (attr == &dev_attr_partname.attr && !nor->info->name)
> +		return 0;

Do you want to show the name for the "spi-nor-generic" flash? If not
then perhaps drop its name as well?

>  	if (attr == &dev_attr_jedec_id.attr && !nor->info->id && !nor->id)
>  		return 0;
diff mbox series

Patch

diff --git a/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor b/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
index c800621eff95..6d7be97bf7d1 100644
--- a/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
+++ b/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
@@ -25,6 +25,9 @@  KernelVersion:	5.14
 Contact:	linux-mtd@lists.infradead.org
 Description:	(RO) Part name of the SPI NOR flash.
 
+		The attribute is not present if the jedec_id founded in
+		ID table but flash name didn't include in it.
+
 
 What:		/sys/bus/spi/devices/.../spi-nor/sfdp
 Date:		April 2021
diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c
index 2dfdc555a69f..96064e4babf0 100644
--- a/drivers/mtd/spi-nor/sysfs.c
+++ b/drivers/mtd/spi-nor/sysfs.c
@@ -78,6 +78,8 @@  static umode_t spi_nor_sysfs_is_visible(struct kobject *kobj,
 
 	if (attr == &dev_attr_manufacturer.attr && !nor->manufacturer)
 		return 0;
+	if (attr == &dev_attr_partname.attr && !nor->info->name)
+		return 0;
 	if (attr == &dev_attr_jedec_id.attr && !nor->info->id && !nor->id)
 		return 0;