Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Improve SPKRDEBUG code.



details:   https://anonhg.NetBSD.org/src/rev/c5b63959388f
branches:  trunk
changeset: 954249:c5b63959388f
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sat Apr 03 03:21:53 2021 +0000

description:
Improve SPKRDEBUG code.
- Replace wrong aprint_debug_dev() with device_printf().
  By this, it no longer need to print dev_t.
- Improve some messages.

diffstat:

 sys/dev/isa/spkr_pcppi.c |   6 +++---
 sys/dev/spkr.c           |  41 ++++++++++++++++++++++-------------------
 sys/dev/spkr_audio.c     |   6 +++---
 3 files changed, 28 insertions(+), 25 deletions(-)

diffs (162 lines):

diff -r 1537c1f90f46 -r c5b63959388f sys/dev/isa/spkr_pcppi.c
--- a/sys/dev/isa/spkr_pcppi.c  Fri Apr 02 22:41:53 2021 +0000
+++ b/sys/dev/isa/spkr_pcppi.c  Sat Apr 03 03:21:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spkr_pcppi.c,v 1.11 2017/06/14 05:01:35 pgoyette Exp $ */
+/*     $NetBSD: spkr_pcppi.c,v 1.12 2021/04/03 03:21:53 isaki Exp $    */
 
 /*
  * Copyright (c) 1990 Eric S. Raymond (esr%snark.thyrsus.com@localhost)
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr_pcppi.c,v 1.11 2017/06/14 05:01:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr_pcppi.c,v 1.12 2021/04/03 03:21:53 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -86,7 +86,7 @@
 spkr_pcppi_tone(device_t self, u_int xhz, u_int ticks)
 {
 #ifdef SPKRDEBUG
-       aprint_debug_dev(self, "%s: %u %u\n", __func__, xhz, ticks);
+       device_printf(self, "%s: %u %u\n", __func__, xhz, ticks);
 #endif /* SPKRDEBUG */
        struct spkr_pcppi_softc *sc = device_private(self);
        (*sc->sc_bell_func)(sc->sc_pcppicookie, xhz, ticks, PCPPI_BELL_SLEEP);
diff -r 1537c1f90f46 -r c5b63959388f sys/dev/spkr.c
--- a/sys/dev/spkr.c    Fri Apr 02 22:41:53 2021 +0000
+++ b/sys/dev/spkr.c    Sat Apr 03 03:21:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spkr.c,v 1.17 2019/04/18 13:01:38 isaki Exp $  */
+/*     $NetBSD: spkr.c,v 1.18 2021/04/03 03:21:53 isaki Exp $  */
 
 /*
  * Copyright (c) 1990 Eric S. Raymond (esr%snark.thyrsus.com@localhost)
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.17 2019/04/18 13:01:38 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.18 2021/04/03 03:21:53 isaki Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "wsmux.h"
@@ -180,7 +180,7 @@
        silence = fac * snum / (fval * sdenom);
 
 #ifdef SPKRDEBUG
-       aprint_debug_dev(sc->sc_dev,
+       device_printf(sc->sc_dev,
            "%s: pitch %d for %d ticks, rest for %d ticks\n", __func__,
            pitch, sound, silence);
 #endif /* SPKRDEBUG */
@@ -207,7 +207,11 @@
                char c = toupper((unsigned char)*cp);
 
 #ifdef SPKRDEBUG
-               aprint_debug_dev(sc->sc_dev, "%s: %c (%x)\n", __func__, c, c);
+               if (0x20 <= c && c < 0x7f) {
+                       device_printf(sc->sc_dev, "%s: '%c'\n", __func__, c);
+               } else {
+                       device_printf(sc->sc_dev, "%s: (0x%x)\n", __func__, c);
+               }
 #endif /* SPKRDEBUG */
 
                switch (c) {
@@ -431,11 +435,11 @@
 int
 spkropen(dev_t dev, int        flags, int mode, struct lwp *l)
 {
-#ifdef SPKRDEBUG
-       aprint_debug("%s: entering with dev = %"PRIx64"\n", __func__, dev);
-#endif /* SPKRDEBUG */
        struct spkr_softc *sc = spkrenter(minor(dev));
 
+#ifdef SPKRDEBUG
+       device_printf(sc->sc_dev, "%s: entering\n", __func__);
+#endif /* SPKRDEBUG */
        if (sc == NULL)
                return ENXIO;
        if (sc->sc_inbuf != NULL)
@@ -449,12 +453,12 @@
 int
 spkrwrite(dev_t dev, struct uio *uio, int flags)
 {
-#ifdef SPKRDEBUG
-       aprint_debug("%s: entering with dev = %"PRIx64", count = %zu\n",
-           __func__, dev, uio->uio_resid);
-#endif /* SPKRDEBUG */
        struct spkr_softc *sc = spkrenter(minor(dev));
 
+#ifdef SPKRDEBUG
+       device_printf(sc->sc_dev, "%s: entering with length = %zu\n",
+           __func__, uio->uio_resid);
+#endif /* SPKRDEBUG */
        if (sc == NULL)
                return ENXIO;
        if (sc->sc_inbuf == NULL)
@@ -471,11 +475,11 @@
 int
 spkrclose(dev_t dev, int flags, int mode, struct lwp *l)
 {
-#ifdef SPKRDEBUG
-       aprint_debug("%s: entering with dev = %"PRIx64"\n", __func__, dev);
-#endif /* SPKRDEBUG */
        struct spkr_softc *sc = spkrenter(minor(dev));
 
+#ifdef SPKRDEBUG
+       device_printf(sc->sc_dev, "%s: entering\n", __func__);
+#endif /* SPKRDEBUG */
        if (sc == NULL)
                return ENXIO;
        if (sc->sc_inbuf == NULL)
@@ -500,16 +504,15 @@
 int
 spkrioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
 {
+       struct spkr_softc *sc = spkrenter(minor(dev));
        tone_t *tp;
        tone_t ttp;
        int error;
+
 #ifdef SPKRDEBUG
-       aprint_debug("%s: entering with dev = %"PRIx64", cmd = %lx\n",
-           __func__, dev, cmd);
+       device_printf(sc->sc_dev, "%s: entering with cmd = %lx\n",
+           __func__, cmd);
 #endif /* SPKRDEBUG */
-
-       struct spkr_softc *sc = spkrenter(minor(dev));
-
        if (sc == NULL)
                return ENXIO;
        if (sc->sc_inbuf == NULL)
diff -r 1537c1f90f46 -r c5b63959388f sys/dev/spkr_audio.c
--- a/sys/dev/spkr_audio.c      Fri Apr 02 22:41:53 2021 +0000
+++ b/sys/dev/spkr_audio.c      Sat Apr 03 03:21:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spkr_audio.c,v 1.9 2021/02/17 12:37:33 isaki Exp $     */
+/*     $NetBSD: spkr_audio.c,v 1.10 2021/04/03 03:21:53 isaki Exp $    */
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.9 2021/02/17 12:37:33 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.10 2021/04/03 03:21:53 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -69,7 +69,7 @@
        struct spkr_audio_softc *sc = device_private(self);
 
 #ifdef SPKRDEBUG
-       aprint_debug_dev(self, "%s: %u %d\n", __func__, xhz, ticks);
+       device_printf(self, "%s: %u %u\n", __func__, xhz, ticks);
 #endif /* SPKRDEBUG */
        audiobell(sc->sc_audiodev, xhz, hztoms(ticks),
            sc->sc_spkr.sc_vol, 0);



Home | Main Index | Thread Index | Old Index