Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb re-write most of the debug messages using c99 va...



details:   https://anonhg.NetBSD.org/src/rev/23ca01433159
branches:  trunk
changeset: 771644:23ca01433159
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Nov 27 04:10:38 2011 +0000

description:
re-write most of the debug messages using c99 varaidic macros and always
include the __func__ and pid:lid.  remove the handful of other __func__
uses and the 100+ other hard coded function name uses.

diffstat:

 sys/dev/usb/uaudio.c |  252 ++++++++++++++++++++++++++------------------------
 1 files changed, 129 insertions(+), 123 deletions(-)

diffs (truncated from 749 to 300 lines):

diff -r eba4e1eaf9e6 -r 23ca01433159 sys/dev/usb/uaudio.c
--- a/sys/dev/usb/uaudio.c      Sun Nov 27 03:52:38 2011 +0000
+++ b/sys/dev/usb/uaudio.c      Sun Nov 27 04:10:38 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uaudio.c,v 1.121 2011/11/23 23:07:36 jmcneill Exp $    */
+/*     $NetBSD: uaudio.c,v 1.122 2011/11/27 04:10:38 mrg Exp $ */
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.121 2011/11/23 23:07:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.122 2011/11/27 04:10:38 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -53,6 +53,7 @@
 #include <sys/poll.h>
 #include <sys/module.h>
 #include <sys/bus.h>
+#include <sys/cpu.h>
 
 #include <sys/audioio.h>
 #include <dev/audio_if.h>
@@ -73,12 +74,27 @@
 /* #define UAUDIO_DEBUG */
 /* #define UAUDIO_MULTIPLE_ENDPOINTS */
 #ifdef UAUDIO_DEBUG
-#define DPRINTF(x)     do { if (uaudiodebug) printf x; } while (0)
-#define DPRINTFN(n,x)  do { if (uaudiodebug>(n)) printf x; } while (0)
-int    uaudiodebug = 0;
+#define DPRINTF(x,y...)                do { \
+               if (uaudiodebug) { \
+                       struct lwp *l = curlwp; \
+                       printf("%s[%d:%d]: "x, __func__, l->l_proc->p_pid, l->l_lid, y); \
+               } \
+       } while (0)
+#define DPRINTFN_CLEAN(n,x...) do { \
+               if (uaudiodebug > (n)) \
+                       printf(x); \
+       } while (0)
+#define DPRINTFN(n,x,y...)     do { \
+               if (uaudiodebug > (n)) { \
+                       struct lwp *l = curlwp; \
+                       printf("%s[%d:%d]: "x, __func__, l->l_proc->p_pid, l->l_lid, y); \
+               } \
+       } while (0)
+int    uaudiodebug = 5;
 #else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
+#define DPRINTF(x,y...)
+#define DPRINTFN_CLEAN(n,x...)
+#define DPRINTFN(n,x,y...)
 #endif
 
 #define UAUDIO_NCHANBUFS 6     /* number of outstanding request */
@@ -480,7 +496,7 @@
        usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
                           sc->sc_dev);
 
-       DPRINTF(("uaudio_attach: doing audio_attach_mi\n"));
+       DPRINTF("%s", "doing audio_attach_mi\n");
 #if defined(__OpenBSD__)
        audio_attach_mi(&uaudio_hw_if, sc, &sc->sc_dev);
 #else
@@ -580,10 +596,9 @@
        struct mixerctl *nmc;
 
        if (mc->class < UAC_NCLASSES) {
-               DPRINTF(("%s: adding %s.%s\n",
-                        __func__, uac_names[mc->class], mc->ctlname));
+               DPRINTF("adding %s.%s\n", uac_names[mc->class], mc->ctlname);
        } else {
-               DPRINTF(("%s: adding %s\n", __func__, mc->ctlname));
+               DPRINTF("adding %s\n", mc->ctlname);
        }
        len = sizeof(*mc) * (sc->sc_nctls + 1);
        nmc = malloc(len, M_USBDEV, M_NOWAIT);
@@ -629,13 +644,14 @@
 #ifdef UAUDIO_DEBUG
        if (uaudiodebug > 2) {
                int i;
-               DPRINTF(("uaudio_mixer_add_ctl: wValue=%04x",mc->wValue[0]));
+
+               DPRINTFN_CLEAN(2, "wValue=%04x", mc->wValue[0]);
                for (i = 1; i < mc->nchan; i++)
-                       DPRINTF((",%04x", mc->wValue[i]));
-               DPRINTF((" wIndex=%04x type=%d name='%s' unit='%s' "
+                       DPRINTFN_CLEAN(2, ",%04x", mc->wValue[i]);
+               DPRINTFN_CLEAN(2, " wIndex=%04x type=%d name='%s' unit='%s' "
                         "min=%d max=%d\n",
                         mc->wIndex, mc->type, mc->ctlname, mc->ctlunit,
-                        mc->minval, mc->maxval));
+                        mc->minval, mc->maxval);
        }
 #endif
 }
@@ -734,12 +750,12 @@
 
        d = iot[id].d.it;
 #ifdef UAUDIO_DEBUG
-       DPRINTFN(2,("uaudio_add_input: bTerminalId=%d wTerminalType=0x%04x "
+       DPRINTFN(2,"bTerminalId=%d wTerminalType=0x%04x "
                    "bAssocTerminal=%d bNrChannels=%d wChannelConfig=%d "
                    "iChannelNames=%d iTerminal=%d\n",
                    d->bTerminalId, UGETW(d->wTerminalType), d->bAssocTerminal,
                    d->bNrChannels, UGETW(d->wChannelConfig),
-                   d->iChannelNames, d->iTerminal));
+                   d->iChannelNames, d->iTerminal);
 #endif
        /* If USB input terminal, record wChannelConfig */
        if ((UGETW(d->wTerminalType) & 0xff00) != 0x0100)
@@ -755,10 +771,10 @@
        const struct usb_audio_output_terminal *d;
 
        d = iot[id].d.ot;
-       DPRINTFN(2,("uaudio_add_output: bTerminalId=%d wTerminalType=0x%04x "
+       DPRINTFN(2,"bTerminalId=%d wTerminalType=0x%04x "
                    "bAssocTerminal=%d bSourceId=%d iTerminal=%d\n",
                    d->bTerminalId, UGETW(d->wTerminalType), d->bAssocTerminal,
-                   d->bSourceId, d->iTerminal));
+                   d->bSourceId, d->iTerminal);
 #endif
 }
 
@@ -772,8 +788,8 @@
        struct mixerctl mix;
 
        d = iot[id].d.mu;
-       DPRINTFN(2,("uaudio_add_mixer: bUnitId=%d bNrInPins=%d\n",
-                   d->bUnitId, d->bNrInPins));
+       DPRINTFN(2,"bUnitId=%d bNrInPins=%d\n",
+                   d->bUnitId, d->bNrInPins);
 
        /* Compute the number of input channels */
        ichs = 0;
@@ -783,7 +799,7 @@
        /* and the number of output channels */
        d1 = (const struct usb_audio_mixer_unit_1 *)&d->baSourceId[d->bNrInPins];
        ochs = d1->bNrChannels;
-       DPRINTFN(2,("uaudio_add_mixer: ichs=%d ochs=%d\n", ichs, ochs));
+       DPRINTFN(2,"ichs=%d ochs=%d\n", ichs, ochs);
 
        bm = d1->bmControls;
        mix.wIndex = MAKE(d->bUnitId, sc->sc_ac_iface);
@@ -835,8 +851,8 @@
        int i, wp;
 
        d = iot[id].d.su;
-       DPRINTFN(2,("uaudio_add_selector: bUnitId=%d bNrInPins=%d\n",
-                   d->bUnitId, d->bNrInPins));
+       DPRINTFN(2,"bUnitId=%d bNrInPins=%d\n",
+                   d->bUnitId, d->bNrInPins);
        mix.wIndex = MAKE(d->bUnitId, sc->sc_ac_iface);
        mix.wValue[0] = MAKE(0, 0);
        uaudio_determine_class(&iot[id], &mix);
@@ -991,8 +1007,7 @@
        terminal_type = uaudio_determine_class(iot, mix);
        if (mix->class == UAC_RECORD && terminal_type == 0)
                return AudioNmixerout;
-       DPRINTF(("%s: terminal_type=%s\n", __func__,
-                uaudio_get_terminal_name(terminal_type)));
+       DPRINTF("terminal_type=%s\n", uaudio_get_terminal_name(terminal_type));
        switch (terminal_type) {
        case UAT_STREAM:
                return AudioNdac;
@@ -1079,7 +1094,7 @@
        case UATF_MULTITRACK:
        case 0xffff:
        default:
-               DPRINTF(("%s: 'master' for 0x%.4x\n", __func__, terminal_type));
+               DPRINTF("'master' for 0x%.4x\n", terminal_type);
                return AudioNmaster;
        }
        return AudioNmaster;
@@ -1106,14 +1121,14 @@
        mmask = GET(0);
        /* Figure out what we can control */
        for (cmask = 0, chan = 1; chan < nchan; chan++) {
-               DPRINTFN(9,("uaudio_add_feature: chan=%d mask=%x\n",
-                           chan, GET(chan)));
+               DPRINTFN(9,"chan=%d mask=%x\n",
+                           chan, GET(chan));
                cmask |= GET(chan);
        }
 
-       DPRINTFN(1,("uaudio_add_feature: bUnitId=%d, "
+       DPRINTFN(1,"bUnitId=%d, "
                    "%d channels, mmask=0x%04x, cmask=0x%04x\n",
-                   d->bUnitId, nchan, mmask, cmask));
+                   d->bUnitId, nchan, mmask, cmask);
 
        if (nchan > MIX_MAX_CHAN)
                nchan = MIX_MAX_CHAN;
@@ -1121,8 +1136,8 @@
        mix.wIndex = MAKE(unit, sc->sc_ac_iface);
        for (ctl = MUTE_CONTROL; ctl < LOUDNESS_CONTROL; ctl++) {
                fumask = FU_MASK(ctl);
-               DPRINTFN(4,("uaudio_add_feature: ctl=%d fumask=0x%04x\n",
-                           ctl, fumask));
+               DPRINTFN(4,"ctl=%d fumask=0x%04x\n",
+                           ctl, fumask);
                if (mmask & fumask) {
                        mix.nchan = 1;
                        mix.wValue[0] = MAKE(ctl, 0);
@@ -1216,11 +1231,11 @@
            &d->baSourceId[d->bNrInPins];
        ud = (const struct usb_audio_processing_unit_updown *)
            &d1->bmControls[d1->bControlSize];
-       DPRINTFN(2,("uaudio_add_processing_updown: bUnitId=%d bNrModes=%d\n",
-                   d->bUnitId, ud->bNrModes));
+       DPRINTFN(2,"bUnitId=%d bNrModes=%d\n",
+                   d->bUnitId, ud->bNrModes);
 
        if (!(d1->bmControls[0] & UA_PROC_MASK(UD_MODE_SELECT_CONTROL))) {
-               DPRINTF(("uaudio_add_processing_updown: no mode select\n"));
+               DPRINTF("%s", "no mode select\n");
                return;
        }
 
@@ -1233,8 +1248,8 @@
        snprintf(mix.ctlname, sizeof(mix.ctlname), "pro%d-mode", d->bUnitId);
 
        for (i = 0; i < ud->bNrModes; i++) {
-               DPRINTFN(2,("uaudio_add_processing_updown: i=%d bm=0x%x\n",
-                           i, UGETW(ud->waModes[i])));
+               DPRINTFN(2,"i=%d bm=0x%x\n",
+                           i, UGETW(ud->waModes[i]));
                /* XXX */
        }
        uaudio_mixer_add_ctl(sc, &mix);
@@ -1252,8 +1267,8 @@
        d1 = (const struct usb_audio_processing_unit_1 *)
            &d->baSourceId[d->bNrInPins];
        ptype = UGETW(d->wProcessType);
-       DPRINTFN(2,("uaudio_add_processing: wProcessType=%d bUnitId=%d "
-                   "bNrInPins=%d\n", ptype, d->bUnitId, d->bNrInPins));
+       DPRINTFN(2,"wProcessType=%d bUnitId=%d "
+                   "bNrInPins=%d\n", ptype, d->bUnitId, d->bNrInPins);
 
        if (d1->bmControls[0] & UA_PROC_ENABLE_MASK) {
                mix.wIndex = MAKE(d->bUnitId, sc->sc_ac_iface);
@@ -1296,8 +1311,8 @@
        d = iot[id].d.eu;
        d1 = (const struct usb_audio_extension_unit_1 *)
            &d->baSourceId[d->bNrInPins];
-       DPRINTFN(2,("uaudio_add_extension: bUnitId=%d bNrInPins=%d\n",
-                   d->bUnitId, d->bNrInPins));
+       DPRINTFN(2,"bUnitId=%d bNrInPins=%d\n",
+                   d->bUnitId, d->bNrInPins);
 
        if (usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_AU_NO_XU)
                return;
@@ -1530,8 +1545,8 @@
                free(sc->sc_alts, M_USBDEV);
        }
        sc->sc_alts = nai;
-       DPRINTFN(2,("uaudio_add_alt: adding alt=%d, enc=%d\n",
-                   ai->alt, ai->encoding));
+       DPRINTFN(2,"adding alt=%d, enc=%d\n",
+                   ai->alt, ai->encoding);
        sc->sc_alts[sc->sc_nalts++] = *ai;
 }
 
@@ -1554,8 +1569,8 @@
        if (asid->bDescriptorType != UDESC_CS_INTERFACE ||
            asid->bDescriptorSubtype != AS_GENERAL)
                return USBD_INVAL;
-       DPRINTF(("uaudio_process_as: asid: bTerminakLink=%d wFormatTag=%d\n",
-                asid->bTerminalLink, UGETW(asid->wFormatTag)));
+       DPRINTF("asid: bTerminakLink=%d wFormatTag=%d\n",
+                asid->bTerminalLink, UGETW(asid->wFormatTag));
        offs += asid->bLength;
        if (offs > size)
                return USBD_INVAL;
@@ -1577,12 +1592,12 @@
        ed = (const void *)(tbuf + offs);
        if (ed->bDescriptorType != UDESC_ENDPOINT)
                return USBD_INVAL;
-       DPRINTF(("uaudio_process_as: endpoint[0] bLength=%d bDescriptorType=%d "
+       DPRINTF("endpoint[0] bLength=%d bDescriptorType=%d "
                 "bEndpointAddress=%d bmAttributes=0x%x wMaxPacketSize=%d "
                 "bInterval=%d bRefresh=%d bSynchAddress=%d\n",
                 ed->bLength, ed->bDescriptorType, ed->bEndpointAddress,
                 ed->bmAttributes, UGETW(ed->wMaxPacketSize),
-                ed->bInterval, ed->bRefresh, ed->bSynchAddress));
+                ed->bInterval, ed->bRefresh, ed->bSynchAddress);
        offs += ed->bLength;
        if (offs > size)
                return USBD_INVAL;
@@ -1618,7 +1633,7 @@
        if (sed->bDescriptorType != UDESC_CS_ENDPOINT ||
            sed->bDescriptorSubtype != AS_GENERAL)
                return USBD_INVAL;
-       DPRINTF((" streadming_endpoint: offset=%d bLength=%d\n", offs, sed->bLength));
+       DPRINTF(" streadming_endpoint: offset=%d bLength=%d\n", offs, sed->bLength);
        offs += sed->bLength;



Home | Main Index | Thread Index | Old Index