X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Foss%2Fvwsnd.c;fp=sound%2Foss%2Fvwsnd.c;h=5f140c7586b385a52d1ca9cf94bc1048b5edbebc;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=265423054cafdee5f715615ddaaf219177b14ef6;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c index 265423054..5f140c758 100644 --- a/sound/oss/vwsnd.c +++ b/sound/oss/vwsnd.c @@ -94,7 +94,7 @@ * Open will block until the previous client has closed the * device, unless O_NONBLOCK is specified. * - * The semaphore devc->io_sema serializes PCM I/O syscalls. This + * The semaphore devc->io_mutex serializes PCM I/O syscalls. This * is unnecessary in Linux 2.2, because the kernel lock * serializes read, write, and ioctl globally, but it's there, * ready for the brave, new post-kernel-lock world. @@ -105,7 +105,7 @@ * area it owns and update its pointers. See pcm_output() and * pcm_input() for most of the gory stuff. * - * devc->mix_sema serializes all mixer ioctls. This is also + * devc->mix_mutex serializes all mixer ioctls. This is also * redundant because of the kernel lock. * * The lowest level lock is lith->lithium_lock. It is a @@ -148,7 +148,8 @@ #include #include #include -#include +#include + #include #include "sound_config.h" @@ -246,27 +247,6 @@ typedef struct lithium { spinlock_t lock; /* protects codec and UST/MSC access */ } lithium_t; -/* - * li_create initializes the lithium_t structure and sets up vm mappings - * to access the registers. - * Returns 0 on success, -errno on failure. - */ - -static int __init li_create(lithium_t *lith, unsigned long baseaddr) -{ - static void li_destroy(lithium_t *); - - spin_lock_init(&lith->lock); - lith->page0 = ioremap_nocache(baseaddr + LI_PAGE0_OFFSET, PAGE_SIZE); - lith->page1 = ioremap_nocache(baseaddr + LI_PAGE1_OFFSET, PAGE_SIZE); - lith->page2 = ioremap_nocache(baseaddr + LI_PAGE2_OFFSET, PAGE_SIZE); - if (!lith->page0 || !lith->page1 || !lith->page2) { - li_destroy(lith); - return -ENOMEM; - } - return 0; -} - /* * li_destroy destroys the lithium_t structure and vm mappings. */ @@ -287,6 +267,25 @@ static void li_destroy(lithium_t *lith) } } +/* + * li_create initializes the lithium_t structure and sets up vm mappings + * to access the registers. + * Returns 0 on success, -errno on failure. + */ + +static int __init li_create(lithium_t *lith, unsigned long baseaddr) +{ + spin_lock_init(&lith->lock); + lith->page0 = ioremap_nocache(baseaddr + LI_PAGE0_OFFSET, PAGE_SIZE); + lith->page1 = ioremap_nocache(baseaddr + LI_PAGE1_OFFSET, PAGE_SIZE); + lith->page2 = ioremap_nocache(baseaddr + LI_PAGE2_OFFSET, PAGE_SIZE); + if (!lith->page0 || !lith->page1 || !lith->page2) { + li_destroy(lith); + return -ENOMEM; + } + return 0; +} + /* * basic register accessors - read/write long/byte */ @@ -1447,11 +1446,11 @@ typedef enum vwsnd_port_flags { * * port->lock protects: hwstate, flags, swb_[iu]_avail. * - * devc->io_sema protects: swstate, sw_*, swb_[iu]_idx. + * devc->io_mutex protects: swstate, sw_*, swb_[iu]_idx. * * everything else is only written by open/release or * pcm_{setup,shutdown}(), which are serialized by a - * combination of devc->open_sema and devc->io_sema. + * combination of devc->open_mutex and devc->io_mutex. */ typedef struct vwsnd_port { @@ -1507,9 +1506,9 @@ typedef struct vwsnd_dev { int audio_minor; /* minor number of audio device */ int mixer_minor; /* minor number of mixer device */ - struct semaphore open_sema; - struct semaphore io_sema; - struct semaphore mix_sema; + struct mutex open_mutex; + struct mutex io_mutex; + struct mutex mix_mutex; mode_t open_mode; wait_queue_head_t open_wait; @@ -1633,7 +1632,7 @@ static __inline__ unsigned int swb_inc_i(vwsnd_port_t *port, int inc) * mode-setting ioctls have been done, but before the first I/O is * done. * - * Locking: called with devc->io_sema held. + * Locking: called with devc->io_mutex held. * * Returns 0 on success, -errno on failure. */ @@ -2319,9 +2318,9 @@ static ssize_t vwsnd_audio_read(struct file *file, vwsnd_dev_t *devc = file->private_data; ssize_t ret; - down(&devc->io_sema); + mutex_lock(&devc->io_mutex); ret = vwsnd_audio_do_read(file, buffer, count, ppos); - up(&devc->io_sema); + mutex_unlock(&devc->io_mutex); return ret; } @@ -2394,9 +2393,9 @@ static ssize_t vwsnd_audio_write(struct file *file, vwsnd_dev_t *devc = file->private_data; ssize_t ret; - down(&devc->io_sema); + mutex_lock(&devc->io_mutex); ret = vwsnd_audio_do_write(file, buffer, count, ppos); - up(&devc->io_sema); + mutex_unlock(&devc->io_mutex); return ret; } @@ -2891,9 +2890,9 @@ static int vwsnd_audio_ioctl(struct inode *inode, vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data; int ret; - down(&devc->io_sema); + mutex_lock(&devc->io_mutex); ret = vwsnd_audio_do_ioctl(inode, file, cmd, arg); - up(&devc->io_sema); + mutex_unlock(&devc->io_mutex); return ret; } @@ -2929,9 +2928,9 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) return -ENODEV; } - down(&devc->open_sema); + mutex_lock(&devc->open_mutex); while (devc->open_mode & file->f_mode) { - up(&devc->open_sema); + mutex_unlock(&devc->open_mutex); if (file->f_flags & O_NONBLOCK) { DEC_USE_COUNT; return -EBUSY; @@ -2941,10 +2940,10 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) DEC_USE_COUNT; return -ERESTARTSYS; } - down(&devc->open_sema); + mutex_lock(&devc->open_mutex); } devc->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); - up(&devc->open_sema); + mutex_unlock(&devc->open_mutex); /* get default sample format from minor number. */ @@ -2960,7 +2959,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) /* Initialize vwsnd_ports. */ - down(&devc->io_sema); + mutex_lock(&devc->io_mutex); { if (file->f_mode & FMODE_READ) { devc->rport.swstate = SW_INITIAL; @@ -2987,7 +2986,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) devc->wport.frag_count = 0; } } - up(&devc->io_sema); + mutex_unlock(&devc->io_mutex); file->private_data = devc; DBGRV(); @@ -3005,7 +3004,7 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file) int err = 0; lock_kernel(); - down(&devc->io_sema); + mutex_lock(&devc->io_mutex); { DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); @@ -3022,13 +3021,13 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file) if (wport) wport->swstate = SW_OFF; } - up(&devc->io_sema); + mutex_unlock(&devc->io_mutex); - down(&devc->open_sema); + mutex_lock(&devc->open_mutex); { devc->open_mode &= ~file->f_mode; } - up(&devc->open_sema); + mutex_unlock(&devc->open_mutex); wake_up(&devc->open_wait); DEC_USE_COUNT; DBGR(); @@ -3213,7 +3212,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl, DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg); - down(&devc->mix_sema); + mutex_lock(&devc->mix_mutex); { if ((cmd & ~nrmask) == MIXER_READ(0)) retval = mixer_read_ioctl(devc, nr, (void __user *) arg); @@ -3222,7 +3221,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl, else retval = -EINVAL; } - up(&devc->mix_sema); + mutex_unlock(&devc->mix_mutex); return retval; } @@ -3376,9 +3375,9 @@ static int __init attach_vwsnd(struct address_info *hw_config) /* Initialize as much of *devc as possible */ - init_MUTEX(&devc->open_sema); - init_MUTEX(&devc->io_sema); - init_MUTEX(&devc->mix_sema); + mutex_init(&devc->open_mutex); + mutex_init(&devc->io_mutex); + mutex_init(&devc->mix_mutex); devc->open_mode = 0; spin_lock_init(&devc->rport.lock); init_waitqueue_head(&devc->rport.queue);