Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nick-nhusb]: src/sys/dev/usb Convert to USBHIST
details: https://anonhg.NetBSD.org/src/rev/1f6b0a2456aa
branches: nick-nhusb
changeset: 334118:1f6b0a2456aa
user: skrll <skrll%NetBSD.org@localhost>
date: Sun Mar 01 08:10:12 2015 +0000
description:
Convert to USBHIST
diffstat:
sys/dev/usb/usb_subr.c | 189 +++++++++++++++++++++++-------------------------
1 files changed, 92 insertions(+), 97 deletions(-)
diffs (truncated from 522 to 300 lines):
diff -r 5db0adba1974 -r 1f6b0a2456aa sys/dev/usb/usb_subr.c
--- a/sys/dev/usb/usb_subr.c Tue Feb 24 16:57:02 2015 +0000
+++ b/sys/dev/usb/usb_subr.c Sun Mar 01 08:10:12 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_subr.c,v 1.198.2.5 2014/12/05 09:37:50 skrll Exp $ */
+/* $NetBSD: usb_subr.c,v 1.198.2.6 2015/03/01 08:10:12 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.198.2.5 2014/12/05 09:37:50 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.198.2.6 2015/03/01 08:10:12 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)
Static usbd_status usbd_set_config(usbd_device_handle, int);
Static void usbd_devinfo(usbd_device_handle, int, char *, size_t);
@@ -127,6 +122,8 @@
usb_device_request_t req;
usbd_status err;
int actlen;
+
+ USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
req.bmRequestType = UT_READ_DEVICE;
req.bRequest = UR_GET_DESCRIPTOR;
@@ -148,8 +145,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;
@@ -289,14 +285,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;
@@ -305,8 +302,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. */
@@ -318,8 +314,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. */
@@ -335,12 +330,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;
@@ -399,8 +396,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->ud_cdesc, ifaceidx, altidx);
if (idesc == NULL)
return USBD_INVAL;
@@ -409,7 +407,7 @@
ifc->ui_index = ifaceidx;
ifc->ui_altindex = altidx;
nendpt = ifc->ui_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->ui_endpoints = kmem_alloc(nendpt * sizeof(struct usbd_endpoint),
KM_SLEEP);
@@ -422,11 +420,10 @@
end = (char *)dev->ud_cdesc + UGETW(dev->ud_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\n", 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;
@@ -511,10 +508,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->ud_ddesc.bNumConfigurations; index++) {
err = usbd_get_config_desc(dev, index, &cd);
@@ -533,7 +532,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->ud_ddesc.bNumConfigurations &&
index != USB_UNCONFIG_INDEX) {
@@ -544,7 +545,7 @@
/* XXX check that all interfaces are idle */
if (dev->ud_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->ud_cdesc->bNumInterface;
for (ifcidx = 0; ifcidx < nifc; ifcidx++)
@@ -558,11 +559,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;
}
@@ -570,7 +571,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);
@@ -586,12 +587,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;
}
@@ -613,10 +613,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->ud_addr, cdp->bmAttributes,
- selfpowered, cdp->bMaxPower * 2));
+ DPRINTF("addr %d cno=%d attr=0x%02x, selfpowered=%d",
+ dev->ud_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 */
@@ -632,14 +632,15 @@
#endif
#ifdef USB_DEBUG
if (dev->ud_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->ud_powersrc->up_power) {
- DPRINTF(("power exceeded %d %d\n", power, dev->ud_powersrc->up_power));
+ DPRINTF("power exceeded %d %d", power, dev->ud_powersrc->up_power,
+ 0, 0);
/* XXX print nicer message. */
if (msg)
printf("%s: device addr %d (config %d) exceeds power "
@@ -654,13 +655,11 @@
dev->ud_selfpowered = 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;
}
@@ -672,7 +671,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->ud_cdesc = cdp;
dev->ud_config = cdp->bConfigurationValue;
for (ifcidx = 0; ifcidx < nifc; ifcidx++) {
@@ -707,9 +706,10 @@
usbd_pipe_handle p;
usbd_status err;
+ USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
+
p = kmem_alloc(dev->ud_bus->ub_pipesize, KM_SLEEP);
- 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->up_dev = dev;
@@ -726,9 +726,8 @@
SIMPLEQ_INIT(&p->up_queue);
err = dev->ud_bus->ub_methods->ubm_open(p);
if (err) {
Home |
Main Index |
Thread Index |
Old Index