mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
v4l: Convert v4l2-dev to unlocked_ioctl
v4l2 implements two separate file operations for drivers that use locked and unlocked ioctl callbacks. Since we want to remove the ioctl file operation in favor of the unlocked variant, this separation no longer seems helpful. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Hans Verkuil <hverkuil@xs4all.nl> Cc: John Kacur <jkacur@redhat.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
This commit is contained in:
parent
29f367bfbf
commit
86a5ef7d77
1 changed files with 15 additions and 37 deletions
|
@ -25,6 +25,7 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/kmod.h>
|
#include <linux/kmod.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/smp_lock.h>
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <asm/system.h>
|
#include <asm/system.h>
|
||||||
|
|
||||||
|
@ -215,28 +216,24 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
|
||||||
return vdev->fops->poll(filp, poll);
|
return vdev->fops->poll(filp, poll);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int v4l2_ioctl(struct inode *inode, struct file *filp,
|
static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
struct video_device *vdev = video_devdata(filp);
|
struct video_device *vdev = video_devdata(filp);
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!vdev->fops->ioctl)
|
|
||||||
return -ENOTTY;
|
|
||||||
/* Allow ioctl to continue even if the device was unregistered.
|
/* Allow ioctl to continue even if the device was unregistered.
|
||||||
Things like dequeueing buffers might still be useful. */
|
Things like dequeueing buffers might still be useful. */
|
||||||
return vdev->fops->ioctl(filp, cmd, arg);
|
if (vdev->fops->unlocked_ioctl) {
|
||||||
}
|
ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
|
||||||
|
} else if (vdev->fops->ioctl) {
|
||||||
|
/* TODO: convert all drivers to unlocked_ioctl */
|
||||||
|
lock_kernel();
|
||||||
|
ret = vdev->fops->ioctl(filp, cmd, arg);
|
||||||
|
unlock_kernel();
|
||||||
|
} else
|
||||||
|
ret = -ENOTTY;
|
||||||
|
|
||||||
static long v4l2_unlocked_ioctl(struct file *filp,
|
return ret;
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
|
||||||
struct video_device *vdev = video_devdata(filp);
|
|
||||||
|
|
||||||
if (!vdev->fops->unlocked_ioctl)
|
|
||||||
return -ENOTTY;
|
|
||||||
/* Allow ioctl to continue even if the device was unregistered.
|
|
||||||
Things like dequeueing buffers might still be useful. */
|
|
||||||
return vdev->fops->unlocked_ioctl(filp, cmd, arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MMU
|
#ifdef CONFIG_MMU
|
||||||
|
@ -307,22 +304,6 @@ static int v4l2_release(struct inode *inode, struct file *filp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations v4l2_unlocked_fops = {
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.read = v4l2_read,
|
|
||||||
.write = v4l2_write,
|
|
||||||
.open = v4l2_open,
|
|
||||||
.get_unmapped_area = v4l2_get_unmapped_area,
|
|
||||||
.mmap = v4l2_mmap,
|
|
||||||
.unlocked_ioctl = v4l2_unlocked_ioctl,
|
|
||||||
#ifdef CONFIG_COMPAT
|
|
||||||
.compat_ioctl = v4l2_compat_ioctl32,
|
|
||||||
#endif
|
|
||||||
.release = v4l2_release,
|
|
||||||
.poll = v4l2_poll,
|
|
||||||
.llseek = no_llseek,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct file_operations v4l2_fops = {
|
static const struct file_operations v4l2_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.read = v4l2_read,
|
.read = v4l2_read,
|
||||||
|
@ -330,7 +311,7 @@ static const struct file_operations v4l2_fops = {
|
||||||
.open = v4l2_open,
|
.open = v4l2_open,
|
||||||
.get_unmapped_area = v4l2_get_unmapped_area,
|
.get_unmapped_area = v4l2_get_unmapped_area,
|
||||||
.mmap = v4l2_mmap,
|
.mmap = v4l2_mmap,
|
||||||
.ioctl = v4l2_ioctl,
|
.unlocked_ioctl = v4l2_ioctl,
|
||||||
#ifdef CONFIG_COMPAT
|
#ifdef CONFIG_COMPAT
|
||||||
.compat_ioctl = v4l2_compat_ioctl32,
|
.compat_ioctl = v4l2_compat_ioctl32,
|
||||||
#endif
|
#endif
|
||||||
|
@ -521,9 +502,6 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (vdev->fops->unlocked_ioctl)
|
|
||||||
vdev->cdev->ops = &v4l2_unlocked_fops;
|
|
||||||
else
|
|
||||||
vdev->cdev->ops = &v4l2_fops;
|
vdev->cdev->ops = &v4l2_fops;
|
||||||
vdev->cdev->owner = vdev->fops->owner;
|
vdev->cdev->owner = vdev->fops->owner;
|
||||||
ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1);
|
ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1);
|
||||||
|
|
Loading…
Reference in a new issue