[PATCH v2 2/7] mtd: spi-nor: sysfs: hide manufacturer if it is not set
Michael Walle
michael at walle.cc
Wed Aug 10 15:06:49 PDT 2022
The manufacturer may be optional when pure SFDP flashes are supported.
Hide the sysfs property if no manufacturer is set.
Signed-off-by: Michael Walle <michael at walle.cc>
Reviewed-by: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>
---
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 e9ef69aef20b..c800621eff95 100644
--- a/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
+++ b/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor
@@ -15,6 +15,9 @@ KernelVersion: 5.14
Contact: linux-mtd at lists.infradead.org
Description: (RO) Manufacturer of the SPI NOR flash.
+ The attribute is not present if the flash device isn't
+ known to the kernel and is only probed by its SFDP
+ tables.
What: /sys/bus/spi/devices/.../spi-nor/partname
Date: April 2021
diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c
index 4c3b351aef24..20563c1926f4 100644
--- a/drivers/mtd/spi-nor/sysfs.c
+++ b/drivers/mtd/spi-nor/sysfs.c
@@ -74,6 +74,8 @@ static umode_t spi_nor_sysfs_is_visible(struct kobject *kobj,
struct spi_mem *spimem = spi_get_drvdata(spi);
struct spi_nor *nor = spi_mem_get_drvdata(spimem);
+ if (attr == &dev_attr_manufacturer.attr && !nor->manufacturer)
+ return 0;
if (attr == &dev_attr_jedec_id.attr && !nor->info->id_len)
return 0;
--
2.30.2
More information about the linux-mtd
mailing list