Skip to content

Commit 47b9ed9

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 88d285a commit 47b9ed9

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
@@ -486,18 +486,6 @@ int usbh_device_init(struct usb_device *const udev)
486486
goto error;
487487
}
488488

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

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

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

0 commit comments

Comments
 (0)