Commit 58c81957 authored by Rafał Miłecki's avatar Rafał Miłecki Committed by Brian Norris

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

This will allow spi-nor users to plainly use JEDEC to detect flash chip.
Signed-off-by: default avatarRafał Miłecki <zajec5@gmail.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 7ca94e07
...@@ -938,13 +938,21 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) ...@@ -938,13 +938,21 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
if (ret) if (ret)
return ret; return ret;
/* 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); id = spi_nor_match_id(name);
if (!id) if (IS_ERR_OR_NULL(id))
return -ENOENT; return -ENOENT;
info = (void *)id->driver_data; 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; const struct spi_device_id *jid;
jid = spi_nor_read_id(nor); jid = spi_nor_read_id(nor);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment