From 645ef9ef1fc0ff70456495b1e21d3420b7b08541 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 14 Sep 2010 21:53:41 +0200 Subject: 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.*/d' ${file} else sed -i 's/include.*.*$/include /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.*\/d' ${file} \ -e '/cycle_kernel_lock()/d' fi Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/oss/sh_dac_audio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sound/oss/sh_dac_audio.c') diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c index 479e3025a8a3..53bba16bf709 100644 --- a/sound/oss/sh_dac_audio.c +++ b/sound/oss/sh_dac_audio.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -34,6 +34,7 @@ #define BUFFER_SIZE 48000 +static DEFINE_MUTEX(sh_dac_audio_mutex); static int rate; static int empty; static char *data_buffer, *buffer_begin, *buffer_end; @@ -163,9 +164,9 @@ static long dac_audio_unlocked_ioctl(struct file *file, u_int cmd, u_long arg) { int ret; - lock_kernel(); + mutex_lock(&sh_dac_audio_mutex); ret = dac_audio_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&sh_dac_audio_mutex); return ret; } @@ -229,16 +230,16 @@ static int dac_audio_open(struct inode *inode, struct file *file) if (file->f_mode & FMODE_READ) return -ENODEV; - lock_kernel(); + mutex_lock(&sh_dac_audio_mutex); if (in_use) { - unlock_kernel(); + mutex_unlock(&sh_dac_audio_mutex); return -EBUSY; } in_use = 1; dac_audio_start(); - unlock_kernel(); + mutex_unlock(&sh_dac_audio_mutex); return 0; } -- cgit v1.2.1