From: Michael Walle <michael@walle.cc>
To: Tudor Ambarus <tudor.ambarus@microchip.com>,
Pratyush Yadav <pratyush@kernel.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
Michael Walle <michael@walle.cc>,
Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Subject: [PATCH v2 7/7] mtd: spi-nor: sysfs: print JEDEC ID for generic flash driver
Date: Thu, 11 Aug 2022 00:06:54 +0200 [thread overview]
Message-ID: <20220810220654.1297699-8-michael@walle.cc> (raw)
In-Reply-To: <20220810220654.1297699-1-michael@walle.cc>
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>
Reviewed-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
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;
--
2.30.2
next prev parent reply other threads:[~2022-08-10 22:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-10 22:06 [PATCH v2 0/7] mtd: spi-nor: generic flash driver Michael Walle
2022-08-10 22:06 ` [PATCH v2 1/7] mtd: spi-nor: hide jedec_id sysfs attribute if not present Michael Walle
2022-08-10 22:06 ` [PATCH v2 2/7] mtd: spi-nor: sysfs: hide manufacturer if it is not set Michael Walle
2022-08-10 22:06 ` [PATCH v2 3/7] mtd: spi-nor: remember full JEDEC flash ID Michael Walle
2022-08-10 22:06 ` [PATCH v2 4/7] mtd: spi-nor: move function declaration out of sfdp.h Michael Walle
2022-08-10 22:06 ` [PATCH v2 5/7] mtd: spi-nor: fix select_uniform_erase to skip 0 erase size Michael Walle
2022-08-10 22:06 ` [PATCH v2 6/7] mtd: spi-nor: add generic flash driver Michael Walle
2022-11-01 8:46 ` Tudor.Ambarus
2022-11-07 14:42 ` Tudor.Ambarus
2022-11-07 18:22 ` Michael Walle
2022-11-21 13:35 ` Tudor.Ambarus
2022-08-10 22:06 ` Michael Walle [this message]
2022-11-21 13:41 ` [PATCH v2 0/7] mtd: spi-nor: " Tudor Ambarus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220810220654.1297699-8-michael@walle.cc \
--to=michael@walle.cc \
--cc=Takahiro.Kuwano@infineon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=tudor.ambarus@microchip.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).