Use address mask in probe_jedec

This allows us to have one common probe_jedec function instead of half a
dozen wrappers. The trick here is to have FEATURE_ADDR_FULL==0 and thus
default to unmasked addresses. That way, we only have to annotate chips
which need small address masks.

Corresponding to flashrom svn r840.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
diff --git a/jedec.c b/jedec.c
index 3a21539..055fbc3 100644
--- a/jedec.c
+++ b/jedec.c
@@ -373,6 +373,19 @@
 	return failed;
 }
 
+int getaddrmask(struct flashchip *flash)
+{
+	switch (flash->feature_bits & FEATURE_ADDR_MASK) {
+	case FEATURE_ADDR_FULL:
+		return MASK_FULL;
+		break;
+	default:
+		fprintf(stderr, "%s called with unknown mask\n", __func__);
+		return 0;
+		break;
+	}
+}
+
 int write_jedec(struct flashchip *flash, uint8_t *buf)
 {
 	int i, failed = 0;
@@ -438,7 +451,10 @@
 
 int probe_jedec(struct flashchip *flash)
 {
-	return probe_jedec_common(flash, MASK_FULL, 1);
+	int mask;
+
+	mask = getaddrmask(flash);
+	return probe_jedec_common(flash, mask, 1);
 }
 
 int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int size)