@@ -3298,32 +3298,28 @@ static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,
3298
3298
3299
3299
if (name )
3300
3300
info = spi_nor_match_name (nor , name );
3301
- /* Try to auto-detect if chip name wasn't specified or not found */
3302
- if (!info )
3303
- return spi_nor_detect (nor );
3304
-
3305
3301
/*
3306
- * If caller has specified name of flash model that can normally be
3307
- * detected using JEDEC, let's verify it.
3302
+ * Auto-detect if chip name wasn't specified or not found, or the chip
3303
+ * has an ID. If the chip supposedly has an ID, we also do an
3304
+ * auto-detection to compare it later.
3308
3305
*/
3309
- if (name && info -> id ) {
3306
+ if (! info || info -> id ) {
3310
3307
const struct flash_info * jinfo ;
3311
3308
3312
3309
jinfo = spi_nor_detect (nor );
3313
- if (IS_ERR (jinfo )) {
3310
+ if (IS_ERR (jinfo ))
3314
3311
return jinfo ;
3315
- } else if (jinfo != info ) {
3316
- /*
3317
- * JEDEC knows better, so overwrite platform ID. We
3318
- * can't trust partitions any longer, but we'll let
3319
- * mtd apply them anyway, since some partitions may be
3320
- * marked read-only, and we don't want to loose that
3321
- * information, even if it's not 100% accurate.
3322
- */
3312
+
3313
+ /*
3314
+ * If caller has specified name of flash model that can normally
3315
+ * be detected using JEDEC, let's verify it.
3316
+ */
3317
+ if (info && jinfo != info )
3323
3318
dev_warn (nor -> dev , "found %s, expected %s\n" ,
3324
3319
jinfo -> name , info -> name );
3325
- info = jinfo ;
3326
- }
3320
+
3321
+ /* If info was set before, JEDEC knows better. */
3322
+ info = jinfo ;
3327
3323
}
3328
3324
3329
3325
return info ;
0 commit comments