summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/hid.c6
-rw-r--r--sys/dev/usb/ohci.c33
-rw-r--r--sys/dev/usb/ohcivar.h8
-rw-r--r--sys/dev/usb/ucom.c18
-rw-r--r--sys/dev/usb/ugen.c8
-rw-r--r--sys/dev/usb/uhci.c39
-rw-r--r--sys/dev/usb/uhcivar.h9
-rw-r--r--sys/dev/usb/uhid.c6
-rw-r--r--sys/dev/usb/uhub.c25
-rw-r--r--sys/dev/usb/ukbd.c20
-rw-r--r--sys/dev/usb/ulpt.c8
-rw-r--r--sys/dev/usb/umodem.c6
-rw-r--r--sys/dev/usb/ums.c12
-rw-r--r--sys/dev/usb/usb.c7
-rw-r--r--sys/dev/usb/usb_subr.c119
-rw-r--r--sys/dev/usb/usbdi.c49
-rw-r--r--sys/dev/usb/usbdi.h4
-rw-r--r--sys/dev/usb/usbdi_util.c4
18 files changed, 180 insertions, 201 deletions
diff --git a/sys/dev/usb/hid.c b/sys/dev/usb/hid.c
index 767fa86..bb852b7 100644
--- a/sys/dev/usb/hid.c
+++ b/sys/dev/usb/hid.c
@@ -51,9 +51,9 @@
#include <dev/usb/hid.h>
-#ifdef USB_DEBUG
-#define DPRINTF(x) if (usbdebug) printf x
-#define DPRINTFN(n,x) if (usbdebug>(n)) printf x
+#ifdef UHID_DEBUG
+#define DPRINTF(x) if (usbdebug) logprintf x
+#define DPRINTFN(n,x) if (usbdebug>(n)) logprintf x
extern int usbdebug;
#else
#define DPRINTF(x)
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index 31b6080..334a998 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -75,9 +75,18 @@
#include <machine/clock.h>
#define delay(d) DELAY(d)
+#endif
+#ifdef OHCI_DEBUG
+#define DPRINTF(x) if (ohcidebug) logprintf x
+#define DPRINTFN(n,x) if (ohcidebug>(n)) logprintf x
+int ohcidebug = 1;
+#else
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
#endif
+
/*
* The OHCI controller is little endian, so on big endian machines
* the data strored in memory needs to be swapped.
@@ -145,7 +154,7 @@ int ohci_str __P((usb_string_descriptor_t *, int, char *));
void ohci_timeout __P((void *));
void ohci_rhsc_able __P((ohci_softc_t *, int));
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
ohci_softc_t *thesc;
void ohci_dumpregs __P((ohci_softc_t *));
void ohci_dump_tds __P((ohci_soft_td_t *));
@@ -458,7 +467,7 @@ ohci_init(sc)
r = USBD_IOERROR;
goto bad3;
}
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
thesc = sc;
if (ohcidebug > 15)
ohci_dumpregs(sc);
@@ -494,7 +503,7 @@ ohci_init(sc)
sc->sc_noport = OHCI_GET_NDP(OREAD4(sc, OHCI_RH_DESCRIPTOR_A));
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (ohcidebug > 5)
ohci_dumpregs(sc);
#endif
@@ -515,7 +524,7 @@ ohci_init(sc)
return (r);
}
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
void ohcidump(void);
void ohcidump(void) { ohci_dumpregs(thesc); }
@@ -650,7 +659,7 @@ ohci_rhsc_able(sc, on)
}
}
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
char *ohci_cc_strs[] = {
"NO_ERROR",
"CRC",
@@ -686,7 +695,7 @@ ohci_process_done(sc, done)
sdone = std;
}
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (ohcidebug > 10) {
printf("ohci_process_done: TD done:\n");
ohci_dump_tds(sdone);
@@ -937,7 +946,7 @@ ohci_waitintr(sc, reqh)
usb_delay_ms(&sc->sc_bus, 1);
intrs = OREAD4(sc, OHCI_INTERRUPT_STATUS) & sc->sc_eintrs;
DPRINTFN(15,("ohci_waitintr: 0x%04x\n", intrs));
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (ohcidebug > 15)
ohci_dumpregs(sc);
#endif
@@ -1065,7 +1074,7 @@ ohci_device_request(reqh)
reqh->hcpriv = stat;
-#if USB_DEBUG
+#if UHCI_DEBUG
if (ohcidebug > 5) {
printf("ohci_device_request:\n");
ohci_dump_ed(sed);
@@ -1088,7 +1097,7 @@ ohci_device_request(reqh)
}
splx(s);
-#if USB_DEBUG
+#if UHCI_DEBUG
if (ohcidebug > 5) {
delay(5000);
printf("ohci_device_request: status=%x\n",
@@ -1206,7 +1215,7 @@ ohci_timeout(addr)
#endif
}
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
void
ohci_dump_tds(std)
ohci_soft_td_t *std;
@@ -2071,7 +2080,7 @@ ohci_device_intr_start(reqh)
reqh->hcpriv = xfer;
-#if USB_DEBUG
+#if UHCI_DEBUG
if (ohcidebug > 5) {
printf("ohci_device_intr_transfer:\n");
ohci_dump_ed(sed);
@@ -2092,7 +2101,7 @@ ohci_device_intr_start(reqh)
#endif
sed->ed->ed_flags &= LE(~OHCI_ED_SKIP);
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (ohcidebug > 5) {
delay(5000);
printf("ohci_device_intr_transfer: status=%x\n",
diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h
index 37abf2f..9063073 100644
--- a/sys/dev/usb/ohcivar.h
+++ b/sys/dev/usb/ohcivar.h
@@ -104,11 +104,3 @@ int ohci_intr __P((void *));
#define MS_TO_TICKS(ms) ((ms) * hz / 1000)
-#ifdef USB_DEBUG
-#define DPRINTF(x) if (ohcidebug) printf x
-#define DPRINTFN(n,x) if (ohcidebug>(n)) printf x
-extern int ohcidebug;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
-#endif
diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c
index 7724ece..07cc3f9 100644
--- a/sys/dev/usb/ucom.c
+++ b/sys/dev/usb/ucom.c
@@ -69,9 +69,9 @@
#include <dev/usb/usb_quirks.h>
#include <dev/usb/hid.h>
-#ifdef USB_DEBUG
-#define DPRINTF(x) if (ucomdebug) printf x
-#define DPRINTFN(n,x) if (ucomdebug>(n)) printf x
+#ifdef UCOM_DEBUG
+#define DPRINTF(x) if (ucomdebug) logprintf x
+#define DPRINTFN(n,x) if (ucomdebug>(n)) logprintf x
int ucomdebug = 1;
#else
#define DPRINTF(x)
@@ -95,12 +95,14 @@ USB_MATCH(ucom)
if (!uaa->iface)
return (UMATCH_NONE);
+
id = usbd_get_interface_descriptor(uaa->iface);
- if ((id &&
- id->bInterfaceClass != UCLASS_CDC) ||
- id->bInterfaceSubClass != USUBCLASS_ABSTRACT_CONTROL_MODEL)
- return (UMATCH_NONE);
- return (UMATCH_IFACECLASS_IFACESUBCLASS);
+ if ((id
+ && id->bInterfaceClass == UCLASS_CDC)
+ && id->bInterfaceSubClass == USUBCLASS_ABSTRACT_CONTROL_MODEL)
+ return (UMATCH_IFACECLASS_IFACESUBCLASS);
+
+ return (UMATCH_NONE);
}
USB_ATTACH(ucom)
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c
index 3eedc8a..cbd9e1e 100644
--- a/sys/dev/usb/ugen.c
+++ b/sys/dev/usb/ugen.c
@@ -65,9 +65,9 @@
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
-#ifdef USB_DEBUG
-#define DPRINTF(x) if (ugendebug) printf x
-#define DPRINTFN(n,x) if (ugendebug>(n)) printf x
+#ifdef UGEN_DEBUG
+#define DPRINTF(x) if (ugendebug) logprintf x
+#define DPRINTFN(n,x) if (ugendebug>(n)) logprintf x
int ugendebug = 1;
#else
#define DPRINTF(x)
@@ -735,7 +735,7 @@ ugenioctl(dev, cmd, addr, flag, p)
return (EINVAL);
switch (cmd) {
-#ifdef USB_DEBUG
+#ifdef UGEN_DEBUG
case USB_SETDEBUG:
ugendebug = *(int *)addr;
break;
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index 60bf2b2..30c69fd 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -80,6 +80,15 @@ cgiform.tpl
#define delay(d) DELAY(d)
#endif
+#ifdef UHCI_DEBUG
+#define DPRINTF(x) if (uhcidebug) logprintf x
+#define DPRINTFN(n,x) if (uhcidebug>(n)) logprintf x
+int uhcidebug = 1;
+#else
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#endif
+
#define MS_TO_TICKS(ms) ((ms) * hz / 1000)
struct uhci_pipe {
@@ -202,7 +211,7 @@ usbd_status uhci_device_setintr __P((uhci_softc_t *sc,
void uhci_intr_done __P((uhci_intr_info_t *ii));
void uhci_isoc_done __P((uhci_intr_info_t *ii));
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
static void uhci_dumpregs __P((uhci_softc_t *));
void uhci_dump_tds __P((uhci_soft_td_t *));
void uhci_dump_qh __P((uhci_soft_qh_t *));
@@ -382,7 +391,7 @@ uhci_init(sc)
return (uhci_run(sc, 1)); /* and here we go... */
}
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
static void
uhci_dumpregs(sc)
uhci_softc_t *sc;
@@ -582,7 +591,7 @@ uhci_remove_ctrl(sc, sqh)
DPRINTFN(10, ("uhci_remove_ctrl: sqh=%p\n", sqh));
for (pqh = sc->sc_ctl_start; pqh->qh->hlink != sqh; pqh=pqh->qh->hlink)
-#if defined(DIAGNOSTIC) || defined(USB_DEBUG)
+#if defined(DIAGNOSTIC) || defined(UHCI_DEBUG)
if (pqh->qh->qh_hlink & UHCI_PTR_T) {
printf("uhci_remove_ctrl: QH not found\n");
return;
@@ -625,7 +634,7 @@ uhci_remove_bulk(sc, sqh)
for (pqh = sc->sc_bulk_start;
pqh->qh->hlink != sqh;
pqh = pqh->qh->hlink)
-#if defined(DIAGNOSTIC) || defined(USB_DEBUG)
+#if defined(DIAGNOSTIC) || defined(UHCI_DEBUG)
if (pqh->qh->qh_hlink & UHCI_PTR_T) {
printf("uhci_remove_bulk: QH not found\n");
return;
@@ -648,7 +657,7 @@ uhci_intr(p)
uhci_intr_info_t *ii;
sc->sc_intrs++;
-#if defined(USB_DEBUG)
+#if defined(UHCI_DEBUG)
if (uhcidebug > 9) {
printf("uhci_intr %p\n", sc);
uhci_dumpregs(sc);
@@ -782,7 +791,7 @@ uhci_ii_done(ii, timo)
std = std->td->link.std) {
tst = std->td->td_status;
status |= tst;
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if ((tst & UHCI_TD_ERROR) && uhcidebug) {
printf("uhci_ii_done: intr error TD:\n");
uhci_dump_td(std);
@@ -1225,7 +1234,7 @@ uhci_device_bulk_start(reqh)
if (!isread && len != 0)
memcpy(KERNADDR(dmap), reqh->buffer, len);
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (uhcidebug > 10) {
printf("uhci_device_bulk_transfer: xfer(1)\n");
uhci_dump_tds(xfer);
@@ -1257,7 +1266,7 @@ uhci_device_bulk_start(reqh)
}
splx(s);
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (uhcidebug > 10) {
printf("uhci_device_bulk_transfer: xfer(2)\n");
uhci_dump_tds(xfer);
@@ -1385,7 +1394,7 @@ uhci_device_intr_start(reqh)
goto ret2;
xferend->td->td_status |= UHCI_TD_IOC;
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (uhcidebug > 10) {
printf("uhci_device_intr_transfer: xfer(1)\n");
uhci_dump_tds(xfer);
@@ -1411,7 +1420,7 @@ uhci_device_intr_start(reqh)
}
splx(s);
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (uhcidebug > 10) {
printf("uhci_device_intr_transfer: xfer(2)\n");
uhci_dump_tds(xfer);
@@ -1577,7 +1586,7 @@ uhci_device_request(reqh)
UHCI_TD_IN (0, endpt, addr, 1);
stat->td->td_buffer = 0;
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (uhcidebug > 20) {
printf("uhci_device_request: setup\n");
uhci_dump_td(setup);
@@ -1604,7 +1613,7 @@ uhci_device_request(reqh)
s = splusb();
uhci_add_ctrl(sc, sqh);
LIST_INSERT_HEAD(&sc->sc_intrhead, ii, list);
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (uhcidebug > 12) {
uhci_soft_td_t *std;
uhci_soft_qh_t *xqh;
@@ -1650,7 +1659,7 @@ uhci_device_isoc_transfer(reqh)
usbd_request_handle reqh;
{
struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
usbd_device_handle dev = upipe->pipe.device;
uhci_softc_t *sc = (uhci_softc_t *)dev->bus;
#endif
@@ -1851,7 +1860,7 @@ uhci_intr_done(ii)
dma, &xfer, &xferend);
xferend->td->td_status |= UHCI_TD_IOC;
-#ifdef USB_DEBUG
+#ifdef UHCI_DEBUG
if (uhcidebug > 10) {
printf("uhci_device_intr_done: xfer(1)\n");
uhci_dump_tds(xfer);
@@ -1967,7 +1976,7 @@ uhci_remove_intr(sc, n, sqh)
DPRINTFN(4, ("uhci_remove_intr: n=%d sqh=%p\n", n, sqh));
for (pqh = vf->hqh; pqh->qh->hlink != sqh; pqh = pqh->qh->hlink)
-#if defined(DIAGNOSTIC) || defined(USB_DEBUG)
+#if defined(DIAGNOSTIC) || defined(UHCI_DEBUG)
if (pqh->qh->qh_hlink & UHCI_PTR_T) {
printf("uhci_remove_intr: QH not found\n");
return;
diff --git a/sys/dev/usb/uhcivar.h b/sys/dev/usb/uhcivar.h
index 723b449..2171374 100644
--- a/sys/dev/usb/uhcivar.h
+++ b/sys/dev/usb/uhcivar.h
@@ -168,12 +168,3 @@ int uhci_intr __P((void *));
void uhci_reset __P((void *));
#endif
-#ifdef USB_DEBUG
-#define DPRINTF(x) if (uhcidebug) printf x
-#define DPRINTFN(n,x) if (uhcidebug>(n)) printf x
-extern int uhcidebug;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
-#endif
-
diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c
index a34ee70..a55944b 100644
--- a/sys/dev/usb/uhid.c
+++ b/sys/dev/usb/uhid.c
@@ -68,9 +68,9 @@
#include <dev/usb/hid.h>
#include <dev/usb/usb_quirks.h>
-#ifdef USB_DEBUG
-#define DPRINTF(x) if (uhiddebug) printf x
-#define DPRINTFN(n,x) if (uhiddebug>(n)) printf x
+#ifdef UHID_DEBUG
+#define DPRINTF(x) if (uhiddebug) logprintf x
+#define DPRINTFN(n,x) if (uhiddebug>(n)) logprintf x
int uhiddebug = 1;
#else
#define DPRINTF(x)
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c
index cae5fdb..2f4029c 100644
--- a/sys/dev/usb/uhub.c
+++ b/sys/dev/usb/uhub.c
@@ -64,7 +64,6 @@
#define DPRINTF(x) if (usbdebug) logprintf x
#define DPRINTFN(n,x) if (usbdebug>(n)) logprintf x
extern int usbdebug;
-extern char *usbd_error_strs[];
#else
#define DPRINTF(x)
#define DPRINTFN(n,x)
@@ -147,8 +146,8 @@ USB_ATTACH(uhub)
r = usbd_set_config_index(dev, 0, 1);
if (r != USBD_NORMAL_COMPLETION) {
- DPRINTF(("%s: configuration failed, error=%d(%s)\n",
- USBDEVNAME(sc->sc_dev), r, usbd_error_strs[r]));
+ DPRINTF(("%s: configuration failed, %s\n",
+ USBDEVNAME(sc->sc_dev), usbd_errstr(r)));
USB_ATTACH_ERROR_RETURN;
}
@@ -172,8 +171,8 @@ USB_ATTACH(uhub)
r = usbd_do_request(dev, &req, &hubdesc);
}
if (r != USBD_NORMAL_COMPLETION) {
- DPRINTF(("%s: getting hub descriptor failed, error=%d(%s)\n",
- USBDEVNAME(sc->sc_dev), r, usbd_error_strs[r]));
+ DPRINTF(("%s: getting hub descriptor failed, %s\n",
+ USBDEVNAME(sc->sc_dev), usbd_errstr(r)));
USB_ATTACH_ERROR_RETURN;
}
@@ -344,8 +343,8 @@ uhub_explore(dev)
up = &dev->hub->ports[port-1];
r = usbd_get_port_status(dev, port, &up->status);
if (r != USBD_NORMAL_COMPLETION) {
- DPRINTF(("uhub_explore: get port %d status failed error=%d(%s)\n",
- port, r, usbd_error_strs[r]));
+ DPRINTF(("uhub_explore: get port %d status failed, %s\n",
+ port, usbd_errstr(r)));
continue;
}
status = UGETW(up->status.wPortStatus);
@@ -355,18 +354,16 @@ uhub_explore(dev)
if (change & UPS_C_PORT_ENABLED) {
usbd_clear_port_feature(dev, port, UHF_C_PORT_ENABLE);
if (status & UPS_PORT_ENABLED) {
- printf("%s: illegal enable change, port %d\n",
+ printf("%s: port %d illegal enable change\n",
USBDEVNAME(sc->sc_dev), port);
} else {
/* Port error condition. */
if (up->restartcnt++ < USBD_RESTART_MAX) {
- printf("%s: port error, restarting "
- "port %d\n",
+ printf("%s: port %d error, restarting\n",
USBDEVNAME(sc->sc_dev), port);
goto disco;
} else {
- printf("%s: port error, giving up "
- "port %d\n",
+ printf("%s: port %d error, giving up\n",
USBDEVNAME(sc->sc_dev), port);
}
}
@@ -418,8 +415,8 @@ uhub_explore(dev)
port, up);
/* XXX retry a few times? */
if (r != USBD_NORMAL_COMPLETION) {
- DPRINTFN(-1,("uhub_explore: usb_new_device failed, "
- "error=%d(%s)\n", r, usbd_error_strs[r]));
+ DPRINTFN(-1,("uhub_explore: usb_new_device failed, %s\n",
+ usbd_errstr(r)));
/* Avoid addressing problems by disabling. */
/* usbd_reset_port(dev, port, &up->status); */
/* XXX
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index 8b485c8..82721c5 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -76,7 +76,7 @@
#define delay(d) DELAY(d)
-#ifdef USB_DEBUG
+#ifdef UKBD_DEBUG
#define DPRINTF(x) if (ukbddebug) logprintf x
#define DPRINTFN(n,x) if (ukbddebug>(n)) logprintf x
int ukbddebug = 1;
@@ -865,7 +865,7 @@ ukbd_interrupt(keyboard_t *kbd, void *arg)
if (state->ks_inputs <= 0)
return 0;
-#if USB_DEBUG
+#if UKBD_DEBUG
for (i = state->ks_inputhead, j = 0; j < state->ks_inputs; ++j,
i = (i + 1)%INPUTBUFSIZE) {
c = state->ks_input[i];
@@ -879,7 +879,7 @@ ukbd_interrupt(keyboard_t *kbd, void *arg)
printf("%d ", ud->keycode[i]);
}
printf("\n");
-#endif /* USB_DEBUG */
+#endif /* UKBD_DEBUG */
if (state->ks_polling)
return 0;
@@ -1425,15 +1425,17 @@ probe_keyboard(struct usb_attach_arg *uaa, int flags)
{
usb_interface_descriptor_t *id;
- /* Check that this is a keyboard that speaks the boot protocol. */
if (!uaa->iface)
return EINVAL;
+
+ /* Check that this is a keyboard that speaks the boot protocol. */
id = usbd_get_interface_descriptor(uaa->iface);
- if (id->bInterfaceClass != UCLASS_HID ||
- id->bInterfaceSubClass != USUBCLASS_BOOT ||
- id->bInterfaceProtocol != UPROTO_BOOT_KEYBOARD)
- return EINVAL;
- return 0;
+ if (id
+ && id->bInterfaceClass == UCLASS_HID
+ && id->bInterfaceSubClass == USUBCLASS_BOOT
+ && id->bInterfaceProtocol == UPROTO_BOOT_KEYBOARD)
+ return 0;
+ return EINVAL;
}
static int
diff --git a/sys/dev/usb/ulpt.c b/sys/dev/usb/ulpt.c
index e62fc92..0984460 100644
--- a/sys/dev/usb/ulpt.c
+++ b/sys/dev/usb/ulpt.c
@@ -67,9 +67,9 @@
#define LPTPRI (PZERO+8)
#define ULPT_BSIZE 1024
-#ifdef USB_DEBUG
-#define DPRINTF(x) if (ulptdebug) printf x
-#define DPRINTFN(n,x) if (ulptdebug>(n)) printf x
+#ifdef ULPT_DEBUG
+#define DPRINTF(x) if (ulptdebug) logprintf x
+#define DPRINTFN(n,x) if (ulptdebug>(n)) logprintf x
int ulptdebug = 1;
#else
#define DPRINTF(x)
@@ -300,7 +300,7 @@ ulptopen(dev, flag, mode, p)
sc->sc_flags = flags;
DPRINTF(("ulptopen: flags=0x%x\n", (unsigned)flags));
-#if defined(USB_DEBUG) && defined(__FreeBSD__)
+#if defined(ULPT_DEBUG) && defined(__FreeBSD__)
/* Ignoring these flags might not be a good idea */
if ((flags & ~ULPT_NOPRIME) != 0)
printf("ulptopen: flags ignored: %b\n", flags,
diff --git a/sys/dev/usb/umodem.c b/sys/dev/usb/umodem.c
index 4ec326e..7a1b600 100644
--- a/sys/dev/usb/umodem.c
+++ b/sys/dev/usb/umodem.c
@@ -65,9 +65,9 @@
#include <dev/usb/usbdevs.h>
#include <dev/usb/usb_quirks.h>
-#ifdef USB_DEBUG
-#define DPRINTF(x) if (umodemdebug) printf x
-#define DPRINTFN(n,x) if (umodemdebug>(n)) printf x
+#ifdef UMODEM_DEBUG
+#define DPRINTF(x) if (umodemdebug) logprintf x
+#define DPRINTFN(n,x) if (umodemdebug>(n)) logprintf x
int umodemdebug = 1;
#else
#define DPRINTF(x)
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c
index ca8a991..9464566 100644
--- a/sys/dev/usb/ums.c
+++ b/sys/dev/usb/ums.c
@@ -74,9 +74,9 @@
#include <machine/mouse.h>
#endif
-#ifdef USB_DEBUG
-#define DPRINTF(x) if (umsdebug) printf x
-#define DPRINTFN(n,x) if (umsdebug>(n)) printf x
+#ifdef UMS_DEBUG
+#define DPRINTF(x) if (umsdebug) logprintf x
+#define DPRINTFN(n,x) if (umsdebug>(n)) logprintf x
int umsdebug = 1;
#else
#define DPRINTF(x)
@@ -307,7 +307,7 @@ USB_ATTACH(ums)
sc->sc_disconnected = 0;
free(desc, M_TEMP);
-#ifdef USB_DEBUG
+#ifdef UMS_DEBUG
DPRINTF(("ums_attach: sc=%p\n", sc));
DPRINTF(("ums_attach: X\t%d/%d\n",
sc->sc_loc_x.pos, sc->sc_loc_x.size));
@@ -495,7 +495,7 @@ ums_intr(reqh, addr, status)
sc->qhead += sc->mode.packetsize;
sc->qcount += sc->mode.packetsize;
-#ifdef USB_DEBUG
+#ifdef UMS_DEBUG
if (sc->qhead > sizeof(sc->qbuf))
DPRINTF(("Buffer overrun! %d %d\n",
sc->qhead, sizeof(sc->qbuf)));
@@ -566,7 +566,7 @@ ums_disable(v)
sc->sc_enabled = 0;
-#if defined(USBVERBOSE) && defined(__FreeBSD__)
+#if defined(__FreeBSD__)
if (sc->qcount != 0)
DPRINTF(("Discarded %d bytes in queue\n", sc->qcount));
#endif
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index 586bcb4..935f951 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -75,11 +75,10 @@ MALLOC_DEFINE(M_USBDEV, "USBdev", "USB device");
#include <dev/usb/usb_quirks.h>
#ifdef USB_DEBUG
-#define DPRINTF(x) if (usbdebug) printf x
-#define DPRINTFN(n,x) if (usbdebug>(n)) printf x
+#define DPRINTF(x) if (usbdebug) logprintf x
+#define DPRINTFN(n,x) if (usbdebug>(n)) logprintf x
int usbdebug = 1;
-int uhcidebug = 1;
-int ohcidebug = 1;
+extern int uhcidebug, ohcidebug;
#else
#define DPRINTF(x)
#define DPRINTFN(n,x)
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index 11f2e03..f8e9af9 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_subr.c,v 1.27 1999/01/08 11:58:25 augustss Exp $ */
+/* $NetBSD: usb_subr.c,v 1.29 1999/03/18 12:08:43 augustss Exp $ */
/* $FreeBSD$ */
/*
@@ -65,8 +65,8 @@
#endif
#ifdef USB_DEBUG
-#define DPRINTF(x) if (usbdebug) printf x
-#define DPRINTFN(n,x) if (usbdebug>(n)) printf x
+#define DPRINTF(x) if (usbdebug) logprintf x
+#define DPRINTFN(n,x) if (usbdebug>(n)) logprintf x
extern int usbdebug;
#else
#define DPRINTF(x)
@@ -86,50 +86,6 @@ usbd_status usbd_probe_and_attach
__P((bdevice *parent, usbd_device_handle dev, int port, int addr));
-#ifdef USBVERBOSE
-typedef u_int16_t usb_vendor_id_t;
-typedef u_int16_t usb_product_id_t;
-
-/*
- * Descriptions of of known vendors and devices ("products").
- */
-struct usb_knowndev {
- usb_vendor_id_t vendor;
- usb_product_id_t product;
- int flags;
- char *vendorname, *productname;
-};
-#define USB_KNOWNDEV_NOPROD 0x01 /* match on vendor only */
-
-#include <dev/usb/usbdevs_data.h>
-#endif /* USBVERBOSE */
-
-#ifdef USB_DEBUG
-char *usbd_error_strs[] = {
- "NORMAL_COMPLETION",
- "IN_PROGRESS",
- "PENDING_REQUESTS",
- "NOT_STARTED",
- "INVAL",
- "IS_IDLE",
- "NOMEM",
- "CANCELLED",
- "BAD_ADDRESS",
- "IN_USE",
- "INTERFACE_NOT_ACTIVE",
- "NO_ADDR",
- "SET_ADDR_FAILED",
- "NO_POWER",
- "TOO_DEEP",
- "IOERROR",
- "NOT_CONFIGURED",
- "TIMEOUT",
- "SHORT_XFER",
- "STALLED",
- "XXX",
-};
-#endif
-
usbd_status
usbd_get_string_desc(dev, sindex, langid, sdesc)
usbd_device_handle dev;
@@ -205,31 +161,10 @@ usbd_devinfo_vp(dev, v, p)
{
usb_device_descriptor_t *udd = &dev->ddesc;
char *vendor = 0, *product = 0;
-#ifdef USBVERBOSE
- struct usb_knowndev *kdp;
-#endif
vendor = usbd_get_string(dev, udd->iManufacturer, v);
product = usbd_get_string(dev, udd->iProduct, p);
-#ifdef USBVERBOSE
- if (!vendor) {
- for(kdp = usb_knowndevs;
- kdp->vendorname != NULL;
- kdp++) {
- if (kdp->vendor == UGETW(udd->idVendor) &&
- (kdp->product == UGETW(udd->idProduct) ||
- (kdp->flags & USB_KNOWNDEV_NOPROD) != 0))
- break;
- }
- if (kdp->vendorname == NULL)
- vendor = product = NULL;
- else {
- vendor = kdp->vendorname;
- product = (kdp->flags & USB_KNOWNDEV_NOPROD) == 0 ?
- kdp->productname : NULL;
- }
- }
-#endif
+
if (vendor)
strcpy(v, vendor);
else
@@ -312,20 +247,23 @@ usbd_reset_port(dev, port, ps)
USETW(req.wIndex, port);
USETW(req.wLength, 0);
r = usbd_do_request(dev, &req, 0);
- DPRINTFN(1,("usbd_reset_port: port %d reset done, error=%d(%s)\n",
- port, r, usbd_error_strs[r]));
+ DPRINTFN(1,("usbd_reset_port: port %d reset done, %s\n",
+ port, usbd_errstr(r)));
if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ return(r);
+
n = 10;
do {
/* Wait for device to recover from reset. */
usbd_delay_ms(dev, USB_PORT_RESET_DELAY);
r = usbd_get_port_status(dev, port, ps);
if (r != USBD_NORMAL_COMPLETION) {
- DPRINTF(("usbd_reset_port: get status failed %d\n",r));
+ DPRINTF(("usbd_reset_port: get port %d status failed %s\n",
+ port, usbd_errstr(r)));
return (r);
}
} while ((UGETW(ps->wPortChange) & UPS_C_PORT_RESET) == 0 && --n > 0);
+
if (n == 0) {
printf("usbd_reset_port: timeout\n");
return (USBD_IOERROR);
@@ -333,7 +271,8 @@ usbd_reset_port(dev, port, ps)
r = usbd_clear_port_feature(dev, port, UHF_C_PORT_RESET);
#ifdef USB_DEBUG
if (r != USBD_NORMAL_COMPLETION)
- DPRINTF(("usbd_reset_port: clear port feature failed %d\n",r));
+ DPRINTF(("usbd_reset_port: clear port %d feature failed %d\n",
+ port, r));
#endif
/* Wait for the device to recover from reset. */
@@ -585,9 +524,8 @@ usbd_set_config_index(dev, index, msg)
(UGETW(ds.wStatus) & UDS_SELF_POWERED))
selfpowered = 1;
}
- DPRINTF(("usbd_set_config_index: status=0x%04x, "
- "error=%d(%s)\n",
- UGETW(ds.wStatus), r, usbd_error_strs[r]));
+ DPRINTF(("usbd_set_config_index: status=0x%04x, %s\n",
+ UGETW(ds.wStatus), usbd_errstr(r)));
} else
selfpowered = 1;
}
@@ -621,9 +559,8 @@ usbd_set_config_index(dev, index, msg)
cdp->bConfigurationValue));
r = usbd_set_config(dev, cdp->bConfigurationValue);
if (r != USBD_NORMAL_COMPLETION) {
- DPRINTF(("usbd_set_config_index: setting config=%d failed, "
- "error=%d(%s)\n",
- cdp->bConfigurationValue, r, usbd_error_strs[r]));
+ DPRINTF(("usbd_set_config_index: setting config=%d failed, %s\n",
+ cdp->bConfigurationValue, usbd_errstr(r)));
goto bad;
}
DPRINTF(("usbd_set_config_index: setting new config %d\n",
@@ -680,12 +617,13 @@ usbd_setup_pipe(dev, iface, ep, pipe)
p->refcnt = 1;
p->intrreqh = 0;
p->running = 0;
+ p->disco = 0;
+ p->discoarg = 0;
SIMPLEQ_INIT(&p->queue);
r = dev->bus->open_pipe(p);
if (r != USBD_NORMAL_COMPLETION) {
- DPRINTFN(-1,("usbd_setup_pipe: endpoint=0x%x failed, error=%d"
- "(%s)\n",
- ep->edesc->bEndpointAddress, r, usbd_error_strs[r]));
+ DPRINTFN(-1,("usbd_setup_pipe: endpoint=0x%x failed, %s\n",
+ ep->edesc->bEndpointAddress, usbd_errstr(r)));
free(p, M_USB);
return (r);
}
@@ -715,7 +653,6 @@ usbd_getnewaddr(bus)
return (-1);
}
-
usbd_status
usbd_probe_and_attach(parent, dev, port, addr)
bdevice *parent;
@@ -764,17 +701,8 @@ usbd_probe_and_attach(parent, dev, port, addr)
confi));
r = usbd_set_config_index(dev, confi, 1);
if (r != USBD_NORMAL_COMPLETION) {
-#ifdef USB_DEBUG
- DPRINTF(("%s: port %d, set config at addr %d failed, "
- "error=%d(%s)\n", USBDEVNAME(*parent), port,
- addr, r, usbd_error_strs[r]));
-#else
- printf("%s: port %d, set config at addr %d failed\n",
- USBDEVNAME(*parent), port, addr);
-#endif
-#if defined(__FreeBSD__)
- device_delete_child(*parent, bdev);
-#endif
+ printf("%s: port %d, set config at addr %d failed, %s\n",
+ USBDEVNAME(*parent), port, addr, usbd_errstr(r));
return (r);
}
nifaces = dev->cdesc->bNumInterface;
@@ -1136,3 +1064,4 @@ usbd_fill_deviceinfo(dev, di)
} else
di->nports = 0;
}
+
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index 7c99104..d045a4d 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -62,8 +62,8 @@
#endif
#ifdef USB_DEBUG
-#define DPRINTF(x) if (usbdebug) printf x
-#define DPRINTFN(n,x) if (usbdebug>(n)) printf x
+#define DPRINTF(x) if (usbdebug) logprintf x
+#define DPRINTFN(n,x) if (usbdebug>(n)) logprintf x
extern int usbdebug;
#else
#define DPRINTF(x)
@@ -86,6 +86,33 @@ static SIMPLEQ_HEAD(, usbd_request) usbd_free_requests;
extern struct cdevsw usb_cdevsw;
#endif
+#ifdef USB_DEBUG
+char *usbd_error_strs[USBD_ERROR_MAX] = {
+ "NORMAL_COMPLETION",
+ "IN_PROGRESS",
+ "PENDING_REQUESTS",
+ "NOT_STARTED",
+ "INVAL",
+ "IS_IDLE",
+ "NOMEM",
+ "CANCELLED",
+ "BAD_ADDRESS",
+ "IN_USE",
+ "INTERFACE_NOT_ACTIVE",
+ "NO_ADDR",
+ "SET_ADDR_FAILED",
+ "NO_POWER",
+ "TOO_DEEP",
+ "IOERROR",
+ "NOT_CONFIGURED",
+ "TIMEOUT",
+ "SHORT_XFER",
+ "STALLED",
+ "XXX",
+};
+#endif
+
+
usbd_status
usbd_open_pipe(iface, address, flags, pipe)
usbd_interface_handle iface;
@@ -1302,3 +1329,21 @@ usbd_devname(bdevice *bdev)
}
#endif
+
+char *
+usbd_errstr(usbd_status err)
+{
+ static char buffer[5]; /* XXX static buffer */
+
+#ifdef USB_DEBUG
+ if ( err < USBD_ERROR_MAX ) {
+ return usbd_error_strs[err];
+ } else {
+ snprintf(buffer, 4, "%d", err);
+ return buffer;
+ }
+#else
+ snprintf(buffer, 4, "%d", err);
+ return buffer;
+#endif
+}
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index 30d187e..8cdcfdb 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -96,6 +96,7 @@ typedef enum {
USBD_INTERRUPTED,
USBD_XXX,
+#define USBD_ERROR_MAX 21 /* used for usbd_error_strs */
} usbd_status;
typedef int usbd_lock_token;
@@ -243,6 +244,9 @@ usb_endpoint_descriptor_t *usbd_find_edesc
__P((usb_config_descriptor_t *cd, int ifaceidx, int altidx,
int endptidx));
+char * usbd_errstr(usbd_status err);
+
+
void usbd_dopoll __P((usbd_interface_handle));
void usbd_set_polling __P((usbd_interface_handle iface, int on));
diff --git a/sys/dev/usb/usbdi_util.c b/sys/dev/usb/usbdi_util.c
index 70ad4eb..2b3e96e 100644
--- a/sys/dev/usb/usbdi_util.c
+++ b/sys/dev/usb/usbdi_util.c
@@ -54,8 +54,8 @@
#include <dev/usb/usbdi_util.h>
#ifdef USB_DEBUG
-#define DPRINTF(x) if (usbdebug) printf x
-#define DPRINTFN(n,x) if (usbdebug>(n)) printf x
+#define DPRINTF(x) if (usbdebug) logprintf x
+#define DPRINTFN(n,x) if (usbdebug>(n)) logprintf x
extern int usbdebug;
#else
#define DPRINTF(x)
OpenPOWER on IntegriCloud