probing: Pass full struct flashchip into probes
In case we want to probe for a particular chip, we can filter the
actual probing sequences by its properties.
We'll use `struct flashchip` internally and `struct flashprog_chip`
will be used only close to the libflashprog API. This way, we can
separate the two later again if necessary.
Change-Id: Id8b13d28fcaefee62746c9391fe86b4b3b09a428
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/441
diff --git a/flashprog.c b/flashprog.c
index c1a8808..fc20045 100644
--- a/flashprog.c
+++ b/flashprog.c
@@ -617,7 +617,7 @@
return 0;
}
-static void probe_bus(struct registered_master *const mst, const enum id_type type)
+static void probe_bus(struct registered_master *const mst, const struct flashchip *const chip)
{
unsigned int least_priority, priority, i;
struct found_id **next_ptr;
@@ -638,10 +638,10 @@
if (mst->probing.probes[i].priority != priority)
continue;
- if (type && type != mst->probing.probes[i].type)
+ if (chip && chip->id.type != mst->probing.probes[i].type)
continue;
- *next_ptr = mst->probing.probes[i].run(&mst->probing.probes[i], &mst->common);
+ *next_ptr = mst->probing.probes[i].run(&mst->probing.probes[i], &mst->common, chip);
found |= !!*next_ptr;
/* walk to end in case multiple IDs were found in a single call */
@@ -657,7 +657,7 @@
mst->probed = true;
}
-static bool chip_on_bus(struct registered_master *const mst, const struct flashprog_chip *const chip)
+static bool chip_on_bus(struct registered_master *const mst, const struct flashchip *const chip)
{
static const char *const id_names[] = {
[ID_82802AB] = "82802AB",
@@ -682,10 +682,10 @@
If it can't be probed, assume it's there... */
if (chip->id.type == ID_NONE)
return true;
- /* ...otherwise, limit the probing functions to its type. */
- probe_bus(mst, chip->id.type);
+ /* ...otherwise, limit the probing sequences by its properties. */
+ probe_bus(mst, chip);
} else {
- probe_bus(mst, 0);
+ probe_bus(mst, NULL);
}
struct found_id *found_id;