Skip to content

Commit 16f0b18

Browse files
santhosh-c-cJosuah Demangeon
authored andcommitted
usb: host: device: Read descriptor after setting device address
Modify the USB device int sequence to read the device descriptor only after setting a valid device address. Signed-off-by: Santhosh Charles <[email protected]>
1 parent d0954c9 commit 16f0b18

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

subsys/usb/host/usbh_device.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -487,18 +487,6 @@ int usbh_device_init(struct usb_device *const udev)
487487
goto error;
488488
}
489489

490-
err = usbh_req_desc_dev(udev, sizeof(udev->dev_desc), &udev->dev_desc);
491-
if (err) {
492-
LOG_ERR("Failed to read device descriptor");
493-
goto error;
494-
}
495-
496-
if (!udev->dev_desc.bNumConfigurations) {
497-
LOG_ERR("Device has no configurations, bNumConfigurations %d",
498-
udev->dev_desc.bNumConfigurations);
499-
goto error;
500-
}
501-
502490
err = alloc_device_address(udev, &new_addr);
503491
if (err) {
504492
LOG_ERR("Failed to allocate device address");
@@ -518,6 +506,18 @@ int usbh_device_init(struct usb_device *const udev)
518506

519507
LOG_INF("New device with address %u state %u", udev->addr, udev->state);
520508

509+
err = usbh_req_desc_dev(udev, sizeof(udev->dev_desc), &udev->dev_desc);
510+
if (err) {
511+
LOG_ERR("Failed to read device descriptor");
512+
goto error;
513+
}
514+
515+
if (!udev->dev_desc.bNumConfigurations) {
516+
LOG_ERR("Device has no configurations, bNumConfigurations %d",
517+
udev->dev_desc.bNumConfigurations);
518+
goto error;
519+
}
520+
521521
err = usbh_device_set_configuration(udev, 1);
522522
if (err) {
523523
LOG_ERR("Failed to configure new device with address %u", udev->addr);

0 commit comments

Comments
 (0)