diff options
Diffstat (limited to 'sound/oss/ite8172.c')
| -rw-r--r-- | sound/oss/ite8172.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sound/oss/ite8172.c b/sound/oss/ite8172.c index 8fd2f9a9e668..ffcb910f5c3e 100644 --- a/sound/oss/ite8172.c +++ b/sound/oss/ite8172.c | |||
| @@ -71,6 +71,8 @@ | |||
| 71 | #include <linux/smp_lock.h> | 71 | #include <linux/smp_lock.h> |
| 72 | #include <linux/ac97_codec.h> | 72 | #include <linux/ac97_codec.h> |
| 73 | #include <linux/interrupt.h> | 73 | #include <linux/interrupt.h> |
| 74 | #include <linux/mutex.h> | ||
| 75 | |||
| 74 | #include <asm/io.h> | 76 | #include <asm/io.h> |
| 75 | #include <asm/dma.h> | 77 | #include <asm/dma.h> |
| 76 | #include <asm/uaccess.h> | 78 | #include <asm/uaccess.h> |
| @@ -304,7 +306,7 @@ struct it8172_state { | |||
| 304 | unsigned dacrate, adcrate; | 306 | unsigned dacrate, adcrate; |
| 305 | 307 | ||
| 306 | spinlock_t lock; | 308 | spinlock_t lock; |
| 307 | struct semaphore open_sem; | 309 | struct mutex open_mutex; |
| 308 | mode_t open_mode; | 310 | mode_t open_mode; |
| 309 | wait_queue_head_t open_wait; | 311 | wait_queue_head_t open_wait; |
| 310 | 312 | ||
| @@ -1801,21 +1803,21 @@ static int it8172_open(struct inode *inode, struct file *file) | |||
| 1801 | } | 1803 | } |
| 1802 | file->private_data = s; | 1804 | file->private_data = s; |
| 1803 | /* wait for device to become free */ | 1805 | /* wait for device to become free */ |
| 1804 | down(&s->open_sem); | 1806 | mutex_lock(&s->open_mutex); |
| 1805 | while (s->open_mode & file->f_mode) { | 1807 | while (s->open_mode & file->f_mode) { |
| 1806 | if (file->f_flags & O_NONBLOCK) { | 1808 | if (file->f_flags & O_NONBLOCK) { |
| 1807 | up(&s->open_sem); | 1809 | mutex_unlock(&s->open_mutex); |
| 1808 | return -EBUSY; | 1810 | return -EBUSY; |
| 1809 | } | 1811 | } |
| 1810 | add_wait_queue(&s->open_wait, &wait); | 1812 | add_wait_queue(&s->open_wait, &wait); |
| 1811 | __set_current_state(TASK_INTERRUPTIBLE); | 1813 | __set_current_state(TASK_INTERRUPTIBLE); |
| 1812 | up(&s->open_sem); | 1814 | mutex_unlock(&s->open_mutex); |
| 1813 | schedule(); | 1815 | schedule(); |
| 1814 | remove_wait_queue(&s->open_wait, &wait); | 1816 | remove_wait_queue(&s->open_wait, &wait); |
| 1815 | set_current_state(TASK_RUNNING); | 1817 | set_current_state(TASK_RUNNING); |
| 1816 | if (signal_pending(current)) | 1818 | if (signal_pending(current)) |
| 1817 | return -ERESTARTSYS; | 1819 | return -ERESTARTSYS; |
| 1818 | down(&s->open_sem); | 1820 | mutex_lock(&s->open_mutex); |
| 1819 | } | 1821 | } |
| 1820 | 1822 | ||
| 1821 | spin_lock_irqsave(&s->lock, flags); | 1823 | spin_lock_irqsave(&s->lock, flags); |
| @@ -1850,7 +1852,7 @@ static int it8172_open(struct inode *inode, struct file *file) | |||
| 1850 | spin_unlock_irqrestore(&s->lock, flags); | 1852 | spin_unlock_irqrestore(&s->lock, flags); |
| 1851 | 1853 | ||
| 1852 | s->open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE)); | 1854 | s->open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE)); |
| 1853 | up(&s->open_sem); | 1855 | mutex_unlock(&s->open_mutex); |
| 1854 | return nonseekable_open(inode, file); | 1856 | return nonseekable_open(inode, file); |
| 1855 | } | 1857 | } |
| 1856 | 1858 | ||
| @@ -1864,7 +1866,7 @@ static int it8172_release(struct inode *inode, struct file *file) | |||
| 1864 | lock_kernel(); | 1866 | lock_kernel(); |
| 1865 | if (file->f_mode & FMODE_WRITE) | 1867 | if (file->f_mode & FMODE_WRITE) |
| 1866 | drain_dac(s, file->f_flags & O_NONBLOCK); | 1868 | drain_dac(s, file->f_flags & O_NONBLOCK); |
| 1867 | down(&s->open_sem); | 1869 | mutex_lock(&s->open_mutex); |
| 1868 | if (file->f_mode & FMODE_WRITE) { | 1870 | if (file->f_mode & FMODE_WRITE) { |
| 1869 | stop_dac(s); | 1871 | stop_dac(s); |
| 1870 | dealloc_dmabuf(s, &s->dma_dac); | 1872 | dealloc_dmabuf(s, &s->dma_dac); |
| @@ -1874,7 +1876,7 @@ static int it8172_release(struct inode *inode, struct file *file) | |||
| 1874 | dealloc_dmabuf(s, &s->dma_adc); | 1876 | dealloc_dmabuf(s, &s->dma_adc); |
| 1875 | } | 1877 | } |
| 1876 | s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE)); | 1878 | s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE)); |
| 1877 | up(&s->open_sem); | 1879 | mutex_unlock(&s->open_mutex); |
| 1878 | wake_up(&s->open_wait); | 1880 | wake_up(&s->open_wait); |
| 1879 | unlock_kernel(); | 1881 | unlock_kernel(); |
| 1880 | return 0; | 1882 | return 0; |
| @@ -1997,7 +1999,7 @@ static int __devinit it8172_probe(struct pci_dev *pcidev, | |||
| 1997 | init_waitqueue_head(&s->dma_adc.wait); | 1999 | init_waitqueue_head(&s->dma_adc.wait); |
| 1998 | init_waitqueue_head(&s->dma_dac.wait); | 2000 | init_waitqueue_head(&s->dma_dac.wait); |
| 1999 | init_waitqueue_head(&s->open_wait); | 2001 | init_waitqueue_head(&s->open_wait); |
| 2000 | init_MUTEX(&s->open_sem); | 2002 | mutex_init(&s->open_mutex); |
| 2001 | spin_lock_init(&s->lock); | 2003 | spin_lock_init(&s->lock); |
| 2002 | s->dev = pcidev; | 2004 | s->dev = pcidev; |
| 2003 | s->io = pci_resource_start(pcidev, 0); | 2005 | s->io = pci_resource_start(pcidev, 0); |
