From 1677cb8011e4c529c7a4e554893b8047387b29ec Mon Sep 17 00:00:00 2001 From: dragonmux Date: Wed, 17 Apr 2024 18:40:54 +0100 Subject: [PATCH] usb: Cleaned up a little in the control endpoint implementation --- lib/usb/usb_control.c | 12 +++++------- lib/usb/usb_standard.c | 4 +--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/usb/usb_control.c b/lib/usb/usb_control.c index 64b61dd464..1f915dec11 100644 --- a/lib/usb/usb_control.c +++ b/lib/usb/usb_control.c @@ -235,27 +235,25 @@ static void usb_control_setup_write(usbd_device *usbd_dev, /* Do not appear to belong to the API, so are omitted from docs */ /**@}*/ -void _usbd_control_setup(usbd_device *usbd_dev, uint8_t ea) +void _usbd_control_setup(usbd_device *usbd_dev, uint8_t ep) { struct usb_setup_data *req = &usbd_dev->control_state.req; - (void)ea; + (void)ep; usbd_dev->control_state.complete = NULL; usbd_ep_nak_set(usbd_dev, 0, 1); - if (req->wLength == 0) { - usb_control_setup_read(usbd_dev, req); - } else if (req->bmRequestType & 0x80) { + if (req->wLength == 0 || (req->bmRequestType & USB_REQ_TYPE_DIRECTION) == USB_REQ_TYPE_IN) { usb_control_setup_read(usbd_dev, req); } else { usb_control_setup_write(usbd_dev, req); } } -void _usbd_control_out(usbd_device *usbd_dev, uint8_t ea) +void _usbd_control_out(usbd_device *usbd_dev, uint8_t ep) { - (void)ea; + (void)ep; switch (usbd_dev->control_state.state) { case DATA_OUT: diff --git a/lib/usb/usb_standard.c b/lib/usb/usb_standard.c index 97eab61616..6328bf9061 100644 --- a/lib/usb/usb_standard.c +++ b/lib/usb/usb_standard.c @@ -305,12 +305,11 @@ usb_standard_set_address(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len) { - (void)req; (void)buf; (void)len; /* The actual address is only latched at the STATUS IN stage. */ - if ((req->bmRequestType != 0) || (req->wValue >= 128)) { + if (req->bmRequestType != 0 || req->wValue >= 128) { return USBD_REQ_NOTSUPP; } @@ -336,7 +335,6 @@ usb_standard_set_configuration(usbd_device *usbd_dev, int found_index = -1; const struct usb_config_descriptor *cfg; - (void)req; (void)buf; (void)len;