Skip to content

Commit

Permalink
V4L/DVB: video_ioctl2: handle the v4l1 compat bit first and move VIDI…
Browse files Browse the repository at this point in the history
…OCGMBUF into the switch

Try to make a more sensible sequence of events in __video_do_ioctl: first
check for a valid ops pointer, then get the compat part done. The VIDIOCGMBUF
command is now part of the big switch.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed May 19, 2010
1 parent dd1ad94 commit 6a71788
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions drivers/media/video/v4l2-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,17 +610,33 @@ static long __video_do_ioctl(struct file *file,
void *fh = file->private_data;
long ret = -EINVAL;

if (ops == NULL) {
printk(KERN_WARNING "videodev: \"%s\" has no ioctl_ops.\n",
vfd->name);
return -EINVAL;
}

#ifdef CONFIG_VIDEO_V4L1_COMPAT
/********************************************************
All other V4L1 calls are handled by v4l1_compat module.
Those calls will be translated into V4L2 calls, and
__video_do_ioctl will be called again, with one or more
V4L2 ioctls.
********************************************************/
if (_IOC_TYPE(cmd) == 'v' && cmd != VIDIOCGMBUF &&
_IOC_NR(cmd) < BASE_VIDIOCPRIVATE) {
return v4l_compat_translate_ioctl(file, cmd, arg,
__video_do_ioctl);
}
#endif

if ((vfd->debug & V4L2_DEBUG_IOCTL) &&
!(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
v4l_print_ioctl(vfd->name, cmd);
printk(KERN_CONT "\n");
}

if (ops == NULL) {
printk(KERN_WARNING "videodev: \"%s\" has no ioctl_ops.\n",
vfd->name);
return -EINVAL;
}
switch (cmd) {

#ifdef CONFIG_VIDEO_V4L1_COMPAT
/***********************************************************
Expand All @@ -630,31 +646,21 @@ static long __video_do_ioctl(struct file *file,
***********************************************************/

/* --- streaming capture ------------------------------------- */
if (cmd == VIDIOCGMBUF) {
case VIDIOCGMBUF:
{
struct video_mbuf *p = arg;

if (!ops->vidiocgmbuf)
return ret;
break;
ret = ops->vidiocgmbuf(file, fh, p);
if (!ret)
dbgarg(cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
p->size, p->frames,
(unsigned long)p->offsets);
return ret;
break;
}

/********************************************************
All other V4L1 calls are handled by v4l1_compat module.
Those calls will be translated into V4L2 calls, and
__video_do_ioctl will be called again, with one or more
V4L2 ioctls.
********************************************************/
if (_IOC_TYPE(cmd) == 'v' && _IOC_NR(cmd) < BASE_VIDIOCPRIVATE)
return v4l_compat_translate_ioctl(file, cmd, arg,
__video_do_ioctl);
#endif

switch (cmd) {
/* --- capabilities ------------------------------------------ */
case VIDIOC_QUERYCAP:
{
Expand Down

0 comments on commit 6a71788

Please sign in to comment.