diff options
-rw-r--r-- | drivers/mtd/spi-nor/spi-nor.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 0f4f2ba16e3e..0f8ec3c2d015 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) | |||
938 | if (ret) | 938 | if (ret) |
939 | return ret; | 939 | return ret; |
940 | 940 | ||
941 | id = spi_nor_match_id(name); | 941 | /* Try to auto-detect if chip name wasn't specified */ |
942 | if (!id) | 942 | if (!name) |
943 | id = spi_nor_read_id(nor); | ||
944 | else | ||
945 | id = spi_nor_match_id(name); | ||
946 | if (IS_ERR_OR_NULL(id)) | ||
943 | return -ENOENT; | 947 | return -ENOENT; |
944 | 948 | ||
945 | info = (void *)id->driver_data; | 949 | info = (void *)id->driver_data; |
946 | 950 | ||
947 | if (info->id_len) { | 951 | /* |
952 | * If caller has specified name of flash model that can normally be | ||
953 | * detected using JEDEC, let's verify it. | ||
954 | */ | ||
955 | if (name && info->id_len) { | ||
948 | const struct spi_device_id *jid; | 956 | const struct spi_device_id *jid; |
949 | 957 | ||
950 | jid = spi_nor_read_id(nor); | 958 | jid = spi_nor_read_id(nor); |