mtd: spi-nor: hide jedec_id sysfs attribute if not present
[ Upstream commit 7d388551b6888f3725e6c957f472526b35161a5b ]
Some non-jedec compliant flashes (like the Everspin flashes) don't have
an ID at all. Hide the attribute in this case.
Fixes: 36ac022862 ("mtd: spi-nor: add initial sysfs support")
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Link: https://lore.kernel.org/r/20220810220654.1297699-2-michael@walle.cc
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
348d95e39f
commit
58e1a0ef52
@@ -5,6 +5,9 @@ Contact: linux-mtd@lists.infradead.org
|
|||||||
Description: (RO) The JEDEC ID of the SPI NOR flash as reported by the
|
Description: (RO) The JEDEC ID of the SPI NOR flash as reported by the
|
||||||
flash device.
|
flash device.
|
||||||
|
|
||||||
|
The attribute is not present if the flash doesn't support
|
||||||
|
the "Read JEDEC ID" command (9Fh). This is the case for
|
||||||
|
non-JEDEC compliant flashes.
|
||||||
|
|
||||||
What: /sys/bus/spi/devices/.../spi-nor/manufacturer
|
What: /sys/bus/spi/devices/.../spi-nor/manufacturer
|
||||||
Date: April 2021
|
Date: April 2021
|
||||||
|
|||||||
@@ -67,6 +67,19 @@ static struct bin_attribute *spi_nor_sysfs_bin_entries[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static umode_t spi_nor_sysfs_is_visible(struct kobject *kobj,
|
||||||
|
struct attribute *attr, int n)
|
||||||
|
{
|
||||||
|
struct spi_device *spi = to_spi_device(kobj_to_dev(kobj));
|
||||||
|
struct spi_mem *spimem = spi_get_drvdata(spi);
|
||||||
|
struct spi_nor *nor = spi_mem_get_drvdata(spimem);
|
||||||
|
|
||||||
|
if (attr == &dev_attr_jedec_id.attr && !nor->info->id_len)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 0444;
|
||||||
|
}
|
||||||
|
|
||||||
static umode_t spi_nor_sysfs_is_bin_visible(struct kobject *kobj,
|
static umode_t spi_nor_sysfs_is_bin_visible(struct kobject *kobj,
|
||||||
struct bin_attribute *attr, int n)
|
struct bin_attribute *attr, int n)
|
||||||
{
|
{
|
||||||
@@ -82,6 +95,7 @@ static umode_t spi_nor_sysfs_is_bin_visible(struct kobject *kobj,
|
|||||||
|
|
||||||
static const struct attribute_group spi_nor_sysfs_group = {
|
static const struct attribute_group spi_nor_sysfs_group = {
|
||||||
.name = "spi-nor",
|
.name = "spi-nor",
|
||||||
|
.is_visible = spi_nor_sysfs_is_visible,
|
||||||
.is_bin_visible = spi_nor_sysfs_is_bin_visible,
|
.is_bin_visible = spi_nor_sysfs_is_bin_visible,
|
||||||
.attrs = spi_nor_sysfs_entries,
|
.attrs = spi_nor_sysfs_entries,
|
||||||
.bin_attrs = spi_nor_sysfs_bin_entries,
|
.bin_attrs = spi_nor_sysfs_bin_entries,
|
||||||
|
|||||||
Reference in New Issue
Block a user