Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Convert to USBHIST. Inspired by patch from Takah...
details: https://anonhg.NetBSD.org/src/rev/a0bebbe02145
branches: trunk
changeset: 336893:a0bebbe02145
user: skrll <skrll%NetBSD.org@localhost>
date: Thu Mar 26 15:53:58 2015 +0000
description:
Convert to USBHIST. Inspired by patch from Takahiro HAYASHI
diffstat:
sys/dev/usb/uhub.c | 115 ++++++++++++++++++++++++++++++++++++----------------
1 files changed, 79 insertions(+), 36 deletions(-)
diffs (267 lines):
diff -r 4cc9bd3ba394 -r a0bebbe02145 sys/dev/usb/uhub.c
--- a/sys/dev/usb/uhub.c Thu Mar 26 14:42:56 2015 +0000
+++ b/sys/dev/usb/uhub.c Thu Mar 26 15:53:58 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uhub.c,v 1.126 2014/08/13 06:26:32 skrll Exp $ */
+/* $NetBSD: uhub.c,v 1.127 2015/03/26 15:53:58 skrll Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
/*
@@ -36,14 +36,16 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.126 2014/08/13 06:26:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.127 2015/03/26 15:53:58 skrll Exp $");
#include <sys/param.h>
+
#include <sys/systm.h>
+#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
-#include <sys/device.h>
#include <sys/proc.h>
+#include <sys/sysctl.h>
#include <sys/bus.h>
@@ -51,15 +53,48 @@
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdivar.h>
+#include <dev/usb/usbhist.h>
-#ifdef UHUB_DEBUG
-#define DPRINTF(x) if (uhubdebug) printf x
-#define DPRINTFN(n,x) if (uhubdebug>(n)) printf x
-int uhubdebug = 0;
+#ifdef USB_DEBUG
+#ifndef UHUB_DEBUG
+#define uhubdebug 0
#else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
-#endif
+static int uhubdebug = 0;
+
+SYSCTL_SETUP(sysctl_hw_uhub_setup, "sysctl hw.uhub setup")
+{
+ int err;
+ const struct sysctlnode *rnode;
+ const struct sysctlnode *cnode;
+
+ err = sysctl_createv(clog, 0, NULL, &rnode,
+ CTLFLAG_PERMANENT, CTLTYPE_NODE, "uhub",
+ SYSCTL_DESCR("uhub global controls"),
+ NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL);
+
+ if (err)
+ goto fail;
+
+ /* control debugging printfs */
+ err = sysctl_createv(clog, 0, &rnode, &cnode,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ "debug", SYSCTL_DESCR("Enable debugging output"),
+ NULL, 0, &uhubdebug, sizeof(uhubdebug), CTL_CREATE, CTL_EOL);
+ if (err)
+ goto fail;
+
+ return;
+fail:
+ aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
+}
+
+#endif /* UHUB_DEBUG */
+#endif /* USB_DEBUG */
+
+#define DPRINTF(FMT,A,B,C,D) USBHIST_LOGN(uhubdebug,1,FMT,A,B,C,D)
+#define DPRINTFN(N,FMT,A,B,C,D) USBHIST_LOGN(uhubdebug,N,FMT,A,B,C,D)
+#define UHUBHIST_FUNC() USBHIST_FUNC()
+#define UHUBHIST_CALLED(name) USBHIST_CALLED(uhubdebug)
struct uhub_softc {
device_t sc_dev; /* base device */
@@ -118,12 +153,14 @@
struct usb_attach_arg *uaa = aux;
int matchvalue;
+ UHUBHIST_FUNC(); UHUBHIST_CALLED();
+
if (uhub_ubermatch)
matchvalue = UMATCH_HIGHEST+1;
else
matchvalue = UMATCH_DEVCLASS_DEVSUBCLASS;
- DPRINTFN(5,("uhub_match, uaa=%p\n", uaa));
+ DPRINTFN(5, "uaa=%p", uaa, 0, 0, 0);
/*
* The subclass for hubs seems to be 0 for some and 1 for others,
* so we just ignore the subclass.
@@ -151,7 +188,8 @@
struct usbd_tt *tts = NULL;
#endif
- DPRINTFN(1,("uhub_attach\n"));
+ UHUBHIST_FUNC(); UHUBHIST_CALLED();
+
sc->sc_dev = self;
sc->sc_hub = dev;
sc->sc_proto = uaa->proto;
@@ -169,8 +207,7 @@
err = usbd_set_config_index(dev, 0, 1);
if (err) {
- DPRINTF(("%s: configuration failed, error=%s\n",
- device_xname(sc->sc_dev), usbd_errstr(err)));
+ DPRINTF("configuration failed, sc %p error %d", sc, err, 0, 0);
return;
}
@@ -187,7 +224,7 @@
USETW2(req.wValue, UDESC_HUB, 0);
USETW(req.wIndex, 0);
USETW(req.wLength, USB_HUB_DESCRIPTOR_SIZE);
- DPRINTFN(1,("%s: getting hub descriptor\n", __func__));
+ DPRINTF("getting hub descriptor", 0, 0, 0, 0);
err = usbd_do_request(dev, &req, &hubdesc);
nports = hubdesc.bNbrPorts;
if (!err && nports > 7) {
@@ -195,8 +232,8 @@
err = usbd_do_request(dev, &req, &hubdesc);
}
if (err) {
- DPRINTF(("%s: getting hub descriptor failed, error=%s\n",
- device_xname(sc->sc_dev), usbd_errstr(err)));
+ DPRINTF("getting hub descriptor failed, sc %p error %d", sc,
+ err, 0, 0);
return;
}
@@ -338,7 +375,7 @@
if (err)
aprint_error_dev(self, "port %d power on failed, %s\n",
port, usbd_errstr(err));
- DPRINTF(("usb_init_port: turn on port %d power\n", port));
+ DPRINTF("turn on port %d power", port, 0, 0, 0);
}
/* Wait for stable power if we are not a root hub */
@@ -376,7 +413,9 @@
int port;
int change, status, reconnect;
- DPRINTFN(10, ("uhub_explore dev=%p addr=%d\n", dev, dev->address));
+ UHUBHIST_FUNC(); UHUBHIST_CALLED();
+
+ DPRINTFN(10, "sc=%p dev=%p addr=%d", sc, dev, dev->address, 0);
if (!sc->sc_running)
return (USBD_NOT_STARTED);
@@ -390,8 +429,8 @@
err = usbd_get_hub_status(dev, &hs);
if (err) {
- DPRINTF(("%s: get hub status failed, err=%d\n",
- device_xname(sc->sc_dev), err));
+ DPRINTF("get hub status failed, sc %p err%d", sc,
+ err, 0, 0);
} else {
/* just acknowledge */
status = UGETW(hs.wHubStatus);
@@ -418,8 +457,8 @@
if (PORTSTAT_ISSET(sc, port) || reconnect) {
err = usbd_get_port_status(dev, port, &up->status);
if (err) {
- DPRINTF(("uhub_explore: get port stat failed, "
- "error=%s\n", usbd_errstr(err)));
+ DPRINTF("get port stat failed, sc %p err %d",
+ sc, err, 0, 0);
continue;
}
status = UGETW(up->status.wPortStatus);
@@ -437,7 +476,7 @@
}
if (change & UPS_C_PORT_ENABLED) {
- DPRINTF(("uhub_explore: C_PORT_ENABLED\n"));
+ DPRINTF("C_PORT_ENABLED", 0, 0, 0, 0);
usbd_clear_port_feature(dev, port, UHF_C_PORT_ENABLE);
if (change & UPS_C_CONNECT_STATUS) {
/* Ignore the port error if the device
@@ -472,8 +511,8 @@
/* We have a connect status change, handle it. */
- DPRINTF(("uhub_explore: status change hub=%d port=%d\n",
- dev->address, port));
+ DPRINTF("status change hub=%d port=%d", dev->address, port, 0,
+ 0);
usbd_clear_port_feature(dev, port, UHF_C_PORT_CONNECTION);
/*
* If there is already a device on the port the change status
@@ -485,16 +524,16 @@
disco:
if (up->device != NULL) {
/* Disconnected */
- DPRINTF(("uhub_explore: device addr=%d disappeared "
- "on port %d\n", up->device->address, port));
+ DPRINTF("device addr=%d disappeared on port %d",
+ up->device->address, port, 0, 0);
usb_disconnect_port(up, sc->sc_dev, DETACH_FORCE);
usbd_clear_port_feature(dev, port,
UHF_C_PORT_CONNECTION);
}
if (!(status & UPS_CURRENT_CONNECT_STATUS)) {
/* Nothing connected, just ignore it. */
- DPRINTFN(3,("uhub_explore: port=%d !CURRENT_CONNECT"
- "_STATUS\n", port));
+ DPRINTFN(3, "port=%d !CURRENT_CONNECT_STATUS", port, 0,
+ 0, 0);
continue;
}
@@ -516,8 +555,8 @@
/* Get port status again, it might have changed during reset */
err = usbd_get_port_status(dev, port, &up->status);
if (err) {
- DPRINTF(("uhub_explore: get port status failed, "
- "error=%s\n", usbd_errstr(err)));
+ DPRINTF("get port status failed, error %d", err, 0, 0,
+ 0);
continue;
}
status = UGETW(up->status.wPortStatus);
@@ -556,8 +595,8 @@
dev->depth + 1, speed, port, up);
/* XXX retry a few times? */
if (err) {
- DPRINTFN(-1,("uhub_explore: usbd_new_device failed, "
- "error=%s\n", usbd_errstr(err)));
+ DPRINTF("usbd_new_device failed, error %d", err, 0, 0,
+ 0);
/* Avoid addressing problems by disabling. */
/* usbd_reset_port(dev, port, &up->status); */
@@ -596,7 +635,9 @@
struct usbd_port *rup;
int nports, port, rc;
- DPRINTF(("uhub_detach: sc=%p flags=%d\n", sc, flags));
+ UHUBHIST_FUNC(); UHUBHIST_CALLED();
+
+ DPRINTF("sc=%p flags=%d", sc, flags, 0, 0);
if (hub == NULL) /* Must be partially working */
return (0);
@@ -703,7 +744,9 @@
{
struct uhub_softc *sc = addr;
- DPRINTFN(5,("uhub_intr: sc=%p\n", sc));
+ UHUBHIST_FUNC(); UHUBHIST_CALLED();
+
+ DPRINTFN(5, "sc=%p", sc, 0, 0, 0);
if (status == USBD_STALLED)
usbd_clear_endpoint_stall_async(sc->sc_ipipe);
Home |
Main Index |
Thread Index |
Old Index