Replace flashprog_chip_match() w/ simpler flashprog_bus_match_chip()

We drop all the prints that were kept for comparison with the old probe
sequence. Now that we actually don't run a probe function per chip from
the database, the output would be quite confusing.

The remaining dropped boilerplate is not needed anymore, as all callers
already take care of flashprog_bus_probe() special cases like ID_NONE.

Change-Id: Icf0f37df4b5cf26fe7e2535cbaa15040631bdd1c
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/490
diff --git a/libflashprog/chips.c b/libflashprog/chips.c
index ac5cdc2..12b4197 100644
--- a/libflashprog/chips.c
+++ b/libflashprog/chips.c
@@ -58,6 +58,19 @@
 	return 0;
 }
 
+static bool flashprog_bus_match_chip(struct registered_master *bus, const struct flashprog_chip *chip)
+{
+	struct found_id *found_id;
+	for (found_id = bus->found_ids; found_id; found_id = found_id->next) {
+		if (found_id->info.id.type != chip->id.type)
+			continue;
+
+		if (bus->probing.match(chip, &found_id->info))
+			break;
+	}
+	return !!found_id;
+}
+
 static int flashprog_chips_probe_bus(struct flashprog_chips *chips,
 				     struct registered_master *bus)
 {
@@ -71,7 +84,7 @@
 		     (flashchips[chip].id.model == GENERIC_DEVICE_ID)))
 			continue;
 
-		if (!flashprog_chip_match(bus, &flashchips[chip]))
+		if (!flashprog_bus_match_chip(bus, &flashchips[chip]))
 			continue;
 
 		struct chip_entry *const entry = malloc(sizeof(*entry));
@@ -116,7 +129,7 @@
 			return NULL;
 
 		flashprog_bus_probe(bus, chip);
-		if (flashprog_chip_match(bus, chip))
+		if (flashprog_bus_match_chip(bus, chip))
 			return &bus->common;
 	}