Date: Tue, 1 Jul 2008 16:49:49 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 144427 for review Message-ID: <200807011649.m61GnnWM045493@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=144427 Change 144427 by hselasky@hselasky_laptop001 on 2008/07/01 16:48:54 Mostly USB HUB descriptor cleanup. The substitution I made for the HUB descriptor size was incorrect. Cleanup this and some other USB descriptor related stuff. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/controller/at91dci.c#3 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/ehci2.c#4 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/ehci2.h#3 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/ohci2.c#3 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/ohci2.h#3 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.c#4 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.h#3 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/uss820dci.c#3 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#6 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_request.c#4 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_request.h#3 edit .. //depot/projects/usb/src/sys/dev/usb2/include/usb2_standard.h#4 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/controller/at91dci.c#3 (text+ko) ==== @@ -1830,8 +1830,8 @@ }, }; -static const struct usb2_hub_descriptor at91dci_hubd = { - .bDescLength = sizeof(struct usb2_hub_descriptor), +static const struct usb2_hub_descriptor_min at91dci_hubd = { + .bDescLength = sizeof(at91dci_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, .wHubCharacteristics[0] = ==== //depot/projects/usb/src/sys/dev/usb2/controller/ehci2.c#4 (text+ko) ==== @@ -2975,35 +2975,33 @@ static const struct ehci_config_desc ehci_confd = { .confd = { - sizeof(struct usb2_config_descriptor), - UDESC_CONFIG, - {sizeof(ehci_confd), 0}, - 1, - 1, - 0, - UC_SELF_POWERED, - 0 /* max power */ + .bLength = sizeof(struct usb2_config_descriptor), + .bDescriptorType = UDESC_CONFIG, + .wTotalLength[0] = sizeof(ehci_confd), + .bNumInterface = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = UC_SELF_POWERED, + .bMaxPower = 0 /* max power */ }, .ifcd = { - sizeof(struct usb2_interface_descriptor), - UDESC_INTERFACE, - 0, - 0, - 1, - UICLASS_HUB, - UISUBCLASS_HUB, - UIPROTO_HSHUBSTT, + .bLength = sizeof(struct usb2_interface_descriptor), + .bDescriptorType = UDESC_INTERFACE, + .bNumEndpoints = 1, + .bInterfaceClass = UICLASS_HUB, + .bInterfaceSubClass = UISUBCLASS_HUB, + .bInterfaceProtocol = UIPROTO_HSHUBSTT, 0 }, .endpd = { - sizeof(struct usb2_endpoint_descriptor), - UDESC_ENDPOINT, - UE_DIR_IN | EHCI_INTR_ENDPT, - UE_INTERRUPT, - {8, 0}, /* max packet (63 ports) */ - 255 + .bLength = sizeof(struct usb2_endpoint_descriptor), + .bDescriptorType = UDESC_ENDPOINT, + .bEndpointAddress = UE_DIR_IN | EHCI_INTR_ENDPT, + .bmAttributes = UE_INTERRUPT, + .wMaxPacketSize[0] = 8, /* max packet (63 ports) */ + .bInterval = 255, }, }; @@ -3142,7 +3140,7 @@ goto done; } std->len = sizeof(ehci_confd); - sc->sc_hub_desc.confd = ehci_confd; + std->ptr = USB_ADD_BYTES(&ehci_confd, 0); break; case UDESC_STRING: ==== //depot/projects/usb/src/sys/dev/usb2/controller/ehci2.h#3 (text+ko) ==== @@ -438,7 +438,6 @@ struct usb2_device_descriptor devd; struct usb2_device_qualifier odevd; struct usb2_hub_descriptor hubd; - struct ehci_config_desc confd; uint8_t temp[128]; }; ==== //depot/projects/usb/src/sys/dev/usb2/controller/ohci2.c#3 (text+ko) ==== @@ -2121,35 +2121,32 @@ struct ohci_config_desc ohci_confd = { .confd = { - sizeof(struct usb2_config_descriptor), - UDESC_CONFIG, - {sizeof(ohci_confd), 0}, - 1, - 1, - 0, - UC_SELF_POWERED, - 0 /* max power */ + .bLength = sizeof(struct usb2_config_descriptor), + .bDescriptorType = UDESC_CONFIG, + .wTotalLength[0] = sizeof(ohci_confd), + .bNumInterface = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = UC_SELF_POWERED, + .bMaxPower = 0, /* max power */ }, .ifcd = { - sizeof(struct usb2_interface_descriptor), - UDESC_INTERFACE, - 0, - 0, - 1, - UICLASS_HUB, - UISUBCLASS_HUB, - UIPROTO_FSHUB, - 0 + .bLength = sizeof(struct usb2_interface_descriptor), + .bDescriptorType = UDESC_INTERFACE, + .bNumEndpoints = 1, + .bInterfaceClass = UICLASS_HUB, + .bInterfaceSubClass = UISUBCLASS_HUB, + .bInterfaceProtocol = UIPROTO_FSHUB, }, .endpd = { - sizeof(struct usb2_endpoint_descriptor), - UDESC_ENDPOINT, - UE_DIR_IN | OHCI_INTR_ENDPT, - UE_INTERRUPT, - {32, 0}, /* max packet (255 ports) */ - 255 + .bLength = sizeof(struct usb2_endpoint_descriptor), + .bDescriptorType = UDESC_ENDPOINT, + .bEndpointAddress = UE_DIR_IN | OHCI_INTR_ENDPT, + .bmAttributes = UE_INTERRUPT, + .wMaxPacketSize[0] = 32,/* max packet (255 ports) */ + .bInterval = 255, }, }; @@ -2259,7 +2256,7 @@ goto done; } std->len = sizeof(ohci_confd); - sc->sc_hub_desc.confd = ohci_confd; + std->ptr = USB_ADD_BYTES(&ohci_confd, 0); break; case UDESC_STRING: ==== //depot/projects/usb/src/sys/dev/usb2/controller/ohci2.h#3 (text+ko) ==== @@ -311,7 +311,6 @@ struct usb2_port_status ps; struct usb2_device_descriptor devd; struct usb2_hub_descriptor hubd; - struct ohci_config_desc confd; uint8_t temp[128]; }; ==== //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.c#4 (text+ko) ==== @@ -2363,42 +2363,39 @@ static const struct uhci_config_desc uhci_confd = { .confd = { - sizeof(struct usb2_config_descriptor), - UDESC_CONFIG, - {sizeof(uhci_confd), 0}, - 1, - 1, - 0, - UC_SELF_POWERED, - 0 /* max power */ + .bLength = sizeof(struct usb2_config_descriptor), + .bDescriptorType = UDESC_CONFIG, + .wTotalLength[0] = sizeof(uhci_confd), + .bNumInterface = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = UC_SELF_POWERED, + .bMaxPower = 0 /* max power */ }, .ifcd = { - sizeof(struct usb2_interface_descriptor), - UDESC_INTERFACE, - 0, - 0, - 1, - UICLASS_HUB, - UISUBCLASS_HUB, - UIPROTO_FSHUB, - 0 + .bLength = sizeof(struct usb2_interface_descriptor), + .bDescriptorType = UDESC_INTERFACE, + .bNumEndpoints = 1, + .bInterfaceClass = UICLASS_HUB, + .bInterfaceSubClass = UISUBCLASS_HUB, + .bInterfaceProtocol = UIPROTO_FSHUB, }, .endpd = { - sizeof(struct usb2_endpoint_descriptor), - UDESC_ENDPOINT, - UE_DIR_IN | UHCI_INTR_ENDPT, - UE_INTERRUPT, - {8, 0}, /* max packet (63 ports) */ - 255 + .bLength = sizeof(struct usb2_endpoint_descriptor), + .bDescriptorType = UDESC_ENDPOINT, + .bEndpointAddress = UE_DIR_IN | UHCI_INTR_ENDPT, + .bmAttributes = UE_INTERRUPT, + .wMaxPacketSize[0] = 8, /* max packet (63 ports) */ + .bInterval = 255, }, }; static const -struct usb2_hub_descriptor uhci_hubd_piix = +struct usb2_hub_descriptor_min uhci_hubd_piix = { - sizeof(struct usb2_hub_descriptor), + sizeof(uhci_hubd_piix), UDESC_HUB, 2, {UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL, 0}, @@ -2618,7 +2615,7 @@ goto done; } std->len = sizeof(uhci_confd); - sc->sc_hub_desc.confd = uhci_confd; + std->ptr = USB_ADD_BYTES(&uhci_confd, 0); break; case UDESC_STRING: @@ -2763,7 +2760,7 @@ goto done; } std->len = sizeof(uhci_hubd_piix); - sc->sc_hub_desc.hubd = uhci_hubd_piix; + std->ptr = USB_ADD_BYTES(&uhci_hubd_piix, 0); break; case C(UR_GET_STATUS, UT_READ_CLASS_DEVICE): std->len = 16; ==== //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.h#3 (text+ko) ==== @@ -241,8 +241,6 @@ struct usb2_status stat; struct usb2_port_status ps; struct usb2_device_descriptor devd; - struct usb2_hub_descriptor hubd; - struct uhci_config_desc confd; uint8_t temp[128]; }; ==== //depot/projects/usb/src/sys/dev/usb2/controller/uss820dci.c#3 (text+ko) ==== @@ -1861,8 +1861,8 @@ }, }; -static const struct usb2_hub_descriptor uss820dci_hubd = { - .bDescLength = sizeof(struct usb2_hub_descriptor), +static const struct usb2_hub_descriptor_min uss820dci_hubd = { + .bDescLength = sizeof(uss820dci_hubd), .bDescriptorType = UDESC_HUB, .bNbrPorts = 1, .wHubCharacteristics[0] = ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#6 (text+ko) ==== @@ -596,7 +596,6 @@ struct usb2_device *udev = uaa->device; struct usb2_device *parent_hub = udev->parent_hub; struct usb2_hub *hub; - struct usb2_device_request req; struct usb2_hub_descriptor hubdesc; uint16_t pwrdly; uint8_t x; @@ -632,29 +631,22 @@ } if (!udev->flags.self_powered && parent_hub && (!parent_hub->flags.self_powered)) { - DPRINTF(-1, "bus powered hub connected to " - "bus powered hub. HUB ignored!\n"); + DPRINTF(-1, "bus powered HUB connected to " + "bus powered HUB. HUB ignored!\n"); goto error; } - /* get hub descriptor */ + /* get HUB descriptor */ - DPRINTF(1, "getting hub descriptor\n"); + DPRINTF(1, "getting HUB descriptor\n"); - req.bmRequestType = UT_READ_CLASS_DEVICE; - req.bRequest = UR_GET_DESCRIPTOR; - USETW2(req.wValue, UDESC_HUB, 0); - USETW(req.wIndex, 0); - USETW(req.wLength, 9); /* assuming that there is one port */ - - err = usb2_do_request(udev, &Giant, &req, &hubdesc); + /* assuming that there is one port */ + err = usb2_req_get_hub_descriptor(udev, &Giant, &hubdesc, 1); nports = hubdesc.bNbrPorts; if (!err && (nports >= 8)) { - uint16_t len = 8 + ((nports + 7) / 8); - - USETW(req.wLength, len); - err = usb2_do_request(udev, &Giant, &req, &hubdesc); + /* get complete HUB descriptor */ + err = usb2_req_get_hub_descriptor(udev, &Giant, &hubdesc, nports); } if (err) { DPRINTF(-1, "getting hub descriptor failed," ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_request.c#4 (text+ko) ==== @@ -892,7 +892,7 @@ req.bRequest = UR_GET_STATUS; USETW(req.wValue, 0); USETW(req.wIndex, 0); - USETW(req.wLength, sizeof(usb2_error_t)); + USETW(req.wLength, sizeof(*st)); return (usb2_do_request(udev, mtx, &req, st)); } @@ -905,15 +905,16 @@ *------------------------------------------------------------------------*/ usb2_error_t usb2_req_get_hub_descriptor(struct usb2_device *udev, struct mtx *mtx, - struct usb2_hub_descriptor *hd) + struct usb2_hub_descriptor *hd, uint8_t nports) { struct usb2_device_request req; + uint16_t len = (nports + 7 + (8 * 8)) / 8; req.bmRequestType = UT_READ_CLASS_DEVICE; req.bRequest = UR_GET_DESCRIPTOR; - USETW(req.wValue, 0); + USETW2(req.wValue, UDESC_HUB, 0); USETW(req.wIndex, 0); - USETW(req.wLength, sizeof(*hd)); + USETW(req.wLength, len); return (usb2_do_request(udev, mtx, &req, hd)); } ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_request.h#3 (text+ko) ==== @@ -36,7 +36,7 @@ usb2_error_t usb2_req_get_desc(struct usb2_device *udev, struct mtx *mtx, void *desc, uint16_t min_len, uint16_t max_len, uint16_t id, uint8_t type, uint8_t index, uint8_t retries); usb2_error_t usb2_req_get_device_desc(struct usb2_device *udev, struct mtx *mtx, struct usb2_device_descriptor *d); usb2_error_t usb2_req_get_device_status(struct usb2_device *udev, struct mtx *mtx, struct usb2_status *st); -usb2_error_t usb2_req_get_hub_descriptor(struct usb2_device *udev, struct mtx *mtx, struct usb2_hub_descriptor *hd); +usb2_error_t usb2_req_get_hub_descriptor(struct usb2_device *udev, struct mtx *mtx, struct usb2_hub_descriptor *hd, uint8_t nports); usb2_error_t usb2_req_get_hub_status(struct usb2_device *udev, struct mtx *mtx, struct usb2_hub_status *st); usb2_error_t usb2_req_get_port_status(struct usb2_device *udev, struct mtx *mtx, struct usb2_port_status *ps, uint8_t port); usb2_error_t usb2_req_get_report(struct usb2_device *udev, struct mtx *mtx, void *data, uint16_t len, uint8_t iface_index, uint8_t type, uint8_t id); ==== //depot/projects/usb/src/sys/dev/usb2/include/usb2_standard.h#4 (text+ko) ==== @@ -412,6 +412,18 @@ /* deprecated */ uByte PortPowerCtrlMask[1]; } __packed; +/* minimum HUB descriptor (8-ports maximum) */ +struct usb2_hub_descriptor_min { + uByte bDescLength; + uByte bDescriptorType; + uByte bNbrPorts; + uWord wHubCharacteristics; + uByte bPwrOn2PwrGood; + uByte bHubContrCurrent; + uByte DeviceRemovable[1]; + uByte PortPowerCtrlMask[1]; +} __packed; + struct usb2_device_qualifier { uByte bLength; uByte bDescriptorType;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807011649.m61GnnWM045493>