Skip to content

Commit

Permalink
usb/ehci: fix root hub descriptors
Browse files Browse the repository at this point in the history
JIRA: RTOS-784
  • Loading branch information
jmaksymowicz authored and agkaminski committed Mar 8, 2024
1 parent f4f4412 commit 05c71f3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions usb/ehci/ehci-hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static const struct {
const char manufacturer[16];
} __attribute__((packed)) ehci_descs = {
{
.bLength = 18,
.bLength = sizeof(ehci_descs.dev),
.bcdUSB = 0x0200,
.bDeviceClass = USB_CLASS_HUB,
.bDeviceSubClass = 0,
Expand All @@ -50,18 +50,18 @@ static const struct {
.bNumConfigurations = 1,
},
{
.bLength = 9,
.bLength = sizeof(ehci_descs.cfg),
.bDescriptorType = USB_DESC_CONFIG,
.wTotalLength = 40,
.wTotalLength = sizeof(ehci_descs.cfg) + sizeof(ehci_descs.iface) + sizeof(ehci_descs.ep),
.bNumInterfaces = 1,
.bConfigurationValue = 1,
.iConfiguration = 0,
.bmAttributes = 0,
.bMaxPower = 0,
},
{
.bLength = 9,
.bDescriptorType = USB_DESC_CONFIG,
.bLength = sizeof(ehci_descs.iface),
.bDescriptorType = USB_DESC_INTERFACE,
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = 1,
Expand All @@ -71,7 +71,7 @@ static const struct {
.iInterface = 0,
},
{
.bLength = 7,
.bLength = sizeof(ehci_descs.ep),
.bDescriptorType = USB_DESC_ENDPOINT,
.bEndpointAddress = USB_ENDPT_DIR_IN | (1 << 7),
.bmAttributes = USB_ENDPT_TYPE_INTR,
Expand Down Expand Up @@ -290,11 +290,11 @@ static int ehci_getDesc(usb_dev_t *hub, int type, int index, char *buf, size_t s

switch (type) {
case USB_DESC_DEVICE:
bytes = min(size, sizeof(ehci_descs.dev));
bytes = min(size, ehci_descs.dev.bLength);
memcpy(buf, &ehci_descs.dev, bytes);
break;
case USB_DESC_CONFIG:
bytes = min(size, sizeof(ehci_descs.dev) + sizeof(ehci_descs.iface) + sizeof(ehci_descs.ep));
bytes = min(size, ehci_descs.cfg.wTotalLength);
memcpy(buf, &ehci_descs.cfg, bytes);
break;
case USB_DESC_STRING:
Expand Down

0 comments on commit 05c71f3

Please sign in to comment.