Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion subsys/usb/host/usbh_ch9.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,16 @@ int usbh_req_set_address(struct usb_device *const udev,
{
const uint8_t bmRequestType = USB_REQTYPE_DIR_TO_DEVICE << 7;
const uint8_t bRequest = USB_SREQ_SET_ADDRESS;
int ret;

ret = usbh_req_setup(udev, bmRequestType, bRequest, addr, 0, 0, NULL);
if (ret != 0) {
return ret;
}

return usbh_req_setup(udev, bmRequestType, bRequest, addr, 0, 0, NULL);
udev->addr = addr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mismatch is only in

err = usbh_req_set_address(udev, new_addr);
if (err) {
shell_error(sh, "host: Failed to set address");
} else {
shell_print(sh, "host: New device address is %u", new_addr);
}

The actual USB host stack updates device address

err = usbh_req_set_address(udev, new_addr);
if (err) {
LOG_ERR("Failed to set device address");
udev->addr = 0;
goto error;
}
udev->addr = new_addr;
udev->state = USB_STATE_ADDRESSED;

The question is really about what should be updated by usbh_req_set_address() and what is left to the caller.


return 0;
}

int usbh_req_set_cfg(struct usb_device *const udev,
Expand Down