summaryrefslogtreecommitdiffstats
path: root/ft2232_spi.c
diff options
context:
space:
mode:
authorHarry Johnson <johnsonh@waymo.com>2021-07-08 14:28:39 -0700
committerNico Huber <nico.h@gmx.de>2021-07-29 09:38:33 +0000
commitb7dec7f2cce9f81d5059c3c3e0d65d14fd9363c8 (patch)
tree21f82769c756c0f9654e1fa173411d352e1c7277 /ft2232_spi.c
parent19c6b2821dffe212fba9421495c77fe8f5db319e (diff)
downloadflashrom-b7dec7f2cce9f81d5059c3c3e0d65d14fd9363c8.tar.gz
flashrom-b7dec7f2cce9f81d5059c3c3e0d65d14fd9363c8.tar.bz2
flashrom-b7dec7f2cce9f81d5059c3c3e0d65d14fd9363c8.zip
ft2232_spi: Add FTDI search by description.
This adds to the search-by-serial functionality with search-by-description (product string). This is useful when e.g. one has multiple FTDIs in a system and wants the serial numbers to reflect the system-level serial number, and the description to reflect the subcomponent names. Tested manually by running with both serial and description searches, on a machine with multiple FTDIs plugged in. Ensured that when two devices with the same vid/pid/serial number are plugged in, description can be used to differentiate. Verifed no-description, no-serial, one FTDI plugged in base case works. Original version of this code used the original single "arg" char*, but on further thought, this wasn't worth the readability and functionality losses. The new version with arg2 gets rid of several lines of code, the gotos, and adds the ability to filter by both description and serial simultaneously. Change-Id: Ib4be23247995710900175f5f16e38db577ef08fa Signed-off-by: Harry Johnson <johnsonh@waymo.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56164 Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'ft2232_spi.c')
-rw-r--r--ft2232_spi.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ft2232_spi.c b/ft2232_spi.c
index d853b09fb..e32d7f81e 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -319,7 +319,7 @@ static int ft2232_spi_init(void)
*/
uint32_t divisor = DEFAULT_DIVISOR;
int f;
- char *arg;
+ char *arg, *arg2;
double mpsse_clk;
uint8_t cs_bits = 0x08;
@@ -499,8 +499,12 @@ static int ft2232_spi_init(void)
}
arg = extract_programmer_param("serial");
- f = ftdi_usb_open_desc(&ftdic, ft2232_vid, ft2232_type, NULL, arg);
+ arg2 = extract_programmer_param("description");
+
+ f = ftdi_usb_open_desc(&ftdic, ft2232_vid, ft2232_type, arg2, arg);
+
free(arg);
+ free(arg2);
if (f < 0 && f != -5) {
msg_perr("Unable to open FTDI device: %d (%s)\n", f,