Module Name: src Committed By: isaki Date: Sat Apr 3 03:21:53 UTC 2021
Modified Files: src/sys/dev: spkr.c spkr_audio.c src/sys/dev/isa: spkr_pcppi.c Log Message: Improve SPKRDEBUG code. - Replace wrong aprint_debug_dev() with device_printf(). By this, it no longer need to print dev_t. - Improve some messages. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/spkr.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/spkr_audio.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/isa/spkr_pcppi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/spkr.c diff -u src/sys/dev/spkr.c:1.17 src/sys/dev/spkr.c:1.18 --- src/sys/dev/spkr.c:1.17 Thu Apr 18 13:01:38 2019 +++ src/sys/dev/spkr.c Sat Apr 3 03:21:53 2021 @@ -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 (e...@snark.thyrsus.com) @@ -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 @@ playtone(struct spkr_softc *sc, int pitc 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 @@ playstring(struct spkr_softc *sc, const 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 @@ spkr_childdet(device_t self, device_t ch 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 @@ spkropen(dev_t dev, int flags, int mode, 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 @@ spkrwrite(dev_t dev, struct uio *uio, in 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 @@ playonetone(struct spkr_softc *sc, tone_ 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) Index: src/sys/dev/spkr_audio.c diff -u src/sys/dev/spkr_audio.c:1.9 src/sys/dev/spkr_audio.c:1.10 --- src/sys/dev/spkr_audio.c:1.9 Wed Feb 17 12:37:33 2021 +++ src/sys/dev/spkr_audio.c Sat Apr 3 03:21:53 2021 @@ -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 <nathanialsl...@yahoo.com.au> @@ -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 @@ spkr_audio_tone(device_t self, u_int xhz 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); Index: src/sys/dev/isa/spkr_pcppi.c diff -u src/sys/dev/isa/spkr_pcppi.c:1.11 src/sys/dev/isa/spkr_pcppi.c:1.12 --- src/sys/dev/isa/spkr_pcppi.c:1.11 Wed Jun 14 05:01:35 2017 +++ src/sys/dev/isa/spkr_pcppi.c Sat Apr 3 03:21:53 2021 @@ -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 (e...@snark.thyrsus.com) @@ -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 @@ static void 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);