From 0f10bf88b27746d6f757538a11d9f7d6ca334e8d Mon Sep 17 00:00:00 2001 From: Anton Staaf Date: Mon, 1 Dec 2014 13:36:42 -0800 Subject: 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 BRANCH=None BUG=None TEST=make buildall -j Change-Id: I89ceb4892f9f810fcaf6e975e6982fc5b2ae447b Reviewed-on: https://chromium-review.googlesource.com/232368 Reviewed-by: Anton Staaf Commit-Queue: Anton Staaf Tested-by: Anton Staaf Reviewed-by: Vincent Palatin --- chip/stm32/usb_hid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'chip/stm32/usb_hid.c') 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) -- cgit v1.2.1