summaryrefslogtreecommitdiff
path: root/chip/stm32/usb_hid.c
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2014-12-01 13:36:42 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-02 21:11:35 +0000
commit0f10bf88b27746d6f757538a11d9f7d6ca334e8d (patch)
tree2240ddc0767e1ed6750773655456351f797fd116 /chip/stm32/usb_hid.c
parent8fa4947f7681aac58937395610ed204fa34b6d5a (diff)
downloadchrome-ec-0f10bf88b27746d6f757538a11d9f7d6ca334e8d.tar.gz
USB: Interface callbacks now return an error code
A non-zero error code returned by the callback causes EP0 to STALL. This is the common mechanism used in USB to indicate an error while processing a control request. This simplifies the implementation of interface callbacks. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I89ceb4892f9f810fcaf6e975e6982fc5b2ae447b Reviewed-on: https://chromium-review.googlesource.com/232368 Reviewed-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip/stm32/usb_hid.c')
-rw-r--r--chip/stm32/usb_hid.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/chip/stm32/usb_hid.c b/chip/stm32/usb_hid.c
index 347140f9ac..bdcf09c3f8 100644
--- a/chip/stm32/usb_hid.c
+++ b/chip/stm32/usb_hid.c
@@ -118,7 +118,7 @@ static void hid_reset(void)
USB_DECLARE_EP(USB_EP_HID, hid_tx, hid_tx, hid_reset);
-static void hid_iface_request(usb_uint *ep0_buf_rx, usb_uint *ep0_buf_tx)
+static int hid_iface_request(usb_uint *ep0_buf_rx, usb_uint *ep0_buf_tx)
{
if ((ep0_buf_rx[0] == (USB_DIR_IN | USB_RECIP_INTERFACE |
(USB_REQ_GET_DESCRIPTOR << 8))) &&
@@ -132,9 +132,10 @@ static void hid_iface_request(usb_uint *ep0_buf_rx, usb_uint *ep0_buf_tx)
EP_STATUS_OUT);
CPRINTF("RPT %04x[l %04x]\n", STM32_USB_EP(0),
ep0_buf_rx[3]);
- } else {
- STM32_TOGGLE_EP(0, EP_TX_RX_MASK, EP_RX_VALID | EP_TX_STALL, 0);
+ return 0;
}
+
+ return 1;
}
USB_DECLARE_IFACE(USB_IFACE_HID, hid_iface_request)