#include <linux/fs.h>
#include <linux/poll.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/vmalloc.h>
static int raw1394_mmap(struct file *file, struct vm_area_struct *vma)
{
struct file_info *fi = file->private_data;
+ int ret;
+
+ mutex_lock(&fi->state_mutex);
if (fi->iso_state == RAW1394_ISO_INACTIVE)
- return -EINVAL;
+ ret = -EINVAL;
+ else
+ ret = dma_region_mmap(&fi->iso_handle->data_buf, file, vma);
+
+ mutex_unlock(&fi->state_mutex);
- return dma_region_mmap(&fi->iso_handle->data_buf, file, vma);
+ return ret;
}
/* ioctl is only used for rawiso operations */
static long raw1394_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
+ struct file_info *fi = file->private_data;
long ret;
- lock_kernel();
+
+ mutex_lock(&fi->state_mutex);
ret = do_raw1394_ioctl(file, cmd, arg);
- unlock_kernel();
+ mutex_unlock(&fi->state_mutex);
return ret;
}
void __user *argp = (void __user *)arg;
long err;
- lock_kernel();
+ mutex_lock(&fi->state_mutex);
switch (cmd) {
/* These requests have same format as long as 'int' has same size. */
case RAW1394_IOC_ISO_RECV_INIT:
err = -EINVAL;
break;
}
- unlock_kernel();
+ mutex_unlock(&fi->state_mutex);
return err;
}
fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */
INIT_LIST_HEAD(&fi->list);
+ mutex_init(&fi->state_mutex);
fi->state = opened;
INIT_LIST_HEAD(&fi->req_pending);
INIT_LIST_HEAD(&fi->req_complete);