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/d0fa079dc92a
branches:  nick-nhusb
changeset: 334237:d0fa079dc92a
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Jul 23 07:36:33 2015 +0000

description:
Convert to usbhist

diffstat:

 sys/dev/usb/ucom.c |  124 +++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 92 insertions(+), 32 deletions(-)

diffs (truncated from 316 to 300 lines):

diff -r 7896e70de73a -r d0fa079dc92a sys/dev/usb/ucom.c
--- a/sys/dev/usb/ucom.c        Sat Jun 27 07:27:29 2015 +0000
+++ b/sys/dev/usb/ucom.c        Thu Jul 23 07:36:33 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ucom.c,v 1.108.2.6 2015/06/06 14:40:14 skrll Exp $     */
+/*     $NetBSD: ucom.c,v 1.108.2.7 2015/07/23 07:36:33 skrll Exp $     */
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.6 2015/06/06 14:40:14 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.7 2015/07/23 07:36:33 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -50,6 +50,7 @@
 #include <sys/poll.h>
 #include <sys/queue.h>
 #include <sys/kauth.h>
+#include <sys/sysctl.h>
 #include <sys/timepps.h>
 #include <sys/rndsource.h>
 
@@ -59,6 +60,7 @@
 #include <dev/usb/usbdi_util.h>
 #include <dev/usb/usbdevs.h>
 #include <dev/usb/usb_quirks.h>
+#include <dev/usb/usbhist.h>
 
 #include <dev/usb/ucomvar.h>
 
@@ -68,13 +70,46 @@
 
 #if NUCOM > 0
 
-#ifdef UCOM_DEBUG
-#define DPRINTFN(n, x) if (ucomdebug > (n)) printf x
-int ucomdebug = 0;
+#ifdef USB_DEBUG
+#ifndef UCOM_DEBUG
+#define ucomdebug 0
 #else
-#define DPRINTFN(n, x)
-#endif
-#define DPRINTF(x) DPRINTFN(0, x)
+int ucomdebug = 0;
+
+SYSCTL_SETUP(sysctl_hw_ucom_setup, "sysctl hw.ucom setup")
+{
+        int err;
+        const struct sysctlnode *rnode;
+        const struct sysctlnode *cnode;
+
+        err = sysctl_createv(clog, 0, NULL, &rnode,
+            CTLFLAG_PERMANENT, CTLTYPE_NODE, "ucom",
+            SYSCTL_DESCR("ucom 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, &ucomdebug, sizeof(ucomdebug), CTL_CREATE, CTL_EOL);
+        if (err)
+                goto fail;
+
+        return;
+fail:
+        aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
+}
+
+#endif /* UCOM_DEBUG */
+#endif /* USB_DEBUG */
+
+#define DPRINTF(FMT,A,B,C,D)    USBHIST_LOGN(ucomdebug,1,FMT,A,B,C,D)
+#define DPRINTFN(N,FMT,A,B,C,D) USBHIST_LOGN(ucomdebug,N,FMT,A,B,C,D)
+#define UCOMHIST_FUNC()         USBHIST_FUNC()
+#define UCOMHIST_CALLED(name)   USBHIST_CALLED(ucomdebug)
 
 #define        UCOMCALLUNIT_MASK       TTCALLUNIT_MASK
 #define        UCOMUNIT_MASK           TTUNIT_MASK
@@ -215,6 +250,8 @@
        struct ucom_attach_args *uca = aux;
        struct tty *tp;
 
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
        if (uca->info != NULL)
                aprint_normal(": %s", uca->info);
        aprint_normal("\n");
@@ -249,7 +286,7 @@
        tp->t_hwiflow = ucomhwiflow;
        sc->sc_tty = tp;
 
-       DPRINTF(("ucom_attach: tty_attach %p\n", tp));
+       DPRINTF("tty_attach %p", tp, 0, 0, 0);
        tty_attach(tp);
 
        rnd_attach_source(&sc->sc_rndsource, device_xname(sc->sc_dev),
@@ -268,8 +305,10 @@
        int maj, mn;
        int s, i;
 
-       DPRINTF(("ucom_detach: sc=%p flags=%d tp=%p, pipe=%d,%d\n",
-                sc, flags, tp, sc->sc_bulkin_no, sc->sc_bulkout_no));
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
+       DPRINTF("sc=%p flags=%d tp=%p", sc, flags, tp, 0);
+       DPRINTF("... pipe=%d,%d",sc->sc_bulkin_no, sc->sc_bulkout_no, 0, 0);
 
        sc->sc_dying = 1;
        pmf_device_deregister(self);
@@ -301,7 +340,7 @@
 
        /* Nuke the vnodes for any open instances. */
        mn = device_unit(self);
-       DPRINTF(("ucom_detach: maj=%d mn=%d\n", maj, mn));
+       DPRINTF("maj=%d mn=%d\n", maj, mn, 0, 0);
        vdevgone(maj, mn, mn, VCHR);
        vdevgone(maj, mn | UCOMDIALOUT_MASK, mn | UCOMDIALOUT_MASK, VCHR);
        vdevgone(maj, mn | UCOMCALLUNIT_MASK, mn | UCOMCALLUNIT_MASK, VCHR);
@@ -334,7 +373,9 @@
 {
        struct ucom_softc *sc = device_private(self);
 
-       DPRINTFN(5,("ucom_activate: %d\n", act));
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
+       DPRINTFN(5, "%d", act, 0, 0, 0);
 
        switch (act) {
        case DVACT_DEACTIVATE:
@@ -350,7 +391,8 @@
 {
        struct tty *tp = sc->sc_tty;
 
-       DPRINTF(("ucom_shutdown\n"));
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
        /*
         * Hang up if necessary.  Wait a bit, so the other side has time to
         * notice even if we immediately open the port again.
@@ -372,6 +414,8 @@
        int s, i;
        int error;
 
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
        if (sc == NULL)
                return ENXIO;
 
@@ -383,7 +427,7 @@
 
        tp = sc->sc_tty;
 
-       DPRINTF(("ucomopen: unit=%d, tp=%p\n", unit, tp));
+       DPRINTF("unit=%d, tp=%p\n", unit, tp, 0, 0);
 
        if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp))
                return EBUSY;
@@ -460,25 +504,23 @@
                ucom_dtr(sc, 1);
                ucom_rts(sc, 1);
 
-               DPRINTF(("ucomopen: open pipes in=%d out=%d\n",
-                        sc->sc_bulkin_no, sc->sc_bulkout_no));
+               DPRINTF("open pipes in=%d out=%d", sc->sc_bulkin_no,
+                   sc->sc_bulkout_no, 0, 0);
 
                /* Open the bulk pipes */
                err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkin_no,
                                     USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe);
                if (err) {
-                       DPRINTF(("%s: open bulk in error (addr %d), err=%s\n",
-                                device_xname(sc->sc_dev), sc->sc_bulkin_no,
-                                usbd_errstr(err)));
+                       DPRINTF("open bulk in error (addr %d), err=%d",
+                           sc->sc_bulkin_no, err, 0, 0);
                        error = EIO;
                        goto fail_0;
                }
                err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout_no,
                                     USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe);
                if (err) {
-                       DPRINTF(("%s: open bulk out error (addr %d), err=%s\n",
-                                device_xname(sc->sc_dev), sc->sc_bulkout_no,
-                                usbd_errstr(err)));
+                       DPRINTF("open bulk out error (addr %d), err=%d",
+                           sc->sc_bulkout_no, err, 0, 0);
                        error = EIO;
                        goto fail_1;
                }
@@ -599,7 +641,9 @@
        struct tty *tp;
        int s;
 
-       DPRINTF(("ucomclose: unit=%d\n", UCOMUNIT(dev)));
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
+       DPRINTF("unit=%d", UCOMUNIT(dev), 0, 0, 0);
 
        if (sc == NULL)
                return 0;
@@ -641,6 +685,8 @@
        struct tty *tp;
        int error;
 
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
        if (sc == NULL || sc->sc_dying)
                return EIO;
 
@@ -724,7 +770,9 @@
        int error;
        int s;
 
-       DPRINTF(("ucomioctl: cmd=0x%08lx\n", cmd));
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
+       DPRINTF("cmd=0x%08lx", cmd, 0, 0, 0);
 
        error = (*tp->t_linesw->l_ioctl)(tp, cmd, data, flag, l);
        if (error != EPASSTHROUGH)
@@ -743,7 +791,7 @@
 
        error = 0;
 
-       DPRINTF(("ucomioctl: our cmd=0x%08lx\n", cmd));
+       DPRINTF("our cmd=0x%08lx", cmd, 0, 0, 0);
        s = spltty();
 
        switch (cmd) {
@@ -875,7 +923,9 @@
 static void
 ucom_break(struct ucom_softc *sc, int onoff)
 {
-       DPRINTF(("ucom_break: onoff=%d\n", onoff));
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
+       DPRINTF("onoff=%d", onoff, 0, 0, 0);
 
        if (sc->sc_methods->ucom_set != NULL)
                sc->sc_methods->ucom_set(sc->sc_parent, sc->sc_portno,
@@ -885,7 +935,9 @@
 static void
 ucom_dtr(struct ucom_softc *sc, int onoff)
 {
-       DPRINTF(("ucom_dtr: onoff=%d\n", onoff));
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
+       DPRINTF("onoff=%d", onoff, 0, 0, 0);
 
        if (sc->sc_methods->ucom_set != NULL)
                sc->sc_methods->ucom_set(sc->sc_parent, sc->sc_portno,
@@ -895,7 +947,9 @@
 static void
 ucom_rts(struct ucom_softc *sc, int onoff)
 {
-       DPRINTF(("ucom_rts: onoff=%d\n", onoff));
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
+       DPRINTF("onoff=%d", onoff, 0, 0, 0);
 
        if (sc->sc_methods->ucom_set != NULL)
                sc->sc_methods->ucom_set(sc->sc_parent, sc->sc_portno,
@@ -938,6 +992,8 @@
            UCOMUNIT(tp->t_dev));
        int error;
 
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
        if (sc == NULL || sc->sc_dying)
                return EIO;
 
@@ -984,7 +1040,7 @@
         * CLOCAL or MDMBUF.  We don't hang up here; we only do that by
         * explicit request.
         */
-       DPRINTF(("ucomparam: l_modem\n"));
+       DPRINTF("l_modem", 0, 0, 0, 0);
        (void) (*tp->t_linesw->l_modem)(tp, ISSET(sc->sc_msr, UMSR_DCD));
 
 #if 0
@@ -1261,12 +1317,14 @@
        u_char *cp;
        int s;
 
+       UCOMHIST_FUNC(); UCOMHIST_CALLED();
+
        ub = SIMPLEQ_FIRST(&sc->sc_ibuff_empty);
        SIMPLEQ_REMOVE_HEAD(&sc->sc_ibuff_empty, ub_link);
 
        if (status == USBD_CANCELLED || status == USBD_IOERROR ||
            sc->sc_dying) {



Home | Main Index | Thread Index | Old Index