summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-08-12 15:19:49 +1000
committerAnastasia Klimchuk <aklm@chromium.org>2022-09-07 02:00:15 +0000
commitea938173a40a6fae076f6fc0f37f940eae82d142 (patch)
tree73b73d116685db844c4951c90929d7ccb8df1b58
parent5c710ea54afabf8c0e5f3c8ada45c4a5f9f0781b (diff)
downloadflashrom-ea938173a40a6fae076f6fc0f37f940eae82d142.tar.gz
flashrom-ea938173a40a6fae076f6fc0f37f940eae82d142.tar.bz2
flashrom-ea938173a40a6fae076f6fc0f37f940eae82d142.zip
usb_device.c: Allow for programmer_cfg plumbing
The only driver impacted is raiden_debug_spi.c and so plumb state directly. Change-Id: I85ff3117de8743b0a548dad98875cc41f48cac93 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/66670 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Felix Singer <felixsinger@posteo.net>
-rw-r--r--include/usb_device.h2
-rw-r--r--raiden_debug_spi.c2
-rw-r--r--usb_device.c31
3 files changed, 18 insertions, 17 deletions
diff --git a/include/usb_device.h b/include/usb_device.h
index 282a7552a..ed8187bb3 100644
--- a/include/usb_device.h
+++ b/include/usb_device.h
@@ -102,7 +102,7 @@ struct usb_match {
* extract_programmer_param_str. If the value is found convert it to an integer
* using strtol, accepting hex, decimal and octal encoding.
*/
-void usb_match_init(struct usb_match *match);
+void usb_match_init(const struct programmer_cfg *cfg, struct usb_match *match);
/*
* Add a default value to a usb_match_value. This must be done after calling
diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c
index 2f073ae0f..161471c13 100644
--- a/raiden_debug_spi.c
+++ b/raiden_debug_spi.c
@@ -1497,7 +1497,7 @@ static int raiden_debug_spi_init(const struct programmer_cfg *cfg)
return 1;
}
- usb_match_init(&match);
+ usb_match_init(cfg, &match);
usb_match_value_default(&match.vid, GOOGLE_VID);
usb_match_value_default(&match.class, LIBUSB_CLASS_VENDOR_SPEC);
diff --git a/usb_device.c b/usb_device.c
index f89e3bbb3..b23b20459 100644
--- a/usb_device.c
+++ b/usb_device.c
@@ -28,10 +28,11 @@
* Possibly extract a programmer parameter and use it to initialize the given
* match value structure.
*/
-static void usb_match_value_init(struct usb_match_value *match,
+static void usb_match_value_init(const struct programmer_cfg *cfg,
+ struct usb_match_value *match,
char const *parameter)
{
- char *string = extract_programmer_param_str(NULL, parameter); /* TODO(quasisec): pass prog_param */
+ char *string = extract_programmer_param_str(cfg, parameter);
match->name = parameter;
@@ -45,21 +46,21 @@ static void usb_match_value_init(struct usb_match_value *match,
free(string);
}
-#define USB_MATCH_VALUE_INIT(NAME) \
- usb_match_value_init(&match->NAME, #NAME)
+#define USB_MATCH_VALUE_INIT(PPARAM, NAME) \
+ usb_match_value_init(PPARAM, &match->NAME, #NAME)
-void usb_match_init(struct usb_match *match)
+void usb_match_init(const struct programmer_cfg *cfg, struct usb_match *match)
{
- USB_MATCH_VALUE_INIT(vid);
- USB_MATCH_VALUE_INIT(pid);
- USB_MATCH_VALUE_INIT(bus);
- USB_MATCH_VALUE_INIT(address);
- USB_MATCH_VALUE_INIT(config);
- USB_MATCH_VALUE_INIT(interface);
- USB_MATCH_VALUE_INIT(altsetting);
- USB_MATCH_VALUE_INIT(class);
- USB_MATCH_VALUE_INIT(subclass);
- USB_MATCH_VALUE_INIT(protocol);
+ USB_MATCH_VALUE_INIT(cfg, vid);
+ USB_MATCH_VALUE_INIT(cfg, pid);
+ USB_MATCH_VALUE_INIT(cfg, bus);
+ USB_MATCH_VALUE_INIT(cfg, address);
+ USB_MATCH_VALUE_INIT(cfg, config);
+ USB_MATCH_VALUE_INIT(cfg, interface);
+ USB_MATCH_VALUE_INIT(cfg, altsetting);
+ USB_MATCH_VALUE_INIT(cfg, class);
+ USB_MATCH_VALUE_INIT(cfg, subclass);
+ USB_MATCH_VALUE_INIT(cfg, protocol);
}
void usb_match_value_default(struct usb_match_value *value,