[PATCH] Interleave order while probing

Scott Wood
2004-10-19T21:03:38Z

The current 2.6 MTD code probes starting with minimal interleave.
This can result in false positives, if the flash happens to contain
zeroes at the QRY address. For example, two interleaved 16-bit chips
can be detected as a non-interleaved 32-bit chip when only one of the
chips is put into read-CFI-query mode, and the "\0\0\0Q" that it gets
back is the same as what a real 32-bit chip would produce.

The patch below (against the latest MTD CVS snapshot) starts with the
highest interleave first; I don't think there are any situations
where that would produce a false positive (short of having QRY as the
actual flash data at the relevant addresses).

Signed-off-by: Scott Wood <scott.wood@timesys.com> under TS0068

diff -urN mtd.orig/drivers/mtd/chips/gen_probe.c mtd/drivers/mtd/chips/gen_probe.c
--- mtd.orig/drivers/mtd/chips/gen_probe.c 2004-08-14 18:00:11.000000000 -0400
+++ mtd/drivers/mtd/chips/gen_probe.c 2004-10-19 16:42:11.000000000 -0400
@@ -162,7 +162,7 @@
int max_chips = map_bankwidth(map); /* And minimum 1 */
int nr_chips, type;

- for (nr_chips = min_chips; nr_chips <= max_chips; nr_chips <<= 1) {
+ for (nr_chips = max_chips; nr_chips >= min_chips; nr_chips >>= 1) {

if (!cfi_interleave_supported(nr_chips))
continue;