It looks to me like the library only looks for up to two matches because it returns an error if there's more than one match. I agree that it would be good to make it able to report which chips matched (making flashrom_flash_probe() suitable for CLI use) in addition to returning an error, but the API would need to be extended in order to support that additional information.

On Sun, Jan 26, 2025 at 10:59 PM Anastasia Klimchuk <aklm@chromium.org> wrote:
Hello everyone,

It turns out, flashrom has two different code paths for probing from
command line vs probing with libflashrom.

I think the logic should be the same, so as a goal I want to
understand which approach is correct and use the same in both places.
Have one piece of code and call it in two places.

What is the difference:

Command line keeps probing until the end of flashchips array, and as a
result all matches will be found (no matter how many of them are).
Currently code is on these lines:
https://github.com/flashrom/flashrom/blob/main/cli_classic.c#L1211

Libflashrom only does probing twice, so at most two matches will be found.
Currently code is on these lines:
https://github.com/flashrom/flashrom/blob/main/libflashrom.c#L250

These two paths were initially introduced like this (>14 and >7yr ago).

To me, command line's approach makes sense - because why stop at two
matches? What if there are three matching chip definitions, and #3 is
actually what the user has?

So I am interested in what people think.

A context how did this come up: I started working towards giving
SFDP-detection more priority and this involves updating the probing
logic, and that's how I came to this.

--
Anastasia.
_______________________________________________
flashrom mailing list -- flashrom@flashrom.org
To unsubscribe send an email to flashrom-leave@flashrom.org