flashchips: Add a type enum to the chip identification

We used to imply what kind of ID (e.g. RES, REMS, RDID) a chip entry
provides, based on the given probing function. This works well as long
as we call the respective probing function for every single chip entry.
With our ever growing chip database, however, this slows probing signi-
ficantly down. Especially with external programmers with a long command
round-trip.

With the type of identification information stored in the chip entries
explicitly, we'll be able to implement bus-specific probing functions.
These would be called only once and their results would be used to look
a matching chip up in the chip database. Instead of looking for every
possible chip on the buses, we can turn it around and search for the
actually present chips in the database.

Change-Id: Ie658ebf58f21c8994b9b66f7683f9490e8d12267
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/74898
diff --git a/flashprog.c b/flashprog.c
index fd9cd74..0ab20cb 100644
--- a/flashprog.c
+++ b/flashprog.c
@@ -678,7 +678,7 @@
 		 * one for this programmer interface (master) and thus no other chip has
 		 * been found on this interface.
 		 */
-		if (startchip == 0 && flash->chip->model_id == SFDP_DEVICE_ID) {
+		if (startchip == 0 && flash->chip->id.model == SFDP_DEVICE_ID) {
 			msg_cinfo("===\n"
 				  "SFDP has autodetected a flash chip which is "
 				  "not natively supported by flashprog yet.\n");
@@ -705,7 +705,7 @@
 		if (startchip == 0)
 			break;
 		/* Not the first flash chip detected on this bus, but not a generic match either. */
-		if ((flash->chip->model_id != GENERIC_DEVICE_ID) && (flash->chip->model_id != SFDP_DEVICE_ID))
+		if ((flash->chip->id.model != GENERIC_DEVICE_ID) && (flash->chip->id.model != SFDP_DEVICE_ID))
 			break;
 		/* Not the first flash chip detected on this bus, and it's just a generic match. Ignore it. */
 notfound:
@@ -1509,7 +1509,8 @@
 	else
 		snprintf(label, sizeof(label), "%s", name);
 
-	if (chip->vendor == NULL || chip->name == NULL || chip->bustype == BUS_NONE) {
+	if (chip->vendor == NULL || chip->name == NULL || chip->bustype == BUS_NONE ||
+	    chip->id.type == ID_FIXME) {
 		ret = 1;
 		msg_gerr("ERROR: Some field of flash chip %s is misconfigured.\n"
 			 "Please report a bug at flashprog@flashprog.org\n", label);