Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/audio Improve error messages.
details: https://anonhg.NetBSD.org/src/rev/1d81798772f7
branches: trunk
changeset: 958630:1d81798772f7
user: isaki <isaki%NetBSD.org@localhost>
date: Fri Jan 15 05:34:49 2021 +0000
description:
Improve error messages.
- prefix MD device name if it's considered to be related to the MD driver.
- revise some messages.
diffstat:
sys/dev/audio/audio.c | 165 +++++++++++++++++++++++++++----------------------
1 files changed, 90 insertions(+), 75 deletions(-)
diffs (truncated from 436 to 300 lines):
diff -r 8430755f4aa2 -r 1d81798772f7 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c Fri Jan 15 04:09:28 2021 +0000
+++ b/sys/dev/audio/audio.c Fri Jan 15 05:34:49 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.87 2021/01/15 04:09:28 isaki Exp $ */
+/* $NetBSD: audio.c,v 1.88 2021/01/15 05:34:49 isaki Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.87 2021/01/15 04:09:28 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.88 2021/01/15 05:34:49 isaki Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -515,6 +515,8 @@
static void audio_softintr_rd(void *);
static void audio_softintr_wr(void *);
+static void audio_printf(struct audio_softc *, const char *, ...)
+ __printflike(2, 3);
static int audio_exlock_mutex_enter(struct audio_softc *);
static void audio_exlock_mutex_exit(struct audio_softc *);
static int audio_exlock_enter(struct audio_softc *);
@@ -972,19 +974,20 @@
perror = audio_hw_probe(sc, &phwfmt, AUMODE_PLAY);
rerror = audio_hw_probe(sc, &rhwfmt, AUMODE_RECORD);
if (perror && rerror) {
- aprint_error_dev(self, "audio_hw_probe failed, "
- "perror = %d, rerror = %d\n", perror, rerror);
+ aprint_error_dev(self,
+ "audio_hw_probe failed: perror=%d, rerror=%d\n",
+ perror, rerror);
goto bad;
}
if (perror) {
mode &= ~AUMODE_PLAY;
- aprint_error_dev(self, "audio_hw_probe failed with "
- "%d, playback disabled\n", perror);
+ aprint_error_dev(self, "audio_hw_probe failed: "
+ "errno=%d, playback disabled\n", perror);
}
if (rerror) {
mode &= ~AUMODE_RECORD;
- aprint_error_dev(self, "audio_hw_probe failed with "
- "%d, capture disabled\n", rerror);
+ aprint_error_dev(self, "audio_hw_probe failed: "
+ "errno=%d, capture disabled\n", rerror);
}
} else {
/*
@@ -994,8 +997,8 @@
audio_format2_t *fmt = has_playback ? &phwfmt : &rhwfmt;
error = audio_hw_probe(sc, fmt, mode);
if (error) {
- aprint_error_dev(self, "audio_hw_probe failed, "
- "error = %d\n", error);
+ aprint_error_dev(self,
+ "audio_hw_probe failed: errno=%d\n", error);
goto bad;
}
if (has_playback && has_capture)
@@ -1006,8 +1009,8 @@
/* hw_probe() also validates [pr]hwfmt. */
error = audio_hw_set_format(sc, mode, &phwfmt, &rhwfmt, &pfil, &rfil);
if (error) {
- aprint_error_dev(self, "audio_hw_set_format failed, "
- "error = %d\n", error);
+ aprint_error_dev(self,
+ "audio_hw_set_format failed: errno=%d\n", error);
goto bad;
}
@@ -1017,8 +1020,8 @@
*/
error = audio_mixers_init(sc, mode, &phwfmt, &rhwfmt, &pfil, &rfil);
if (sc->sc_pmixer == NULL && sc->sc_rmixer == NULL) {
- aprint_error_dev(self, "audio_mixers_init failed, "
- "error = %d\n", error);
+ aprint_error_dev(self,
+ "audio_mixers_init failed: errno=%d\n", error);
goto bad;
}
@@ -1436,6 +1439,22 @@
}
/*
+ * audio_printf() outputs fmt... with the audio device name and MD device
+ * name prefixed. If the message is considered to be related to the MD
+ * driver, use this one instead of device_printf().
+ */
+static void
+audio_printf(struct audio_softc *sc, const char *fmt, ...)
+{
+ va_list ap;
+
+ printf("%s(%s): ", device_xname(sc->sc_dev), device_xname(sc->hw_dev));
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
+}
+
+/*
* Enter critical section and also keep sc_lock.
* If successful, returns 0 with sc_lock held. Otherwise returns errno.
* Must be called without sc_lock held.
@@ -1581,7 +1600,7 @@
if (error) {
TRACET(2, track, "cv_timedwait_sig failed %d", error);
if (error == EWOULDBLOCK)
- device_printf(sc->sc_dev, "device timeout\n");
+ audio_printf(sc, "device timeout\n");
} else {
TRACET(3, track, "wakeup");
}
@@ -2424,8 +2443,8 @@
/* XXX what should I do on error? */
if (error == EWOULDBLOCK) {
mutex_exit(sc->sc_lock);
- device_printf(sc->sc_dev,
- "%s: cv_timedwait_sig failed %d\n",
+ audio_printf(sc,
+ "%s: cv_timedwait_sig failed: errno=%d\n",
__func__, error);
return error;
}
@@ -2449,8 +2468,8 @@
if (sc->sc_popens == 0 && sc->sc_pbusy) {
error = audio_pmixer_halt(sc);
if (error) {
- device_printf(sc->sc_dev,
- "halt_output failed with %d (ignored)\n",
+ audio_printf(sc,
+ "halt_output failed: errno=%d (ignored)\n",
error);
}
}
@@ -2475,8 +2494,8 @@
if (sc->sc_ropens == 0 && sc->sc_rbusy) {
error = audio_rmixer_halt(sc);
if (error) {
- device_printf(sc->sc_dev,
- "halt_input failed with %d (ignored)\n",
+ audio_printf(sc,
+ "halt_input failed: errno=%d (ignored)\n",
error);
}
}
@@ -2594,8 +2613,8 @@
if (error) {
audio_track_lock_exit(track);
device_printf(sc->sc_dev,
- "uiomove(len=%d) failed with %d\n",
- len, error);
+ "%s: uiomove(%d) failed: errno=%d\n",
+ __func__, len, error);
goto abort;
}
auring_take(usrbuf, len);
@@ -2723,8 +2742,8 @@
if (error) {
audio_track_lock_exit(track);
device_printf(sc->sc_dev,
- "uiomove(len=%d) failed with %d\n",
- len, error);
+ "%s: uiomove(%d) failed: errno=%d\n",
+ __func__, len, error);
goto abort;
}
auring_push(usrbuf, len);
@@ -3433,7 +3452,7 @@
UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW, UVM_INH_NONE,
UVM_ADV_RANDOM, 0));
if (error) {
- device_printf(sc->sc_dev, "uvm_map failed with %d\n", error);
+ device_printf(sc->sc_dev, "uvm_map failed: errno=%d\n", error);
uao_detach(track->uobj); /* release reference */
goto abort;
}
@@ -3441,7 +3460,7 @@
error = uvm_map_pageable(kernel_map, vstart, vstart + newvsize,
false, 0);
if (error) {
- device_printf(sc->sc_dev, "uvm_map_pageable failed with %d\n",
+ device_printf(sc->sc_dev, "uvm_map_pageable failed: errno=%d\n",
error);
uvm_unmap(kernel_map, vstart, vstart + newvsize);
/* uvm_unmap also detach uobj */
@@ -4895,9 +4914,9 @@
if (rounded != blksize) {
if ((rounded * NBBY) % (mixer->hwbuf.fmt.stride *
mixer->hwbuf.fmt.channels) != 0) {
- device_printf(sc->sc_dev,
- "round_blocksize must return blocksize "
- "divisible by framesize: "
+ audio_printf(sc,
+ "round_blocksize returned blocksize "
+ "indivisible by framesize: "
"blksize=%d rounded=%d "
"stride=%ubit channels=%u\n",
blksize, rounded,
@@ -4926,16 +4945,17 @@
TRACE(1, "round_buffersize %zd -> %zd", bufsize, rounded);
if (rounded < bufsize) {
/* buffersize needs NBLKHW blocks at least. */
- device_printf(sc->sc_dev,
- "buffersize too small: buffersize=%zd blksize=%d\n",
+ audio_printf(sc,
+ "round_buffersize returned too small buffersize: "
+ "buffersize=%zd blksize=%d\n",
rounded, blksize);
return EINVAL;
}
if (rounded % blksize != 0) {
/* buffersize/blksize constraint mismatch? */
- device_printf(sc->sc_dev,
- "buffersize must be multiple of blksize: "
- "buffersize=%zu blksize=%d\n",
+ audio_printf(sc,
+ "round_buffersize returned buffersize indivisible "
+ "by blksize: buffersize=%zu blksize=%d\n",
rounded, blksize);
return EINVAL;
}
@@ -4955,8 +4975,7 @@
/* sc_lock is not necessary for allocm */
mixer->hwbuf.mem = sc->hw_if->allocm(sc->hw_hdl, mode, bufsize);
if (mixer->hwbuf.mem == NULL) {
- device_printf(sc->sc_dev, "%s: allocm(%zu) failed\n",
- __func__, bufsize);
+ audio_printf(sc, "allocm(%zu) failed\n", bufsize);
return ENOMEM;
}
} else {
@@ -5023,8 +5042,7 @@
mixer->codecbuf.mem = audio_realloc(mixer->codecbuf.mem, len);
if (mixer->codecbuf.mem == NULL) {
device_printf(sc->sc_dev,
- "%s: malloc codecbuf(%d) failed\n",
- __func__, len);
+ "malloc codecbuf(%d) failed\n", len);
error = ENOMEM;
goto abort;
}
@@ -5500,8 +5518,9 @@
error = sc->hw_if->trigger_output(sc->hw_hdl,
start, end, blksize, audio_pintr, sc, ¶ms);
if (error) {
- device_printf(sc->sc_dev,
- "trigger_output failed with %d\n", error);
+ audio_printf(sc,
+ "trigger_output failed: errno=%d\n",
+ error);
return;
}
}
@@ -5512,8 +5531,8 @@
error = sc->hw_if->start_output(sc->hw_hdl,
start, blksize, audio_pintr, sc);
if (error) {
- device_printf(sc->sc_dev,
- "start_output failed with %d\n", error);
+ audio_printf(sc,
+ "start_output failed: errno=%d\n", error);
return;
}
}
@@ -5539,8 +5558,7 @@
return;
if (sc->sc_pbusy == false) {
#if defined(DIAGNOSTIC)
- device_printf(sc->sc_dev,
- "DIAGNOSTIC: %s raised stray interrupt\n",
+ audio_printf(sc, "DIAGNOSTIC: %s raised stray interrupt\n",
device_xname(sc->hw_dev));
#endif
return;
@@ -5771,8 +5789,9 @@
error = sc->hw_if->trigger_input(sc->hw_hdl,
start, end, blksize, audio_rintr, sc, ¶ms);
if (error) {
- device_printf(sc->sc_dev,
- "trigger_input failed with %d\n", error);
+ audio_printf(sc,
+ "trigger_input failed: errno=%d\n",
+ error);
return;
}
}
@@ -5783,8 +5802,8 @@
error = sc->hw_if->start_input(sc->hw_hdl,
start, blksize, audio_rintr, sc);
if (error) {
- device_printf(sc->sc_dev,
- "start_input failed with %d\n", error);
+ audio_printf(sc,
Home |
Main Index |
Thread Index |
Old Index