diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-09-14 15:53:41 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-09-14 17:14:50 -0400 |
commit | 645ef9ef1fc0ff70456495b1e21d3420b7b08541 (patch) | |
tree | f5e5df85076f397690437f09cb56688b06a03dbf /sound/oss/vwsnd.c | |
parent | 7b6c3a34e93aafc5dd9adc7dee87c7fa61d8bdbb (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/vwsnd.c')
-rw-r--r-- | sound/oss/vwsnd.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c index 8cd73cdd88af..643f1113b1d8 100644 --- a/sound/oss/vwsnd.c +++ b/sound/oss/vwsnd.c | |||
@@ -145,7 +145,6 @@ | |||
145 | #include <linux/init.h> | 145 | #include <linux/init.h> |
146 | 146 | ||
147 | #include <linux/spinlock.h> | 147 | #include <linux/spinlock.h> |
148 | #include <linux/smp_lock.h> | ||
149 | #include <linux/wait.h> | 148 | #include <linux/wait.h> |
150 | #include <linux/interrupt.h> | 149 | #include <linux/interrupt.h> |
151 | #include <linux/mutex.h> | 150 | #include <linux/mutex.h> |
@@ -160,6 +159,7 @@ | |||
160 | 159 | ||
161 | #ifdef VWSND_DEBUG | 160 | #ifdef VWSND_DEBUG |
162 | 161 | ||
162 | static DEFINE_MUTEX(vwsnd_mutex); | ||
163 | static int shut_up = 1; | 163 | static int shut_up = 1; |
164 | 164 | ||
165 | /* | 165 | /* |
@@ -2891,11 +2891,11 @@ static long vwsnd_audio_ioctl(struct file *file, | |||
2891 | vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data; | 2891 | vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data; |
2892 | int ret; | 2892 | int ret; |
2893 | 2893 | ||
2894 | lock_kernel(); | 2894 | mutex_lock(&vwsnd_mutex); |
2895 | mutex_lock(&devc->io_mutex); | 2895 | mutex_lock(&devc->io_mutex); |
2896 | ret = vwsnd_audio_do_ioctl(file, cmd, arg); | 2896 | ret = vwsnd_audio_do_ioctl(file, cmd, arg); |
2897 | mutex_unlock(&devc->io_mutex); | 2897 | mutex_unlock(&devc->io_mutex); |
2898 | unlock_kernel(); | 2898 | mutex_unlock(&vwsnd_mutex); |
2899 | 2899 | ||
2900 | return ret; | 2900 | return ret; |
2901 | } | 2901 | } |
@@ -2922,7 +2922,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) | |||
2922 | 2922 | ||
2923 | DBGE("(inode=0x%p, file=0x%p)\n", inode, file); | 2923 | DBGE("(inode=0x%p, file=0x%p)\n", inode, file); |
2924 | 2924 | ||
2925 | lock_kernel(); | 2925 | mutex_lock(&vwsnd_mutex); |
2926 | INC_USE_COUNT; | 2926 | INC_USE_COUNT; |
2927 | for (devc = vwsnd_dev_list; devc; devc = devc->next_dev) | 2927 | for (devc = vwsnd_dev_list; devc; devc = devc->next_dev) |
2928 | if ((devc->audio_minor & ~0x0F) == (minor & ~0x0F)) | 2928 | if ((devc->audio_minor & ~0x0F) == (minor & ~0x0F)) |
@@ -2930,7 +2930,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) | |||
2930 | 2930 | ||
2931 | if (devc == NULL) { | 2931 | if (devc == NULL) { |
2932 | DEC_USE_COUNT; | 2932 | DEC_USE_COUNT; |
2933 | unlock_kernel(); | 2933 | mutex_unlock(&vwsnd_mutex); |
2934 | return -ENODEV; | 2934 | return -ENODEV; |
2935 | } | 2935 | } |
2936 | 2936 | ||
@@ -2939,13 +2939,13 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) | |||
2939 | mutex_unlock(&devc->open_mutex); | 2939 | mutex_unlock(&devc->open_mutex); |
2940 | if (file->f_flags & O_NONBLOCK) { | 2940 | if (file->f_flags & O_NONBLOCK) { |
2941 | DEC_USE_COUNT; | 2941 | DEC_USE_COUNT; |
2942 | unlock_kernel(); | 2942 | mutex_unlock(&vwsnd_mutex); |
2943 | return -EBUSY; | 2943 | return -EBUSY; |
2944 | } | 2944 | } |
2945 | interruptible_sleep_on(&devc->open_wait); | 2945 | interruptible_sleep_on(&devc->open_wait); |
2946 | if (signal_pending(current)) { | 2946 | if (signal_pending(current)) { |
2947 | DEC_USE_COUNT; | 2947 | DEC_USE_COUNT; |
2948 | unlock_kernel(); | 2948 | mutex_unlock(&vwsnd_mutex); |
2949 | return -ERESTARTSYS; | 2949 | return -ERESTARTSYS; |
2950 | } | 2950 | } |
2951 | mutex_lock(&devc->open_mutex); | 2951 | mutex_lock(&devc->open_mutex); |
@@ -2998,7 +2998,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) | |||
2998 | 2998 | ||
2999 | file->private_data = devc; | 2999 | file->private_data = devc; |
3000 | DBGRV(); | 3000 | DBGRV(); |
3001 | unlock_kernel(); | 3001 | mutex_unlock(&vwsnd_mutex); |
3002 | return 0; | 3002 | return 0; |
3003 | } | 3003 | } |
3004 | 3004 | ||
@@ -3012,7 +3012,7 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file) | |||
3012 | vwsnd_port_t *wport = NULL, *rport = NULL; | 3012 | vwsnd_port_t *wport = NULL, *rport = NULL; |
3013 | int err = 0; | 3013 | int err = 0; |
3014 | 3014 | ||
3015 | lock_kernel(); | 3015 | mutex_lock(&vwsnd_mutex); |
3016 | mutex_lock(&devc->io_mutex); | 3016 | mutex_lock(&devc->io_mutex); |
3017 | { | 3017 | { |
3018 | DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); | 3018 | DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); |
@@ -3040,7 +3040,7 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file) | |||
3040 | wake_up(&devc->open_wait); | 3040 | wake_up(&devc->open_wait); |
3041 | DEC_USE_COUNT; | 3041 | DEC_USE_COUNT; |
3042 | DBGR(); | 3042 | DBGR(); |
3043 | unlock_kernel(); | 3043 | mutex_unlock(&vwsnd_mutex); |
3044 | return err; | 3044 | return err; |
3045 | } | 3045 | } |
3046 | 3046 | ||
@@ -3068,18 +3068,18 @@ static int vwsnd_mixer_open(struct inode *inode, struct file *file) | |||
3068 | DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); | 3068 | DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); |
3069 | 3069 | ||
3070 | INC_USE_COUNT; | 3070 | INC_USE_COUNT; |
3071 | lock_kernel(); | 3071 | mutex_lock(&vwsnd_mutex); |
3072 | for (devc = vwsnd_dev_list; devc; devc = devc->next_dev) | 3072 | for (devc = vwsnd_dev_list; devc; devc = devc->next_dev) |
3073 | if (devc->mixer_minor == iminor(inode)) | 3073 | if (devc->mixer_minor == iminor(inode)) |
3074 | break; | 3074 | break; |
3075 | 3075 | ||
3076 | if (devc == NULL) { | 3076 | if (devc == NULL) { |
3077 | DEC_USE_COUNT; | 3077 | DEC_USE_COUNT; |
3078 | unlock_kernel(); | 3078 | mutex_unlock(&vwsnd_mutex); |
3079 | return -ENODEV; | 3079 | return -ENODEV; |
3080 | } | 3080 | } |
3081 | file->private_data = devc; | 3081 | file->private_data = devc; |
3082 | unlock_kernel(); | 3082 | mutex_unlock(&vwsnd_mutex); |
3083 | return 0; | 3083 | return 0; |
3084 | } | 3084 | } |
3085 | 3085 | ||
@@ -3223,7 +3223,7 @@ static long vwsnd_mixer_ioctl(struct file *file, | |||
3223 | 3223 | ||
3224 | DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg); | 3224 | DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg); |
3225 | 3225 | ||
3226 | lock_kernel(); | 3226 | mutex_lock(&vwsnd_mutex); |
3227 | mutex_lock(&devc->mix_mutex); | 3227 | mutex_lock(&devc->mix_mutex); |
3228 | { | 3228 | { |
3229 | if ((cmd & ~nrmask) == MIXER_READ(0)) | 3229 | if ((cmd & ~nrmask) == MIXER_READ(0)) |
@@ -3234,7 +3234,7 @@ static long vwsnd_mixer_ioctl(struct file *file, | |||
3234 | retval = -EINVAL; | 3234 | retval = -EINVAL; |
3235 | } | 3235 | } |
3236 | mutex_unlock(&devc->mix_mutex); | 3236 | mutex_unlock(&devc->mix_mutex); |
3237 | unlock_kernel(); | 3237 | mutex_unlock(&vwsnd_mutex); |
3238 | return retval; | 3238 | return retval; |
3239 | } | 3239 | } |
3240 | 3240 | ||