Skip to content

Commit

Permalink
mtd: spi-nor: allow NULL as chip name and try to auto detect it
Browse files Browse the repository at this point in the history
This will allow spi-nor users to plainly use JEDEC to detect flash chip.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
  • Loading branch information
Rafał Miłecki authored and Brian Norris committed Dec 1, 2014
1 parent 7ca94e0 commit 58c8195
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions drivers/mtd/spi-nor/spi-nor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
if (!id)
/* 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 (IS_ERR_OR_NULL(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);
Expand Down

0 comments on commit 58c8195

Please sign in to comment.