Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Pull across the conversion to usbhist from nick-...
details: https://anonhg.NetBSD.org/src/rev/471788b036c1
branches: trunk
changeset: 342159:471788b036c1
user: skrll <skrll%NetBSD.org@localhost>
date: Thu Dec 10 09:04:08 2015 +0000
description:
Pull across the conversion to usbhist from nick-nhusb.
diffstat:
sys/dev/usb/usb_subr.c | 200 +++++++++++++++++++++++-------------------------
1 files changed, 96 insertions(+), 104 deletions(-)
diffs (truncated from 560 to 300 lines):
diff -r a1f84ee88132 -r 471788b036c1 sys/dev/usb/usb_subr.c
--- a/sys/dev/usb/usb_subr.c Thu Dec 10 08:11:03 2015 +0000
+++ b/sys/dev/usb/usb_subr.c Thu Dec 10 09:04:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_subr.c,v 1.204 2015/11/08 23:25:17 joerg Exp $ */
+/* $NetBSD: usb_subr.c,v 1.205 2015/12/10 09:04:08 skrll Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.204 2015/11/08 23:25:17 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.205 2015/12/10 09:04:08 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -59,17 +59,12 @@
#include <dev/usb/usbdevs.h>
#include <dev/usb/usb_quirks.h>
#include <dev/usb/usb_verbose.h>
+#include <dev/usb/usbhist.h>
#include "locators.h"
-#ifdef USB_DEBUG
-#define DPRINTF(x) if (usbdebug) printf x
-#define DPRINTFN(n,x) if (usbdebug>(n)) printf x
-extern int usbdebug;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
-#endif
+#define DPRINTF(FMT,A,B,C,D) USBHIST_LOG(usbdebug,FMT,A,B,C,D)
+#define DPRINTFN(N,FMT,A,B,C,D) USBHIST_LOGN(usbdebug,N,FMT,A,B,C,D)
MALLOC_DEFINE(M_USB, "USB", "USB misc. memory");
MALLOC_DEFINE(M_USBDEV, "USB device", "USB device driver");
@@ -132,6 +127,8 @@
usbd_status err;
int actlen;
+ USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
+
req.bmRequestType = UT_READ_DEVICE;
req.bRequest = UR_GET_DESCRIPTOR;
USETW2(req.wValue, UDESC_STRING, sindex);
@@ -152,8 +149,7 @@
return (err);
if (actlen != sdesc->bLength) {
- DPRINTFN(-1, ("usbd_get_string_desc: expected %d, got %d\n",
- sdesc->bLength, actlen));
+ DPRINTF("expected %d, got %d", sdesc->bLength, actlen, 0, 0);
}
*sizep = actlen;
@@ -293,14 +289,15 @@
usbd_status err;
int n;
+ USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
+
req.bmRequestType = UT_WRITE_CLASS_OTHER;
req.bRequest = UR_SET_FEATURE;
USETW(req.wValue, UHF_PORT_RESET);
USETW(req.wIndex, port);
USETW(req.wLength, 0);
err = usbd_do_request(dev, &req, 0);
- DPRINTFN(1,("usbd_reset_port: port %d reset done, error=%s\n",
- port, usbd_errstr(err)));
+ DPRINTFN(1, "port %d reset done, error=%d", port, err, 0, 0);
if (err)
return (err);
n = 10;
@@ -309,8 +306,7 @@
usbd_delay_ms(dev, USB_PORT_RESET_DELAY);
err = usbd_get_port_status(dev, port, ps);
if (err) {
- DPRINTF(("usbd_reset_port: get status failed %d\n",
- err));
+ DPRINTF("get status failed %d", err, 0, 0, 0);
return (err);
}
/* If the device disappeared, just give up. */
@@ -322,8 +318,7 @@
err = usbd_clear_port_feature(dev, port, UHF_C_PORT_RESET);
#ifdef USB_DEBUG
if (err)
- DPRINTF(("usbd_reset_port: clear port feature failed %d\n",
- err));
+ DPRINTF("clear port feature failed %d", err, 0, 0, 0);
#endif
/* Wait for the device to recover from reset. */
@@ -339,12 +334,14 @@
usb_interface_descriptor_t *d;
int curidx, lastidx, curaidx = 0;
+ USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
+
for (curidx = lastidx = -1; p < end; ) {
d = (usb_interface_descriptor_t *)p;
- DPRINTFN(4,("usbd_find_idesc: idx=%d(%d) altidx=%d(%d) len=%d "
- "type=%d\n",
- ifaceidx, curidx, altidx, curaidx,
- d->bLength, d->bDescriptorType));
+ DPRINTFN(4, "idx=%d(%d) altidx=%d(%d)", ifaceidx, curidx,
+ altidx, curaidx);
+ DPRINTFN(4, "len=%d type=%d", d->bLength, d->bDescriptorType,
+ 0, 0);
if (d->bLength == 0) /* bad descriptor */
break;
p += d->bLength;
@@ -403,8 +400,9 @@
char *p, *end;
int endpt, nendpt;
- DPRINTFN(4,("usbd_fill_iface_data: ifaceidx=%d altidx=%d\n",
- ifaceidx, altidx));
+ USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
+
+ DPRINTFN(4, "ifaceidx=%d altidx=%d", ifaceidx, altidx, 0, 0);
idesc = usbd_find_idesc(dev->cdesc, ifaceidx, altidx);
if (idesc == NULL)
return (USBD_INVAL);
@@ -413,7 +411,7 @@
ifc->index = ifaceidx;
ifc->altindex = altidx;
nendpt = ifc->idesc->bNumEndpoints;
- DPRINTFN(4,("usbd_fill_iface_data: found idesc nendpt=%d\n", nendpt));
+ DPRINTFN(4, "found idesc nendpt=%d", nendpt, 0, 0, 0);
if (nendpt != 0) {
ifc->endpoints = malloc(nendpt * sizeof(struct usbd_endpoint),
M_USB, M_NOWAIT);
@@ -426,11 +424,10 @@
end = (char *)dev->cdesc + UGETW(dev->cdesc->wTotalLength);
#define ed ((usb_endpoint_descriptor_t *)p)
for (endpt = 0; endpt < nendpt; endpt++) {
- DPRINTFN(10,("usbd_fill_iface_data: endpt=%d\n", endpt));
+ DPRINTFN(10, "endpt=%d", endpt, 0, 0, 0);
for (; p < end; p += ed->bLength) {
- DPRINTFN(10,("usbd_fill_iface_data: p=%p end=%p "
- "len=%d type=%d\n",
- p, end, ed->bLength, ed->bDescriptorType));
+ DPRINTFN(10, "p=%p end=%p len=%d type=%d",
+ p, end, ed->bLength, ed->bDescriptorType);
if (p + ed->bLength <= end && ed->bLength != 0 &&
ed->bDescriptorType == UDESC_ENDPOINT)
goto found;
@@ -512,10 +509,12 @@
usb_config_descriptor_t cd;
usbd_status err;
+ USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
+
if (no == USB_UNCONFIG_NO)
return (usbd_set_config_index(dev, USB_UNCONFIG_INDEX, msg));
- DPRINTFN(5,("usbd_set_config_no: %d\n", no));
+ DPRINTFN(5, "%d", no, 0, 0, 0);
/* Figure out what config index to use. */
for (index = 0; index < dev->ddesc.bNumConfigurations; index++) {
err = usbd_get_config_desc(dev, index, &cd);
@@ -534,7 +533,9 @@
usbd_status err;
int i, ifcidx, nifc, len, selfpowered, power;
- DPRINTFN(5,("usbd_set_config_index: dev=%p index=%d\n", dev, index));
+ USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
+
+ DPRINTFN(5, "dev=%p index=%d", dev, index, 0, 0);
if (index >= dev->ddesc.bNumConfigurations &&
index != USB_UNCONFIG_INDEX) {
@@ -545,7 +546,7 @@
/* XXX check that all interfaces are idle */
if (dev->config != USB_UNCONFIG_NO) {
- DPRINTF(("usbd_set_config_index: free old config\n"));
+ DPRINTF("free old config", 0, 0, 0, 0);
/* Free all configuration data structures. */
nifc = dev->cdesc->bNumInterface;
for (ifcidx = 0; ifcidx < nifc; ifcidx++)
@@ -559,11 +560,11 @@
if (index == USB_UNCONFIG_INDEX) {
/* We are unconfiguring the device, so leave unallocated. */
- DPRINTF(("usbd_set_config_index: set config 0\n"));
+ DPRINTF("set config 0", 0, 0, 0, 0);
err = usbd_set_config(dev, USB_UNCONFIG_NO);
if (err) {
- DPRINTF(("usbd_set_config_index: setting config=0 "
- "failed, error=%s\n", usbd_errstr(err)));
+ DPRINTF("setting config=0 failed, err = %d", err,
+ 0, 0, 0);
}
return (err);
}
@@ -571,7 +572,7 @@
/* Get the short descriptor. */
err = usbd_get_config_desc(dev, index, &cd);
if (err) {
- DPRINTF(("usbd_set_config_index: get_config_desc=%d\n", err));
+ DPRINTF("get_config_desc=%d", err, 0, 0, 0);
return (err);
}
len = UGETW(cd.wTotalLength);
@@ -587,12 +588,11 @@
usbd_delay_ms(dev, 200);
}
if (err) {
- DPRINTF(("usbd_set_config_index: get_desc=%d\n", err));
+ DPRINTF("get_desc=%d", err, 0, 0, 0);
goto bad;
}
if (cdp->bDescriptorType != UDESC_CONFIG) {
- DPRINTFN(-1,("usbd_set_config_index: bad desc %d\n",
- cdp->bDescriptorType));
+ DPRINTF("bad desc %d", cdp->bDescriptorType, 0, 0, 0);
err = USBD_INVAL;
goto bad;
}
@@ -614,10 +614,10 @@
*/
selfpowered = !!(cdp->bmAttributes & UC_SELF_POWERED);
- DPRINTF(("usbd_set_config_index: (addr %d) cno=%d attr=0x%02x, "
- "selfpowered=%d, power=%d\n",
- cdp->bConfigurationValue, dev->address, cdp->bmAttributes,
- selfpowered, cdp->bMaxPower * 2));
+ DPRINTF("addr %d cno=%d attr=0x%02x, selfpowered=%d",
+ dev->addr, cdp->bConfigurationValue, cdp->bmAttributes,
+ selfpowered);
+ DPRINTF("max power=%d", cdp->bMaxPower * 2, 0, 0, 0);
/* Check if we have enough power. */
#if 0 /* this is a no-op, see above */
@@ -633,14 +633,15 @@
#endif
#ifdef USB_DEBUG
if (dev->powersrc == NULL) {
- DPRINTF(("usbd_set_config_index: No power source?\n"));
+ DPRINTF("No power source?", 0, 0, 0, 0);
err = USBD_IOERROR;
goto bad;
}
#endif
power = cdp->bMaxPower * 2;
if (power > dev->powersrc->power) {
- DPRINTF(("power exceeded %d %d\n", power,dev->powersrc->power));
+ DPRINTF("power exceeded %d %d", power, dev->powersrc->up_power,
+ 0, 0);
/* XXX print nicer message. */
if (msg)
printf("%s: device addr %d (config %d) exceeds power "
@@ -655,13 +656,11 @@
dev->self_powered = selfpowered;
/* Set the actual configuration value. */
- DPRINTF(("usbd_set_config_index: set config %d\n",
- cdp->bConfigurationValue));
+ DPRINTF("set config %d", cdp->bConfigurationValue, 0, 0, 0);
err = usbd_set_config(dev, cdp->bConfigurationValue);
if (err) {
- DPRINTF(("usbd_set_config_index: setting config=%d failed, "
- "error=%s\n",
- cdp->bConfigurationValue, usbd_errstr(err)));
+ DPRINTF("setting config=%d failed, error=%d",
+ cdp->bConfigurationValue, err, 0, 0);
goto bad;
}
@@ -673,7 +672,7 @@
err = USBD_NOMEM;
goto bad;
}
- DPRINTFN(5,("usbd_set_config_index: dev=%p cdesc=%p\n", dev, cdp));
+ DPRINTFN(5, "dev=%p cdesc=%p", dev, cdp, 0, 0);
dev->cdesc = cdp;
dev->config = cdp->bConfigurationValue;
for (ifcidx = 0; ifcidx < nifc; ifcidx++) {
@@ -709,8 +708,7 @@
usbd_status err;
p = malloc(dev->bus->pipe_size, M_USB, M_NOWAIT);
- DPRINTFN(1,("usbd_setup_pipe: dev=%p iface=%p ep=%p pipe=%p\n",
- dev, iface, ep, p));
+ DPRINTFN(1, "dev=%p iface=%p ep=%p pipe=%p", dev, iface, ep, p);
if (p == NULL)
return (USBD_NOMEM);
p->device = dev;
@@ -727,9 +725,8 @@
SIMPLEQ_INIT(&p->queue);
err = dev->bus->methods->open_pipe(p);
if (err) {
- DPRINTFN(-1,("usbd_setup_pipe: endpoint=0x%x failed, error="
- "%s\n",
- ep->edesc->bEndpointAddress, usbd_errstr(err)));
Home |
Main Index |
Thread Index |
Old Index