summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2013-11-02 12:23:59 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2013-11-02 12:23:59 +0000
commit6b22f0ec5966fbb214e9e77a48b073c56abd34d6 (patch)
tree90101e5bf2bab87b6139e0c3530f5fa6be325e1b
parent033c8a289ea6e79e8060870a3ae5291dfbb6ec92 (diff)
Remove a layer of abstraction for fetching a configuration descriptor.
-rw-r--r--sys/dev/usb/usb_subr.c17
-rw-r--r--sys/dev/usb/usbdi_util.c22
-rw-r--r--sys/dev/usb/usbdi_util.h4
3 files changed, 12 insertions, 31 deletions
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index a881a1df9ad..dd10ac8752e 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_subr.c,v 1.93 2013/08/21 13:45:34 mpi Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.94 2013/11/02 12:23:58 mpi Exp $ */
/* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -610,8 +610,9 @@ usbd_set_config_no(struct usbd_device *dev, int no, int msg)
DPRINTFN(5,("usbd_set_config_no: %d\n", no));
/* Figure out what config index to use. */
for (index = 0; index < dev->ddesc.bNumConfigurations; index++) {
- err = usbd_get_config_desc(dev, index, &cd);
- if (err)
+ err = usbd_get_desc(dev, UDESC_CONFIG, index,
+ USB_CONFIG_DESCRIPTOR_SIZE, &cd);
+ if (err || cd.bDescriptorType != UDESC_CONFIG)
return (err);
if (cd.bConfigurationValue == no)
return (usbd_set_config_index(dev, index, msg));
@@ -654,8 +655,9 @@ usbd_set_config_index(struct usbd_device *dev, int index, int msg)
}
/* Get the short descriptor. */
- err = usbd_get_config_desc(dev, index, &cd);
- if (err)
+ err = usbd_get_desc(dev, UDESC_CONFIG, index,
+ USB_CONFIG_DESCRIPTOR_SIZE, &cd);
+ if (err || cd.bDescriptorType != UDESC_CONFIG)
return (err);
len = UGETW(cd.wTotalLength);
cdp = malloc(len, M_USB, M_NOWAIT);
@@ -1394,8 +1396,9 @@ usbd_get_cdesc(struct usbd_device *dev, int index, int *lenp)
memcpy(cdesc, tdesc, len);
DPRINTFN(5,("usbd_get_cdesc: current, len=%d\n", len));
} else {
- err = usbd_get_config_desc(dev, index, &cdescr);
- if (err)
+ err = usbd_get_desc(dev, UDESC_CONFIG, index,
+ USB_CONFIG_DESCRIPTOR_SIZE, &cdescr);
+ if (err || cdescr.bDescriptorType != UDESC_CONFIG)
return (0);
len = UGETW(cdescr.wTotalLength);
DPRINTFN(5,("usbd_get_cdesc: index=%d, len=%d\n", index, len));
diff --git a/sys/dev/usb/usbdi_util.c b/sys/dev/usb/usbdi_util.c
index 4c12cde6a27..9029e8978d0 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.32 2013/09/20 15:34:51 mpi Exp $ */
+/* $OpenBSD: usbdi_util.c,v 1.33 2013/11/02 12:23:58 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 $ */
@@ -70,26 +70,6 @@ usbd_get_desc(struct usbd_device *dev, int type, int index, int len, void *desc)
}
usbd_status
-usbd_get_config_desc(struct usbd_device *dev, int confidx,
- usb_config_descriptor_t *d)
-{
- usbd_status err;
-
- DPRINTFN(3,("usbd_get_config_desc: confidx=%d\n", confidx));
- err = usbd_get_desc(dev, UDESC_CONFIG, confidx,
- USB_CONFIG_DESCRIPTOR_SIZE, d);
- if (err)
- return (err);
- if (d->bDescriptorType != UDESC_CONFIG) {
- DPRINTFN(-1,("usbd_get_config_desc: confidx=%d, bad desc "
- "len=%d type=%d\n", confidx, d->bLength,
- d->bDescriptorType));
- return (USBD_INVAL);
- }
- return (USBD_NORMAL_COMPLETION);
-}
-
-usbd_status
usbd_get_device_status(struct usbd_device *dev, usb_status_t *st)
{
usb_device_request_t req;
diff --git a/sys/dev/usb/usbdi_util.h b/sys/dev/usb/usbdi_util.h
index 8692d0bc4c1..801febb5e1c 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.22 2013/09/20 15:34:51 mpi Exp $ */
+/* $OpenBSD: usbdi_util.h,v 1.23 2013/11/02 12:23:58 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 $ */
@@ -34,8 +34,6 @@
usbd_status usbd_get_desc(struct usbd_device *dev, int type,
int index, int len, void *desc);
-usbd_status usbd_get_config_desc(struct usbd_device *, int,
- usb_config_descriptor_t *);
usbd_status usbd_set_address(struct usbd_device *dev, int addr);
usbd_status usbd_get_port_status(struct usbd_device *,
int, usb_port_status_t *);