Message ID | 20220513133520.3945820-7-michael@walle.cc |
---|---|
State | Superseded |
Delegated to: | Pratyush Yadav |
Headers | show |
Series | mtd: spi-nor: generic flash driver | expand |
On 5/13/2022 10:35 PM, Michael Walle wrote: > We don't have a database entry for the generic SPI-NOR flash driver and > thus we don't have a JEDEC ID to print. Print the (cached) JEDEC ID > instead. > > Signed-off-by: Michael Walle <michael@walle.cc> > --- > drivers/mtd/spi-nor/sysfs.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c > index 20563c1926f4..c09bb832b3b9 100644 > --- a/drivers/mtd/spi-nor/sysfs.c > +++ b/drivers/mtd/spi-nor/sysfs.c > @@ -35,8 +35,10 @@ static ssize_t jedec_id_show(struct device *dev, > struct spi_device *spi = to_spi_device(dev); > struct spi_mem *spimem = spi_get_drvdata(spi); > struct spi_nor *nor = spi_mem_get_drvdata(spimem); > + const u8 *id = nor->info->id_len ? nor->info->id : nor->id; > + u8 id_len = nor->info->id_len ?: SPI_NOR_MAX_ID_LEN; > > - return sysfs_emit(buf, "%*phN\n", nor->info->id_len, nor->info->id); > + return sysfs_emit(buf, "%*phN\n", id_len, id); > } > static DEVICE_ATTR_RO(jedec_id); > > @@ -76,7 +78,7 @@ 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_jedec_id.attr && !nor->info->id_len) > + if (attr == &dev_attr_jedec_id.attr && !nor->info->id_len && !nor->id) > return 0; > > return 0444; Reviewed-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c index 20563c1926f4..c09bb832b3b9 100644 --- a/drivers/mtd/spi-nor/sysfs.c +++ b/drivers/mtd/spi-nor/sysfs.c @@ -35,8 +35,10 @@ static ssize_t jedec_id_show(struct device *dev, struct spi_device *spi = to_spi_device(dev); struct spi_mem *spimem = spi_get_drvdata(spi); struct spi_nor *nor = spi_mem_get_drvdata(spimem); + const u8 *id = nor->info->id_len ? nor->info->id : nor->id; + u8 id_len = nor->info->id_len ?: SPI_NOR_MAX_ID_LEN; - return sysfs_emit(buf, "%*phN\n", nor->info->id_len, nor->info->id); + return sysfs_emit(buf, "%*phN\n", id_len, id); } static DEVICE_ATTR_RO(jedec_id); @@ -76,7 +78,7 @@ 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_jedec_id.attr && !nor->info->id_len) + if (attr == &dev_attr_jedec_id.attr && !nor->info->id_len && !nor->id) return 0; return 0444;
We don't have a database entry for the generic SPI-NOR flash driver and thus we don't have a JEDEC ID to print. Print the (cached) JEDEC ID instead. Signed-off-by: Michael Walle <michael@walle.cc> --- drivers/mtd/spi-nor/sysfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)