mtd: spi-nor: sysfs: hide the flash name if not set
authorJaimeLiao <jaimeliao@mxic.com.tw>
Fri, 15 Dec 2023 08:21:37 +0000 (10:21 +0200)
committerTudor Ambarus <tudor.ambarus@linaro.org>
Tue, 19 Dec 2023 03:08:23 +0000 (05:08 +0200)
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>
Reviewed-by: Michael Walle <michael@walle.cc>
[ta: update commit subject and description and the sysfs description]
Link: https://lore.kernel.org/r/20231215082138.16063-4-tudor.ambarus@linaro.org
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
drivers/mtd/spi-nor/sysfs.c

index c800621eff95f6ab87f91ec9bde677f7df51ee6b..9ed5582ddea2200349c9d326fe4e196fc690c035 100644 (file)
@@ -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 optional. User space should not rely on
+               it to be present or even correct. Instead, user space
+               should read the jedec_id attribute.
 
 What:          /sys/bus/spi/devices/.../spi-nor/sfdp
 Date:          April 2021
index 2dfdc555a69faf6392e9deb6110b88a82968a507..96064e4babf01f6950c81586764386e7671cbf97 100644 (file)
@@ -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;