summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJes B. Klinke <jbk@chromium.org>2021-10-29 11:28:12 -0700
committerCommit Bot <commit-bot@chromium.org>2021-10-29 20:00:04 +0000
commit1053767af03e18d28912226e1cc74b175657b490 (patch)
tree0eed77ec3ea4d05fffde8c372e58623e77d1308b
parent35fadc59c3936f57fc0232b8b6429ceeafbe0620 (diff)
downloadchrome-ec-1053767af03e18d28912226e1cc74b175657b490.tar.gz
chip/stm32/usb_spi.c: Fix bug crippling full duplex
It seems that the logical condition of an ifdef had been accidentally negated. Furthermore, in cases where full duplex support is present, the control flow should reach the final else branch of the if statement, which it previously would not when a full duplex transaction was requested. These two mistakes makes it such that SPI full duplex forwarding from USB cannot work on e.g. servo v4 (and on the future HyperDebug board that I am working on.) I have tested this change as part of my HyperDebug code under development, as well as tested that the change compiles on servo_micro. I have not attempted full duplex transactions on servo micro, as I do not currently have a setup that I can use to easily verify. Looking at the code, one can convince oneself that behavior can only change in cases where the code would previously either reject a transaction explicitly, or silently drop it resulting in USB timeout. Signed-off-by: Jes B. Klinke <jbk@chromium.org> BUG=b:192262089 BRANCH=None TEST=make BOARD=servo_micro Change-Id: I5767d91c5b1ada4e54eec7ecd0512345448288e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3253432 Commit-Queue: Jes Klinke <jbk@chromium.org> Commit-Queue: Brian J. Nemec <bnemec@chromium.org> Tested-by: Jes Klinke <jbk@chromium.org> Auto-Submit: Jes Klinke <jbk@chromium.org> Reviewed-by: Brian J. Nemec <bnemec@chromium.org>
-rw-r--r--chip/stm32/usb_spi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/chip/stm32/usb_spi.c b/chip/stm32/usb_spi.c
index 54caae015e..86254ddaac 100644
--- a/chip/stm32/usb_spi.c
+++ b/chip/stm32/usb_spi.c
@@ -273,8 +273,8 @@ static void usb_spi_process_rx_packet(struct usb_spi_config const *config,
} else if (write_count > USB_SPI_MAX_WRITE_COUNT) {
setup_transfer_response(config,
USB_SPI_WRITE_COUNT_INVALID);
+#ifdef CONFIG_SPI_HALFDUPLEX
} else if (read_count == USB_SPI_FULL_DUPLEX_ENABLED) {
-#ifndef CONFIG_SPI_HALFDUPLEX
/* Full duplex mode is not supported on this device. */
setup_transfer_response(config,
USB_SPI_UNSUPPORTED_FULL_DUPLEX);