Skip to content

Commit 2ff20a8

Browse files
jfischer-nokartben
authored andcommitted
usb: host: allow partially read device descriptor
To determine bMaxPacketSize0, which is unknown after the reset. Signed-off-by: Johann Fischer <[email protected]>
1 parent a7c8a8d commit 2ff20a8

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

subsys/usb/host/usbh_ch9.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,11 @@ int usbh_req_desc(struct usb_device *const udev,
116116
}
117117

118118
int usbh_req_desc_dev(struct usb_device *const udev,
119+
const uint16_t len,
119120
struct usb_device_descriptor *const desc)
120121
{
121122
const uint8_t type = USB_DESC_DEVICE;
122-
const uint16_t wLength = sizeof(struct usb_device_descriptor);
123+
const uint16_t wLength = MIN(len, sizeof(struct usb_device_descriptor));
123124
struct net_buf *buf;
124125
int ret;
125126

subsys/usb/host/usbh_ch9.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ int usbh_req_desc(struct usb_device *const udev,
2727
struct net_buf *const data);
2828

2929
int usbh_req_desc_dev(struct usb_device *const udev,
30+
const uint16_t len,
3031
struct usb_device_descriptor *const dev);
3132

3233
int usbh_req_desc_cfg(struct usb_device *const udev,

subsys/usb/host/usbh_shell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static int cmd_desc_device(const struct shell *sh,
188188
struct usb_device_descriptor desc;
189189
int err;
190190

191-
err = usbh_req_desc_dev(udev, &desc);
191+
err = usbh_req_desc_dev(udev, sizeof(desc), &desc);
192192
if (err) {
193193
shell_print(sh, "host: Failed to request device descriptor");
194194
} else {

0 commit comments

Comments
 (0)