#include <linux/interrupt.h>
#include <linux/poll.h>
#include <linux/wait.h>
-#include <linux/mutex.h>
#include <asm/dma.h>
#include <asm/page.h>
/* waiting and locking */
wait_queue_head_t wait;
- struct mutex open_mutex;
+ struct semaphore open_sem;
wait_queue_head_t open_wait;
} dma[RME96xx_MAX_DEVS];
static int rme96xx_dmabuf_init(rme96xx_info * s,struct dmabuf* dma,int ioffset,int ooffset) {
- mutex_init(&dma->open_mutex);
+ init_MUTEX(&dma->open_sem);
init_waitqueue_head(&dma->open_wait);
init_waitqueue_head(&dma->wait);
dma->s = s;
if (pci_enable_device(pcidev))
goto err_irq;
- if (request_irq(s->irq, rme96xx_interrupt, IRQF_SHARED, "rme96xx", s)) {
+ if (request_irq(s->irq, rme96xx_interrupt, SA_SHIRQ, "rme96xx", s)) {
printk(KERN_ERR RME_MESS" irq %u in use\n", s->irq);
goto err_irq;
}
dma = &s->dma[devnum];
f->private_data = dma;
/* wait for device to become free */
- mutex_lock(&dma->open_mutex);
+ down(&dma->open_sem);
while (dma->open_mode & f->f_mode) {
if (f->f_flags & O_NONBLOCK) {
- mutex_unlock(&dma->open_mutex);
+ up(&dma->open_sem);
return -EBUSY;
}
add_wait_queue(&dma->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- mutex_unlock(&dma->open_mutex);
+ up(&dma->open_sem);
schedule();
remove_wait_queue(&dma->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- mutex_lock(&dma->open_mutex);
+ down(&dma->open_sem);
}
COMM ("hardware open")
dma->open_mode |= (f->f_mode & (FMODE_READ | FMODE_WRITE));
dma->opened = 1;
- mutex_unlock(&dma->open_mutex);
+ up(&dma->open_sem);
DBG(printk("device num %d open finished\n",devnum));
return 0;
}
wake_up(&dma->open_wait);
- mutex_unlock(&dma->open_mutex);
+ up(&dma->open_sem);
return 0;
}