summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2014-03-07 09:38:15 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2014-03-07 09:38:15 +0000
commitf67dfc536972901758227a00fa38f4c5e99111e2 (patch)
tree41fd816f1f0db793df8ca3beb247bf390011a09c /sys
parent723f365bcf24694f40daf89b769160b21c500168 (diff)
We already have three identical copies of the *hci_str() function,
so merge them into usbd_str() to not introduce other copies with the upcoming HC drivers.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/ehci.c26
-rw-r--r--sys/dev/usb/ohci.c27
-rw-r--r--sys/dev/usb/uhci.c26
-rw-r--r--sys/dev/usb/usbdi.c20
-rw-r--r--sys/dev/usb/usbdi.h4
5 files changed, 34 insertions, 69 deletions
diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c
index 633fce39a83..952d860a37f 100644
--- a/sys/dev/usb/ehci.c
+++ b/sys/dev/usb/ehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ehci.c,v 1.141 2014/02/24 18:21:20 mpi Exp $ */
+/* $OpenBSD: ehci.c,v 1.142 2014/03/07 09:38:14 mpi Exp $ */
/* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */
/*
@@ -175,7 +175,6 @@ void ehci_device_isoc_done(struct usbd_xfer *);
void ehci_device_clear_toggle(struct usbd_pipe *pipe);
void ehci_noop(struct usbd_pipe *pipe);
-int ehci_str(usb_string_descriptor_t *, int, const char *);
void ehci_pcd(struct ehci_softc *, struct usbd_xfer *);
void ehci_disown(struct ehci_softc *, int, int);
@@ -1874,23 +1873,6 @@ usb_hub_descriptor_t ehci_hubd = {
{0},
};
-int
-ehci_str(usb_string_descriptor_t *p, int l, const char *s)
-{
- int i;
-
- if (l == 0)
- return (0);
- p->bLength = 2 * strlen(s) + 2;
- if (l == 1)
- return (1);
- p->bDescriptorType = UDESC_STRING;
- l -= 2;
- for (i = 0; s[i] && l > 1; i++, l -= 2)
- USETW2(p->bString[i], 0, s[i]);
- return (2*i+2);
-}
-
/*
* Simulate a hardware hub by handling all the necessary requests.
*/
@@ -2013,13 +1995,13 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
totlen = 1;
switch (value & 0xff) {
case 0: /* Language table */
- totlen = ehci_str(buf, len, "\001");
+ totlen = usbd_str(buf, len, "\001");
break;
case 1: /* Vendor */
- totlen = ehci_str(buf, len, sc->sc_vendor);
+ totlen = usbd_str(buf, len, sc->sc_vendor);
break;
case 2: /* Product */
- totlen = ehci_str(buf, len, "EHCI root hub");
+ totlen = usbd_str(buf, len, "EHCI root hub");
break;
}
break;
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index 29b7c30adb9..f67500996a6 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ohci.c,v 1.119 2014/01/15 11:10:40 mpi Exp $ */
+/* $OpenBSD: ohci.c,v 1.120 2014/03/07 09:38:14 mpi Exp $ */
/* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
@@ -158,8 +158,6 @@ void ohci_device_isoc_done(struct usbd_xfer *);
usbd_status ohci_device_setintr(struct ohci_softc *sc,
struct ohci_pipe *pipe, int ival);
-int ohci_str(usb_string_descriptor_t *, int, const char *);
-
void ohci_timeout(void *);
void ohci_timeout_task(void *);
void ohci_rhsc_able(struct ohci_softc *, int);
@@ -2279,23 +2277,6 @@ usb_hub_descriptor_t ohci_hubd = {
{0},
};
-int
-ohci_str(usb_string_descriptor_t *p, int l, const char *s)
-{
- int i;
-
- if (l == 0)
- return (0);
- p->bLength = 2 * strlen(s) + 2;
- if (l == 1)
- return (1);
- p->bDescriptorType = UDESC_STRING;
- l -= 2;
- for (i = 0; s[i] && l > 1; i++, l -= 2)
- USETW2(p->bString[i], 0, s[i]);
- return (2*i+2);
-}
-
/*
* Simulate a hardware hub by handling all the necessary requests.
*/
@@ -2399,13 +2380,13 @@ ohci_root_ctrl_start(struct usbd_xfer *xfer)
totlen = 1;
switch (value & 0xff) {
case 0: /* Language table */
- totlen = ohci_str(buf, len, "\001");
+ totlen = usbd_str(buf, len, "\001");
break;
case 1: /* Vendor */
- totlen = ohci_str(buf, len, sc->sc_vendor);
+ totlen = usbd_str(buf, len, sc->sc_vendor);
break;
case 2: /* Product */
- totlen = ohci_str(buf, len, "OHCI root hub");
+ totlen = usbd_str(buf, len, "OHCI root hub");
break;
}
break;
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index 903b5650070..7752db7660a 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhci.c,v 1.105 2013/12/09 01:02:06 brad Exp $ */
+/* $OpenBSD: uhci.c,v 1.106 2014/03/07 09:38:14 mpi Exp $ */
/* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -152,7 +152,6 @@ void uhci_add_bulk(struct uhci_softc *, struct uhci_soft_qh *);
void uhci_remove_ls_ctrl(struct uhci_softc *, struct uhci_soft_qh *);
void uhci_remove_hs_ctrl(struct uhci_softc *, struct uhci_soft_qh *);
void uhci_remove_bulk(struct uhci_softc *,struct uhci_soft_qh *);
-int uhci_str(usb_string_descriptor_t *, int, char *);
void uhci_add_loop(struct uhci_softc *sc);
void uhci_rem_loop(struct uhci_softc *sc);
@@ -2890,23 +2889,6 @@ usb_hub_descriptor_t uhci_hubd_piix = {
{ 0x00 }, /* both ports are removable */
};
-int
-uhci_str(usb_string_descriptor_t *p, int l, char *s)
-{
- int i;
-
- if (l == 0)
- return (0);
- p->bLength = 2 * strlen(s) + 2;
- if (l == 1)
- return (1);
- p->bDescriptorType = UDESC_STRING;
- l -= 2;
- for (i = 0; s[i] && l > 1; i++, l -= 2)
- USETW2(p->bString[i], 0, s[i]);
- return (2*i+2);
-}
-
/*
* The USB hub protocol requires that SET_FEATURE(PORT_RESET) also
* enables the port, and also states that SET_FEATURE(PORT_ENABLE)
@@ -3105,13 +3087,13 @@ uhci_root_ctrl_start(struct usbd_xfer *xfer)
totlen = 1;
switch (value & 0xff) {
case 0: /* Language table */
- totlen = uhci_str(buf, len, "\001");
+ totlen = usbd_str(buf, len, "\001");
break;
case 1: /* Vendor */
- totlen = uhci_str(buf, len, sc->sc_vendor);
+ totlen = usbd_str(buf, len, sc->sc_vendor);
break;
case 2: /* Product */
- totlen = uhci_str(buf, len, "UHCI root hub");
+ totlen = usbd_str(buf, len, "UHCI root hub");
break;
}
break;
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index 4cb218287f4..202b09dd578 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi.c,v 1.69 2014/03/06 23:53:11 mpi Exp $ */
+/* $OpenBSD: usbdi.c,v 1.70 2014/03/07 09:38:14 mpi Exp $ */
/* $NetBSD: usbdi.c,v 1.103 2002/09/27 15:37:38 provos Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */
@@ -1106,3 +1106,21 @@ usbd_desc_iter_next(struct usbd_desc_iter *iter)
}
return desc;
}
+
+int
+usbd_str(usb_string_descriptor_t *p, int l, const char *s)
+{
+ int i;
+
+ if (l == 0)
+ return (0);
+ p->bLength = 2 * strlen(s) + 2;
+ if (l == 1)
+ return (1);
+ p->bDescriptorType = UDESC_STRING;
+ l -= 2;
+ for (i = 0; s[i] && l > 1; i++, l -= 2)
+ USETW2(p->bString[i], 0, s[i]);
+ return (2*i+2);
+}
+
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index 461c430fcc0..819bb291c32 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi.h,v 1.61 2014/03/06 23:51:04 mpi Exp $ */
+/* $OpenBSD: usbdi.h,v 1.62 2014/03/07 09:38:14 mpi Exp $ */
/* $NetBSD: usbdi.h,v 1.62 2002/07/11 21:14:35 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */
@@ -172,6 +172,8 @@ struct usbd_desc_iter {
void usbd_desc_iter_init(struct usbd_device *, struct usbd_desc_iter *);
const usb_descriptor_t *usbd_desc_iter_next(struct usbd_desc_iter *);
+int usbd_str(usb_string_descriptor_t *, int, const char *);
+
/*
* The usb_task structs form a queue of things to run in the USB task
* threads. Normally this is just device discovery when a connect/disconnect