aboutsummaryrefslogtreecommitdiffstats
path: root/sound/oss/dmasound
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-09-14 15:53:41 -0400
committerTakashi Iwai <tiwai@suse.de>2010-09-14 17:14:50 -0400
commit645ef9ef1fc0ff70456495b1e21d3420b7b08541 (patch)
treef5e5df85076f397690437f09cb56688b06a03dbf /sound/oss/dmasound
parent7b6c3a34e93aafc5dd9adc7dee87c7fa61d8bdbb (diff)
sound: autoconvert trivial BKL users to private mutex
The usage of the BKL in the OSS sound drivers is trivial, and each of them only locks against itself, so it can be turned into per-driver mutexes. This is the script that was used for the conversion: file=$1 name=$2 if grep -q lock_kernel ${file} ; then if grep -q 'include.*linux.mutex.h' ${file} ; then sed -i '/include.*<linux\/smp_lock.h>/d' ${file} else sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file} fi sed -i ${file} \ -e "/^#include.*linux.mutex.h/,$ { 1,/^\(static\|int\|long\)/ { /^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex); } }" \ -e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \ -e '/[ ]*cycle_kernel_lock();/d' else sed -i -e '/include.*\<smp_lock.h\>/d' ${file} \ -e '/cycle_kernel_lock()/d' fi Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/oss/dmasound')
-rw-r--r--sound/oss/dmasound/dmasound_core.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
index 6ecd41abb066..87e2c72651f5 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -181,7 +181,7 @@
181#include <linux/init.h> 181#include <linux/init.h>
182#include <linux/soundcard.h> 182#include <linux/soundcard.h>
183#include <linux/poll.h> 183#include <linux/poll.h>
184#include <linux/smp_lock.h> 184#include <linux/mutex.h>
185 185
186#include <asm/uaccess.h> 186#include <asm/uaccess.h>
187 187
@@ -194,6 +194,7 @@
194 * Declarations 194 * Declarations
195 */ 195 */
196 196
197static DEFINE_MUTEX(dmasound_core_mutex);
197int dmasound_catchRadius = 0; 198int dmasound_catchRadius = 0;
198module_param(dmasound_catchRadius, int, 0); 199module_param(dmasound_catchRadius, int, 0);
199 200
@@ -323,22 +324,22 @@ static struct {
323 324
324static int mixer_open(struct inode *inode, struct file *file) 325static int mixer_open(struct inode *inode, struct file *file)
325{ 326{
326 lock_kernel(); 327 mutex_lock(&dmasound_core_mutex);
327 if (!try_module_get(dmasound.mach.owner)) { 328 if (!try_module_get(dmasound.mach.owner)) {
328 unlock_kernel(); 329 mutex_unlock(&dmasound_core_mutex);
329 return -ENODEV; 330 return -ENODEV;
330 } 331 }
331 mixer.busy = 1; 332 mixer.busy = 1;
332 unlock_kernel(); 333 mutex_unlock(&dmasound_core_mutex);
333 return 0; 334 return 0;
334} 335}
335 336
336static int mixer_release(struct inode *inode, struct file *file) 337static int mixer_release(struct inode *inode, struct file *file)
337{ 338{
338 lock_kernel(); 339 mutex_lock(&dmasound_core_mutex);
339 mixer.busy = 0; 340 mixer.busy = 0;
340 module_put(dmasound.mach.owner); 341 module_put(dmasound.mach.owner);
341 unlock_kernel(); 342 mutex_unlock(&dmasound_core_mutex);
342 return 0; 343 return 0;
343} 344}
344 345
@@ -370,9 +371,9 @@ static long mixer_unlocked_ioctl(struct file *file, u_int cmd, u_long arg)
370{ 371{
371 int ret; 372 int ret;
372 373
373 lock_kernel(); 374 mutex_lock(&dmasound_core_mutex);
374 ret = mixer_ioctl(file, cmd, arg); 375 ret = mixer_ioctl(file, cmd, arg);
375 unlock_kernel(); 376 mutex_unlock(&dmasound_core_mutex);
376 377
377 return ret; 378 return ret;
378} 379}
@@ -752,9 +753,9 @@ static int sq_open(struct inode *inode, struct file *file)
752{ 753{
753 int rc; 754 int rc;
754 755
755 lock_kernel(); 756 mutex_lock(&dmasound_core_mutex);
756 if (!try_module_get(dmasound.mach.owner)) { 757 if (!try_module_get(dmasound.mach.owner)) {
757 unlock_kernel(); 758 mutex_unlock(&dmasound_core_mutex);
758 return -ENODEV; 759 return -ENODEV;
759 } 760 }
760 761
@@ -799,11 +800,11 @@ static int sq_open(struct inode *inode, struct file *file)
799 sound_set_format(AFMT_MU_LAW); 800 sound_set_format(AFMT_MU_LAW);
800 } 801 }
801#endif 802#endif
802 unlock_kernel(); 803 mutex_unlock(&dmasound_core_mutex);
803 return 0; 804 return 0;
804 out: 805 out:
805 module_put(dmasound.mach.owner); 806 module_put(dmasound.mach.owner);
806 unlock_kernel(); 807 mutex_unlock(&dmasound_core_mutex);
807 return rc; 808 return rc;
808} 809}
809 810
@@ -869,7 +870,7 @@ static int sq_release(struct inode *inode, struct file *file)
869{ 870{
870 int rc = 0; 871 int rc = 0;
871 872
872 lock_kernel(); 873 mutex_lock(&dmasound_core_mutex);
873 874
874 if (file->f_mode & FMODE_WRITE) { 875 if (file->f_mode & FMODE_WRITE) {
875 if (write_sq.busy) 876 if (write_sq.busy)
@@ -900,7 +901,7 @@ static int sq_release(struct inode *inode, struct file *file)
900 write_sq_wake_up(file); /* checks f_mode */ 901 write_sq_wake_up(file); /* checks f_mode */
901#endif /* blocking open() */ 902#endif /* blocking open() */
902 903
903 unlock_kernel(); 904 mutex_unlock(&dmasound_core_mutex);
904 905
905 return rc; 906 return rc;
906} 907}
@@ -1141,9 +1142,9 @@ static long sq_unlocked_ioctl(struct file *file, u_int cmd, u_long arg)
1141{ 1142{
1142 int ret; 1143 int ret;
1143 1144
1144 lock_kernel(); 1145 mutex_lock(&dmasound_core_mutex);
1145 ret = sq_ioctl(file, cmd, arg); 1146 ret = sq_ioctl(file, cmd, arg);
1146 unlock_kernel(); 1147 mutex_unlock(&dmasound_core_mutex);
1147 1148
1148 return ret; 1149 return ret;
1149} 1150}
@@ -1257,7 +1258,7 @@ static int state_open(struct inode *inode, struct file *file)
1257 int len = 0; 1258 int len = 0;
1258 int ret; 1259 int ret;
1259 1260
1260 lock_kernel(); 1261 mutex_lock(&dmasound_core_mutex);
1261 ret = -EBUSY; 1262 ret = -EBUSY;
1262 if (state.busy) 1263 if (state.busy)
1263 goto out; 1264 goto out;
@@ -1329,16 +1330,16 @@ printk("dmasound: stat buffer used %d bytes\n", len) ;
1329 state.len = len; 1330 state.len = len;
1330 ret = 0; 1331 ret = 0;
1331out: 1332out:
1332 unlock_kernel(); 1333 mutex_unlock(&dmasound_core_mutex);
1333 return ret; 1334 return ret;
1334} 1335}
1335 1336
1336static int state_release(struct inode *inode, struct file *file) 1337static int state_release(struct inode *inode, struct file *file)
1337{ 1338{
1338 lock_kernel(); 1339 mutex_lock(&dmasound_core_mutex);
1339 state.busy = 0; 1340 state.busy = 0;
1340 module_put(dmasound.mach.owner); 1341 module_put(dmasound.mach.owner);
1341 unlock_kernel(); 1342 mutex_unlock(&dmasound_core_mutex);
1342 return 0; 1343 return 0;
1343} 1344}
1344 1345