#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <linux/interrupt.h>
-#include <linux/mutex.h>
-
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/mach-au1x00/au1000.h>
/* Boot options */
static int vra = 0; // 0 = no VRA, 1 = use VRA if codec supports it
-module_param(vra, bool, 0);
+MODULE_PARM(vra, "i");
MODULE_PARM_DESC(vra, "if 1 use VRA if codec supports it");
int no_vra; // do not use VRA
spinlock_t lock;
- struct mutex open_mutex;
- struct mutex sem;
+ struct semaphore open_sem;
+ struct semaphore sem;
mode_t open_mode;
wait_queue_head_t open_wait;
count *= db->cnt_factor;
- mutex_lock(&s->sem);
+ down(&s->sem);
add_wait_queue(&db->wait, &wait);
while (count > 0) {
ret = -EAGAIN;
goto out;
}
- mutex_unlock(&s->sem);
+ up(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
- mutex_lock(&s->sem);
+ down(&s->sem);
}
} while (avail <= 0);
} // while (count > 0)
out:
- mutex_unlock(&s->sem);
+ up(&s->sem);
out2:
remove_wait_queue(&db->wait, &wait);
set_current_state(TASK_RUNNING);
count *= db->cnt_factor;
- mutex_lock(&s->sem);
+ down(&s->sem);
add_wait_queue(&db->wait, &wait);
while (count > 0) {
ret = -EAGAIN;
goto out;
}
- mutex_unlock(&s->sem);
+ up(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
- mutex_lock(&s->sem);
+ down(&s->sem);
}
} while (avail <= 0);
} // while (count > 0)
out:
- mutex_unlock(&s->sem);
+ up(&s->sem);
out2:
remove_wait_queue(&db->wait, &wait);
set_current_state(TASK_RUNNING);
dbg("%s", __FUNCTION__);
lock_kernel();
- mutex_lock(&s->sem);
+ down(&s->sem);
if (vma->vm_flags & VM_WRITE)
db = &s->dma_dac;
else if (vma->vm_flags & VM_READ)
vma->vm_flags &= ~VM_IO;
db->mapped = 1;
out:
- mutex_unlock(&s->sem);
+ up(&s->sem);
unlock_kernel();
return ret;
}
file->private_data = s;
/* wait for device to become free */
- mutex_lock(&s->open_mutex);
+ down(&s->open_sem);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- mutex_unlock(&s->open_mutex);
+ up(&s->open_sem);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- mutex_unlock(&s->open_mutex);
+ up(&s->open_sem);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- mutex_lock(&s->open_mutex);
+ down(&s->open_sem);
}
stop_dac(s);
}
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- mutex_unlock(&s->open_mutex);
- mutex_init(&s->sem);
+ up(&s->open_sem);
+ init_MUTEX(&s->sem);
return nonseekable_open(inode, file);
}
lock_kernel();
}
- mutex_lock(&s->open_mutex);
+ down(&s->open_sem);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
dealloc_dmabuf(s, &s->dma_dac);
dealloc_dmabuf(s, &s->dma_adc);
}
s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
- mutex_unlock(&s->open_mutex);
+ up(&s->open_sem);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
init_waitqueue_head(&s->open_wait);
- mutex_init(&s->open_mutex);
+ init_MUTEX(&s->open_sem);
spin_lock_init(&s->lock);
s->codec.private_data = s;
s->codec.id = 0;