diff options
Diffstat (limited to 'sound/oss/vwsnd.c')
-rw-r--r-- | sound/oss/vwsnd.c | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c index 265423054caf..b372e88e857f 100644 --- a/sound/oss/vwsnd.c +++ b/sound/oss/vwsnd.c | |||
@@ -94,7 +94,7 @@ | |||
94 | * Open will block until the previous client has closed the | 94 | * Open will block until the previous client has closed the |
95 | * device, unless O_NONBLOCK is specified. | 95 | * device, unless O_NONBLOCK is specified. |
96 | * | 96 | * |
97 | * The semaphore devc->io_sema serializes PCM I/O syscalls. This | 97 | * The semaphore devc->io_mutex serializes PCM I/O syscalls. This |
98 | * is unnecessary in Linux 2.2, because the kernel lock | 98 | * is unnecessary in Linux 2.2, because the kernel lock |
99 | * serializes read, write, and ioctl globally, but it's there, | 99 | * serializes read, write, and ioctl globally, but it's there, |
100 | * ready for the brave, new post-kernel-lock world. | 100 | * ready for the brave, new post-kernel-lock world. |
@@ -105,7 +105,7 @@ | |||
105 | * area it owns and update its pointers. See pcm_output() and | 105 | * area it owns and update its pointers. See pcm_output() and |
106 | * pcm_input() for most of the gory stuff. | 106 | * pcm_input() for most of the gory stuff. |
107 | * | 107 | * |
108 | * devc->mix_sema serializes all mixer ioctls. This is also | 108 | * devc->mix_mutex serializes all mixer ioctls. This is also |
109 | * redundant because of the kernel lock. | 109 | * redundant because of the kernel lock. |
110 | * | 110 | * |
111 | * The lowest level lock is lith->lithium_lock. It is a | 111 | * The lowest level lock is lith->lithium_lock. It is a |
@@ -148,7 +148,8 @@ | |||
148 | #include <linux/smp_lock.h> | 148 | #include <linux/smp_lock.h> |
149 | #include <linux/wait.h> | 149 | #include <linux/wait.h> |
150 | #include <linux/interrupt.h> | 150 | #include <linux/interrupt.h> |
151 | #include <asm/semaphore.h> | 151 | #include <linux/mutex.h> |
152 | |||
152 | #include <asm/mach-visws/cobalt.h> | 153 | #include <asm/mach-visws/cobalt.h> |
153 | 154 | ||
154 | #include "sound_config.h" | 155 | #include "sound_config.h" |
@@ -1447,11 +1448,11 @@ typedef enum vwsnd_port_flags { | |||
1447 | * | 1448 | * |
1448 | * port->lock protects: hwstate, flags, swb_[iu]_avail. | 1449 | * port->lock protects: hwstate, flags, swb_[iu]_avail. |
1449 | * | 1450 | * |
1450 | * devc->io_sema protects: swstate, sw_*, swb_[iu]_idx. | 1451 | * devc->io_mutex protects: swstate, sw_*, swb_[iu]_idx. |
1451 | * | 1452 | * |
1452 | * everything else is only written by open/release or | 1453 | * everything else is only written by open/release or |
1453 | * pcm_{setup,shutdown}(), which are serialized by a | 1454 | * pcm_{setup,shutdown}(), which are serialized by a |
1454 | * combination of devc->open_sema and devc->io_sema. | 1455 | * combination of devc->open_mutex and devc->io_mutex. |
1455 | */ | 1456 | */ |
1456 | 1457 | ||
1457 | typedef struct vwsnd_port { | 1458 | typedef struct vwsnd_port { |
@@ -1507,9 +1508,9 @@ typedef struct vwsnd_dev { | |||
1507 | int audio_minor; /* minor number of audio device */ | 1508 | int audio_minor; /* minor number of audio device */ |
1508 | int mixer_minor; /* minor number of mixer device */ | 1509 | int mixer_minor; /* minor number of mixer device */ |
1509 | 1510 | ||
1510 | struct semaphore open_sema; | 1511 | struct mutex open_mutex; |
1511 | struct semaphore io_sema; | 1512 | struct mutex io_mutex; |
1512 | struct semaphore mix_sema; | 1513 | struct mutex mix_mutex; |
1513 | mode_t open_mode; | 1514 | mode_t open_mode; |
1514 | wait_queue_head_t open_wait; | 1515 | wait_queue_head_t open_wait; |
1515 | 1516 | ||
@@ -1633,7 +1634,7 @@ static __inline__ unsigned int swb_inc_i(vwsnd_port_t *port, int inc) | |||
1633 | * mode-setting ioctls have been done, but before the first I/O is | 1634 | * mode-setting ioctls have been done, but before the first I/O is |
1634 | * done. | 1635 | * done. |
1635 | * | 1636 | * |
1636 | * Locking: called with devc->io_sema held. | 1637 | * Locking: called with devc->io_mutex held. |
1637 | * | 1638 | * |
1638 | * Returns 0 on success, -errno on failure. | 1639 | * Returns 0 on success, -errno on failure. |
1639 | */ | 1640 | */ |
@@ -2319,9 +2320,9 @@ static ssize_t vwsnd_audio_read(struct file *file, | |||
2319 | vwsnd_dev_t *devc = file->private_data; | 2320 | vwsnd_dev_t *devc = file->private_data; |
2320 | ssize_t ret; | 2321 | ssize_t ret; |
2321 | 2322 | ||
2322 | down(&devc->io_sema); | 2323 | mutex_lock(&devc->io_mutex); |
2323 | ret = vwsnd_audio_do_read(file, buffer, count, ppos); | 2324 | ret = vwsnd_audio_do_read(file, buffer, count, ppos); |
2324 | up(&devc->io_sema); | 2325 | mutex_unlock(&devc->io_mutex); |
2325 | return ret; | 2326 | return ret; |
2326 | } | 2327 | } |
2327 | 2328 | ||
@@ -2394,9 +2395,9 @@ static ssize_t vwsnd_audio_write(struct file *file, | |||
2394 | vwsnd_dev_t *devc = file->private_data; | 2395 | vwsnd_dev_t *devc = file->private_data; |
2395 | ssize_t ret; | 2396 | ssize_t ret; |
2396 | 2397 | ||
2397 | down(&devc->io_sema); | 2398 | mutex_lock(&devc->io_mutex); |
2398 | ret = vwsnd_audio_do_write(file, buffer, count, ppos); | 2399 | ret = vwsnd_audio_do_write(file, buffer, count, ppos); |
2399 | up(&devc->io_sema); | 2400 | mutex_unlock(&devc->io_mutex); |
2400 | return ret; | 2401 | return ret; |
2401 | } | 2402 | } |
2402 | 2403 | ||
@@ -2891,9 +2892,9 @@ static int vwsnd_audio_ioctl(struct inode *inode, | |||
2891 | vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data; | 2892 | vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data; |
2892 | int ret; | 2893 | int ret; |
2893 | 2894 | ||
2894 | down(&devc->io_sema); | 2895 | mutex_lock(&devc->io_mutex); |
2895 | ret = vwsnd_audio_do_ioctl(inode, file, cmd, arg); | 2896 | ret = vwsnd_audio_do_ioctl(inode, file, cmd, arg); |
2896 | up(&devc->io_sema); | 2897 | mutex_unlock(&devc->io_mutex); |
2897 | return ret; | 2898 | return ret; |
2898 | } | 2899 | } |
2899 | 2900 | ||
@@ -2929,9 +2930,9 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) | |||
2929 | return -ENODEV; | 2930 | return -ENODEV; |
2930 | } | 2931 | } |
2931 | 2932 | ||
2932 | down(&devc->open_sema); | 2933 | mutex_lock(&devc->open_mutex); |
2933 | while (devc->open_mode & file->f_mode) { | 2934 | while (devc->open_mode & file->f_mode) { |
2934 | up(&devc->open_sema); | 2935 | mutex_unlock(&devc->open_mutex); |
2935 | if (file->f_flags & O_NONBLOCK) { | 2936 | if (file->f_flags & O_NONBLOCK) { |
2936 | DEC_USE_COUNT; | 2937 | DEC_USE_COUNT; |
2937 | return -EBUSY; | 2938 | return -EBUSY; |
@@ -2941,10 +2942,10 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) | |||
2941 | DEC_USE_COUNT; | 2942 | DEC_USE_COUNT; |
2942 | return -ERESTARTSYS; | 2943 | return -ERESTARTSYS; |
2943 | } | 2944 | } |
2944 | down(&devc->open_sema); | 2945 | mutex_lock(&devc->open_mutex); |
2945 | } | 2946 | } |
2946 | devc->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); | 2947 | devc->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); |
2947 | up(&devc->open_sema); | 2948 | mutex_unlock(&devc->open_mutex); |
2948 | 2949 | ||
2949 | /* get default sample format from minor number. */ | 2950 | /* get default sample format from minor number. */ |
2950 | 2951 | ||
@@ -2960,7 +2961,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) | |||
2960 | 2961 | ||
2961 | /* Initialize vwsnd_ports. */ | 2962 | /* Initialize vwsnd_ports. */ |
2962 | 2963 | ||
2963 | down(&devc->io_sema); | 2964 | mutex_lock(&devc->io_mutex); |
2964 | { | 2965 | { |
2965 | if (file->f_mode & FMODE_READ) { | 2966 | if (file->f_mode & FMODE_READ) { |
2966 | devc->rport.swstate = SW_INITIAL; | 2967 | devc->rport.swstate = SW_INITIAL; |
@@ -2987,7 +2988,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) | |||
2987 | devc->wport.frag_count = 0; | 2988 | devc->wport.frag_count = 0; |
2988 | } | 2989 | } |
2989 | } | 2990 | } |
2990 | up(&devc->io_sema); | 2991 | mutex_unlock(&devc->io_mutex); |
2991 | 2992 | ||
2992 | file->private_data = devc; | 2993 | file->private_data = devc; |
2993 | DBGRV(); | 2994 | DBGRV(); |
@@ -3005,7 +3006,7 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file) | |||
3005 | int err = 0; | 3006 | int err = 0; |
3006 | 3007 | ||
3007 | lock_kernel(); | 3008 | lock_kernel(); |
3008 | down(&devc->io_sema); | 3009 | mutex_lock(&devc->io_mutex); |
3009 | { | 3010 | { |
3010 | DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); | 3011 | DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); |
3011 | 3012 | ||
@@ -3022,13 +3023,13 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file) | |||
3022 | if (wport) | 3023 | if (wport) |
3023 | wport->swstate = SW_OFF; | 3024 | wport->swstate = SW_OFF; |
3024 | } | 3025 | } |
3025 | up(&devc->io_sema); | 3026 | mutex_unlock(&devc->io_mutex); |
3026 | 3027 | ||
3027 | down(&devc->open_sema); | 3028 | mutex_lock(&devc->open_mutex); |
3028 | { | 3029 | { |
3029 | devc->open_mode &= ~file->f_mode; | 3030 | devc->open_mode &= ~file->f_mode; |
3030 | } | 3031 | } |
3031 | up(&devc->open_sema); | 3032 | mutex_unlock(&devc->open_mutex); |
3032 | wake_up(&devc->open_wait); | 3033 | wake_up(&devc->open_wait); |
3033 | DEC_USE_COUNT; | 3034 | DEC_USE_COUNT; |
3034 | DBGR(); | 3035 | DBGR(); |
@@ -3213,7 +3214,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl, | |||
3213 | 3214 | ||
3214 | DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg); | 3215 | DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg); |
3215 | 3216 | ||
3216 | down(&devc->mix_sema); | 3217 | mutex_lock(&devc->mix_mutex); |
3217 | { | 3218 | { |
3218 | if ((cmd & ~nrmask) == MIXER_READ(0)) | 3219 | if ((cmd & ~nrmask) == MIXER_READ(0)) |
3219 | retval = mixer_read_ioctl(devc, nr, (void __user *) arg); | 3220 | retval = mixer_read_ioctl(devc, nr, (void __user *) arg); |
@@ -3222,7 +3223,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl, | |||
3222 | else | 3223 | else |
3223 | retval = -EINVAL; | 3224 | retval = -EINVAL; |
3224 | } | 3225 | } |
3225 | up(&devc->mix_sema); | 3226 | mutex_unlock(&devc->mix_mutex); |
3226 | return retval; | 3227 | return retval; |
3227 | } | 3228 | } |
3228 | 3229 | ||
@@ -3376,9 +3377,9 @@ static int __init attach_vwsnd(struct address_info *hw_config) | |||
3376 | 3377 | ||
3377 | /* Initialize as much of *devc as possible */ | 3378 | /* Initialize as much of *devc as possible */ |
3378 | 3379 | ||
3379 | init_MUTEX(&devc->open_sema); | 3380 | mutex_init(&devc->open_mutex); |
3380 | init_MUTEX(&devc->io_sema); | 3381 | mutex_init(&devc->io_mutex); |
3381 | init_MUTEX(&devc->mix_sema); | 3382 | mutex_init(&devc->mix_mutex); |
3382 | devc->open_mode = 0; | 3383 | devc->open_mode = 0; |
3383 | spin_lock_init(&devc->rport.lock); | 3384 | spin_lock_init(&devc->rport.lock); |
3384 | init_waitqueue_head(&devc->rport.queue); | 3385 | init_waitqueue_head(&devc->rport.queue); |