Fri Dec 9 05:08:25 2011 UTC ()
drop the thread lock in a couple of error cases that were missing.


(mrg)
diff -r1.255 -r1.256 src/sys/dev/audio.c

cvs diff -r1.255 -r1.256 src/sys/dev/Attic/audio.c (expand / switch to unified diff)

--- src/sys/dev/Attic/audio.c 2011/11/25 03:13:06 1.255
+++ src/sys/dev/Attic/audio.c 2011/12/09 05:08:25 1.256
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: audio.c,v 1.255 2011/11/25 03:13:06 jakllsch Exp $ */ 1/* $NetBSD: audio.c,v 1.256 2011/12/09 05:08:25 mrg Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -145,27 +145,27 @@ @@ -145,27 +145,27 @@
145 * query_devinfo - x 145 * query_devinfo - x
146 * allocm - - Called at attach time 146 * allocm - - Called at attach time
147 * freem - - Called at attach time 147 * freem - - Called at attach time
148 * round_buffersize - x 148 * round_buffersize - x
149 * mappage - - Mem. unchanged after attach 149 * mappage - - Mem. unchanged after attach
150 * get_props - x 150 * get_props - x
151 * trigger_output x x 151 * trigger_output x x
152 * trigger_input x x 152 * trigger_input x x
153 * dev_ioctl - x 153 * dev_ioctl - x
154 * get_locks - - Called at attach time 154 * get_locks - - Called at attach time
155 */ 155 */
156 156
157#include <sys/cdefs.h> 157#include <sys/cdefs.h>
158__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.255 2011/11/25 03:13:06 jakllsch Exp $"); 158__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.256 2011/12/09 05:08:25 mrg Exp $");
159 159
160#include "audio.h" 160#include "audio.h"
161#if NAUDIO > 0 161#if NAUDIO > 0
162 162
163#include <sys/param.h> 163#include <sys/param.h>
164#include <sys/ioctl.h> 164#include <sys/ioctl.h>
165#include <sys/fcntl.h> 165#include <sys/fcntl.h>
166#include <sys/vnode.h> 166#include <sys/vnode.h>
167#include <sys/select.h> 167#include <sys/select.h>
168#include <sys/poll.h> 168#include <sys/poll.h>
169#include <sys/kmem.h> 169#include <sys/kmem.h>
170#include <sys/malloc.h> 170#include <sys/malloc.h>
171#include <sys/proc.h> 171#include <sys/proc.h>
@@ -454,37 +454,39 @@ audioattach(device_t parent, device_t se @@ -454,37 +454,39 @@ audioattach(device_t parent, device_t se
454 /* 454 /*
455 * XXX Would like to not hold the sc_lock around this whole block 455 * XXX Would like to not hold the sc_lock around this whole block
456 * escpially for audio_alloc_ring(), except that the latter calls 456 * escpially for audio_alloc_ring(), except that the latter calls
457 * ->round_blocksize() which demands the thread lock to be taken. 457 * ->round_blocksize() which demands the thread lock to be taken.
458 * 458 *
459 * Revisit. 459 * Revisit.
460 */ 460 */
461 mutex_enter(sc->sc_lock); 461 mutex_enter(sc->sc_lock);
462 if (audio_can_playback(sc)) { 462 if (audio_can_playback(sc)) {
463 error = audio_alloc_ring(sc, &sc->sc_pr, 463 error = audio_alloc_ring(sc, &sc->sc_pr,
464 AUMODE_PLAY, AU_RING_SIZE); 464 AUMODE_PLAY, AU_RING_SIZE);
465 if (error) { 465 if (error) {
466 sc->hw_if = NULL; 466 sc->hw_if = NULL;
 467 mutex_exit(sc->sc_lock);
467 aprint_error("audio: could not allocate play buffer\n"); 468 aprint_error("audio: could not allocate play buffer\n");
468 return; 469 return;
469 } 470 }
470 } 471 }
471 if (audio_can_capture(sc)) { 472 if (audio_can_capture(sc)) {
472 error = audio_alloc_ring(sc, &sc->sc_rr, 473 error = audio_alloc_ring(sc, &sc->sc_rr,
473 AUMODE_RECORD, AU_RING_SIZE); 474 AUMODE_RECORD, AU_RING_SIZE);
474 if (error) { 475 if (error) {
475 if (sc->sc_pr.s.start != 0) 476 if (sc->sc_pr.s.start != 0)
476 audio_free_ring(sc, &sc->sc_pr); 477 audio_free_ring(sc, &sc->sc_pr);
477 sc->hw_if = NULL; 478 sc->hw_if = NULL;
 479 mutex_exit(sc->sc_lock);
478 aprint_error("audio: could not allocate record buffer\n"); 480 aprint_error("audio: could not allocate record buffer\n");
479 return; 481 return;
480 } 482 }
481 } 483 }
482 484
483 sc->sc_lastgain = 128; 485 sc->sc_lastgain = 128;
484 486
485 error = audio_set_defaults(sc, 0); 487 error = audio_set_defaults(sc, 0);
486 mutex_exit(sc->sc_lock); 488 mutex_exit(sc->sc_lock);
487 if (error != 0) { 489 if (error != 0) {
488 aprint_error("audioattach: audio_set_defaults() failed\n"); 490 aprint_error("audioattach: audio_set_defaults() failed\n");
489 sc->hw_if = NULL; 491 sc->hw_if = NULL;
490 return; 492 return;