public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: allow NULL as chip name and try to auto detect it
@ 2014-10-22 16:05 Rafał Miłecki
  2014-11-28  8:24 ` Rafał Miłecki
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Rafał Miłecki @ 2014-10-22 16:05 UTC (permalink / raw)
  To: David Woodhouse, Artem Bityutskiy, Brian Norris, linux-mtd
  Cc: Hauke Mehrtens, Rafał Miłecki

This will allow spi-nor users to plainly use JEDEC to detect flash chip.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index ee777a4..1facaac 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -937,13 +937,21 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 	if (ret)
 		return ret;
 
-	id = spi_nor_match_id(name);
+	/* Try to auto-detect if chip name wasn't specified */
+	if (!name)
+		id = spi_nor_read_id(nor);
+	else
+		id = spi_nor_match_id(name);
 	if (!id)
 		return -ENOENT;
 
 	info = (void *)id->driver_data;
 
-	if (info->jedec_id) {
+	/*
+	 * If caller has specified name of flash model that can normally be
+	 * detected using JEDEC, let's verify it.
+	 */
+	if (name && info->jedec_id) {
 		const struct spi_device_id *jid;
 
 		jid = spi_nor_read_id(nor);
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-12-17  6:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-22 16:05 [PATCH] mtd: spi-nor: allow NULL as chip name and try to auto detect it Rafał Miłecki
2014-11-28  8:24 ` Rafał Miłecki
2014-12-01  8:40 ` Brian Norris
2014-12-01  9:49   ` Rafał Miłecki
2014-12-17  1:15     ` Brian Norris
2014-12-17  6:19       ` Rafał Miłecki
2014-12-17  6:50         ` Brian Norris
2014-12-01  8:42 ` [PATCH V2] " Rafał Miłecki
2014-12-01  8:53   ` Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox