Module Name:    src
Committed By:   nakayama
Date:           Mon May 13 04:11:04 UTC 2019

Modified Files:
        src/sys/dev/audio: audio.c

Log Message:
audio_hw_probe:
Return error if both play and record probes failed.

Avoid audio is disabled on devices with only play like USB speakers.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/audio/audio.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.4 src/sys/dev/audio/audio.c:1.5
--- src/sys/dev/audio/audio.c:1.4	Mon May 13 04:09:35 2019
+++ src/sys/dev/audio/audio.c	Mon May 13 04:11:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.4 2019/05/13 04:09:35 nakayama Exp $	*/
+/*	$NetBSD: audio.c,v 1.5 2019/05/13 04:11:04 nakayama Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -149,7 +149,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.4 2019/05/13 04:09:35 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.5 2019/05/13 04:11:04 nakayama Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -6149,17 +6149,23 @@ audio_hw_probe(struct audio_softc *sc, i
 	    "invalid mode = %x", mode);
 
 	if (is_indep) {
+		int errorp = 0, errorr = 0;
+
 		/* On independent devices, probe separately. */
 		if ((mode & AUMODE_PLAY) != 0) {
-			error = audio_hw_probe_fmt(sc, phwfmt, AUMODE_PLAY);
-			if (error)
+			errorp = audio_hw_probe_fmt(sc, phwfmt, AUMODE_PLAY);
+			if (errorp)
 				mode &= ~AUMODE_PLAY;
 		}
 		if ((mode & AUMODE_RECORD) != 0) {
-			error = audio_hw_probe_fmt(sc, rhwfmt, AUMODE_RECORD);
-			if (error)
+			errorr = audio_hw_probe_fmt(sc, rhwfmt, AUMODE_RECORD);
+			if (errorr)
 				mode &= ~AUMODE_RECORD;
 		}
+
+		/* Return error if both play and record probes failed. */
+		if (errorp && errorr)
+			error = errorp;
 	} else {
 		/* On non independent devices, probe simultaneously. */
 		error = audio_hw_probe_fmt(sc, &fmt, mode);

Reply via email to