Skip to content

Commit

Permalink
usb: Cleaned up a little in the control endpoint implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmux committed Aug 11, 2024
1 parent 8233356 commit 1677cb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 5 additions & 7 deletions lib/usb/usb_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions lib/usb/usb_standard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;

Expand Down

0 comments on commit 1677cb8

Please sign in to comment.