diff mbox

[V2] mtd: spi-nor: allow NULL as chip name and try to auto detect it

Message ID 1417423336-15255-1-git-send-email-zajec5@gmail.com
State Accepted
Commit 5986a0d4717bc82af0e69e3c6dd04150eafceabe
Headers show

Commit Message

Rafał Miłecki Dec. 1, 2014, 8:42 a.m. UTC
This will allow spi-nor users to plainly use JEDEC to detect flash chip.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
V2: Rebase on top of:
6d7604e mtd: spi-nor: add support for s25fl128s
d928a25 mtd: spi-nor: remove the jedec_id/ext_id
09ffafb mtd: spi-nor: add id/id_len for flash_info{}
---
 drivers/mtd/spi-nor/spi-nor.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Brian Norris Dec. 1, 2014, 8:53 a.m. UTC | #1
On Mon, Dec 01, 2014 at 09:42:16AM +0100, Rafał Miłecki wrote:
> This will allow spi-nor users to plainly use JEDEC to detect flash chip.
> 
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
> V2: Rebase on top of:
> 6d7604e mtd: spi-nor: add support for s25fl128s
> d928a25 mtd: spi-nor: remove the jedec_id/ext_id
> 09ffafb mtd: spi-nor: add id/id_len for flash_info{}

Applied, thanks!

Brian
diff mbox

Patch

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 0f4f2ba..afc58da 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -938,13 +938,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->id_len) {
+	/*
+	 * If caller has specified name of flash model that can normally be
+	 * detected using JEDEC, let's verify it.
+	 */
+	if (name && info->id_len) {
 		const struct spi_device_id *jid;
 
 		jid = spi_nor_read_id(nor);