From 08fede6504dd3ba5c83b2d337b960eeeb6b42362 Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Fri, 7 Nov 2025 16:26:05 +0000 Subject: [PATCH] usb: host: update udev->addr after setting the address The usbh_req_set_address() function did successfully set the device to its new address, but the udev->addr was not update, so there was a mismatch between the reality and udev. Signed-off-by: Josuah Demangeon --- subsys/usb/host/usbh_ch9.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/subsys/usb/host/usbh_ch9.c b/subsys/usb/host/usbh_ch9.c index 80783e430559b..787107e627574 100644 --- a/subsys/usb/host/usbh_ch9.c +++ b/subsys/usb/host/usbh_ch9.c @@ -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; + + return 0; } int usbh_req_set_cfg(struct usb_device *const udev,