aboutsummaryrefslogtreecommitdiffstats
path: root/usb_device.h
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2020-03-05 15:06:57 +1100
committerEdward O'Callaghan <quasisec@chromium.org>2020-03-11 06:25:14 +0000
commit8b191f5ced93dc4d376ce4c6e83fb3ca139c6e77 (patch)
tree93d80f0046569888a4295bf9dc8116f0ac481028 /usb_device.h
parent2141250162934159f1158c640e0737e872fccb5b (diff)
downloadflashrom-8b191f5ced93dc4d376ce4c6e83fb3ca139c6e77.tar.gz
flashrom-8b191f5ced93dc4d376ce4c6e83fb3ca139c6e77.tar.bz2
flashrom-8b191f5ced93dc4d376ce4c6e83fb3ca139c6e77.zip
raiden_debug_spi.c: Disable retry during some error codes
Forward ports the downstream commit: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/2073077 Change-Id: I77def28040fea8d1ecf102463180378f8612b00e Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/39311 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'usb_device.h')
-rw-r--r--usb_device.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/usb_device.h b/usb_device.h
index d3796757..b2c7656e 100644
--- a/usb_device.h
+++ b/usb_device.h
@@ -27,10 +27,18 @@
#include <libusb.h>
#include <stdint.h>
+#include <stdbool.h>
+
+/*
+ * The LIBUSB_ERROR macro converts a libusb failure code into an error code that
+ * flashrom recognizes. It does so without displaying an error code allowing us
+ * to compare error codes against the library enumeration values.
+ */
+#define LIBUSB_ERROR(eror_code) (0x20000 | -eror_code)
/*
* The LIBUSB macro converts a libusb failure code into an error code that
- * flashrom recognizes. It also displays additional libusb specific
+ * flashrom recognizes. It also displays additional libusb specific
* information about the failure.
*/
#define LIBUSB(expression) \
@@ -42,7 +50,7 @@
__FILE__, \
__LINE__, \
libusb_error_name(libusb_error__)); \
- libusb_error__ = 0x20000 | -libusb_error__; \
+ libusb_error__ = LIBUSB_ERROR(libusb_error__); \
} else { \
libusb_error__ = 0; \
} \
@@ -51,6 +59,15 @@
})
/*
+ * Returns true if the error code falls within the range of valid libusb
+ * error codes.
+ */
+static inline bool usb_device_is_libusb_error(int error_code)
+{
+ return (0x20000 <= error_code && error_code < 0x20064);
+}
+
+/*
* A USB match and associated value struct are used to encode the information
* about a device against which we wish to match. If the value of a
* usb_match_value has been set then a device must match that value. The name