Skip to content

Commit 3ce2e33

Browse files
santhosh-c-cAidenHu
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 b73201b commit 3ce2e33

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
@@ -497,18 +497,6 @@ int usbh_device_init(struct usb_device *const udev)
497497
goto error;
498498
}
499499

500-
err = usbh_req_desc_dev(udev, sizeof(udev->dev_desc), &udev->dev_desc);
501-
if (err) {
502-
LOG_ERR("Failed to read device descriptor");
503-
goto error;
504-
}
505-
506-
if (!udev->dev_desc.bNumConfigurations) {
507-
LOG_ERR("Device has no configurations, bNumConfigurations %d",
508-
udev->dev_desc.bNumConfigurations);
509-
goto error;
510-
}
511-
512500
err = alloc_device_address(udev, &new_addr);
513501
if (err) {
514502
LOG_ERR("Failed to allocate device address");
@@ -528,6 +516,18 @@ int usbh_device_init(struct usb_device *const udev)
528516

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

519+
err = usbh_req_desc_dev(udev, sizeof(udev->dev_desc), &udev->dev_desc);
520+
if (err) {
521+
LOG_ERR("Failed to read device descriptor");
522+
goto error;
523+
}
524+
525+
if (!udev->dev_desc.bNumConfigurations) {
526+
LOG_ERR("Device has no configurations, bNumConfigurations %d",
527+
udev->dev_desc.bNumConfigurations);
528+
goto error;
529+
}
530+
531531
err = usbh_device_set_configuration(udev, 1);
532532
if (err) {
533533
LOG_ERR("Failed to configure new device with address %u", udev->addr);

0 commit comments

Comments
 (0)