summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/uhub.c25
-rw-r--r--sys/dev/usb/usbdi_util.c17
-rw-r--r--sys/dev/usb/usbdi_util.h4
3 files changed, 29 insertions, 17 deletions
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c
index 26d913d7739..e656b07898b 100644
--- a/sys/dev/usb/uhub.c
+++ b/sys/dev/usb/uhub.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhub.c,v 1.63 2013/10/19 08:29:30 mpi Exp $ */
+/* $OpenBSD: uhub.c,v 1.64 2014/03/07 18:57:23 mpi Exp $ */
/* $NetBSD: uhub.c,v 1.64 2003/02/08 03:32:51 ichiro Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
@@ -121,14 +121,16 @@ uhub_attach(struct device *parent, struct device *self, void *aux)
struct uhub_softc *sc = (struct uhub_softc *)self;
struct usb_attach_arg *uaa = aux;
struct usbd_device *dev = uaa->device;
- usbd_status err;
struct usbd_hub *hub = NULL;
- usb_device_request_t req;
usb_hub_descriptor_t hubdesc;
- int p, port, nports, nremov, pwrdly;
+ int p, port, nports, pwrdly;
struct usbd_interface *iface;
usb_endpoint_descriptor_t *ed;
struct usbd_tt *tts = NULL;
+ usbd_status err;
+#ifdef UHUB_DEBUG
+ int nremov;
+#endif
sc->sc_hub = dev;
@@ -146,28 +148,21 @@ uhub_attach(struct device *parent, struct device *self, void *aux)
}
/* Get hub descriptor. */
- req.bmRequestType = UT_READ_CLASS_DEVICE;
- req.bRequest = UR_GET_DESCRIPTOR;
- USETW2(req.wValue, UDESC_HUB, 0);
- USETW(req.wIndex, 0);
- USETW(req.wLength, USB_HUB_DESCRIPTOR_SIZE);
- err = usbd_do_request(dev, &req, &hubdesc);
+ err = usbd_get_hub_descriptor(dev, &hubdesc, 1);
nports = hubdesc.bNbrPorts;
- if (!err && nports > 7) {
- USETW(req.wLength, USB_HUB_DESCRIPTOR_SIZE + (nports+1) / 8);
- err = usbd_do_request(dev, &req, &hubdesc);
- }
+ if (!err && nports > 7)
+ usbd_get_hub_descriptor(dev, &hubdesc, nports);
if (err) {
DPRINTF("%s: getting hub descriptor failed, error=%s\n",
sc->sc_dev.dv_xname, usbd_errstr(err));
return;
}
+#ifdef UHUB_DEBUG
for (nremov = 0, port = 1; port <= nports; port++)
if (!UHD_NOT_REMOV(&hubdesc, port))
nremov++;
-#ifdef UHUB_DEBUG
printf("%s: %d port%s with %d removable, %s powered",
sc->sc_dev.dv_xname, nports, nports != 1 ? "s" : "",
nremov, dev->self_powered ? "self" : "bus");
diff --git a/sys/dev/usb/usbdi_util.c b/sys/dev/usb/usbdi_util.c
index 0ee79ee1ef5..439209de101 100644
--- a/sys/dev/usb/usbdi_util.c
+++ b/sys/dev/usb/usbdi_util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi_util.c,v 1.34 2013/11/13 13:48:08 pirofti Exp $ */
+/* $OpenBSD: usbdi_util.c,v 1.35 2014/03/07 18:57:23 mpi Exp $ */
/* $NetBSD: usbdi_util.c,v 1.40 2002/07/11 21:14:36 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi_util.c,v 1.14 1999/11/17 22:33:50 n_hibma Exp $ */
@@ -106,6 +106,21 @@ usbd_get_hub_status(struct usbd_device *dev, usb_hub_status_t *st)
}
usbd_status
+usbd_get_hub_descriptor(struct usbd_device *dev, usb_hub_descriptor_t *hd,
+ uint8_t nports)
+{
+ usb_device_request_t req;
+ uint16_t len = USB_HUB_DESCRIPTOR_SIZE + (nports + 1) / 8;
+
+ req.bmRequestType = UT_READ_CLASS_DEVICE;
+ req.bRequest = UR_GET_DESCRIPTOR;
+ USETW2(req.wValue, UDESC_HUB, 0);
+ USETW(req.wIndex, 0);
+ USETW(req.wLength, len);
+ return (usbd_do_request(dev, &req, hd));
+}
+
+usbd_status
usbd_set_address(struct usbd_device *dev, int addr)
{
usb_device_request_t req;
diff --git a/sys/dev/usb/usbdi_util.h b/sys/dev/usb/usbdi_util.h
index 801febb5e1c..d140e7f8409 100644
--- a/sys/dev/usb/usbdi_util.h
+++ b/sys/dev/usb/usbdi_util.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi_util.h,v 1.23 2013/11/02 12:23:58 mpi Exp $ */
+/* $OpenBSD: usbdi_util.h,v 1.24 2014/03/07 18:57:23 mpi Exp $ */
/* $NetBSD: usbdi_util.h,v 1.28 2002/07/11 21:14:36 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi_util.h,v 1.9 1999/11/17 22:33:50 n_hibma Exp $ */
@@ -43,6 +43,8 @@ usbd_status usbd_set_port_feature(struct usbd_device *dev, int, int);
usbd_status usbd_clear_port_feature(struct usbd_device *, int, int);
usbd_status usbd_get_device_status(struct usbd_device *, usb_status_t *);
usbd_status usbd_get_hub_status(struct usbd_device *, usb_hub_status_t *);
+usbd_status usbd_get_hub_descriptor(struct usbd_device *,
+ usb_hub_descriptor_t *, uint8_t);
usbd_status usbd_get_protocol(struct usbd_interface *dev, u_int8_t *report);
usbd_status usbd_set_protocol(struct usbd_interface *dev, int report);
usbd_status usbd_get_report_descriptor(struct usbd_device *dev, int ifcno,