Commit 54ace1cf authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] v4l2-ioctl: simplify code

Instead of a big if at the beginning, just check if g_selection == NULL
and call the cropcap op immediately and return the result.

No functional changes in this patch.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 9765a32c
...@@ -2160,11 +2160,19 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, ...@@ -2160,11 +2160,19 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg) struct file *file, void *fh, void *arg)
{ {
struct v4l2_cropcap *p = arg; struct v4l2_cropcap *p = arg;
if (ops->vidioc_g_selection) {
struct v4l2_selection s = { .type = p->type }; struct v4l2_selection s = { .type = p->type };
int ret; int ret;
if (ops->vidioc_g_selection == NULL) {
/*
* The determine_valid_ioctls() call already should ensure
* that ops->vidioc_cropcap != NULL, but just in case...
*/
if (ops->vidioc_cropcap)
return ops->vidioc_cropcap(file, fh, p);
return -ENOTTY;
}
/* obtaining bounds */ /* obtaining bounds */
if (V4L2_TYPE_IS_OUTPUT(p->type)) if (V4L2_TYPE_IS_OUTPUT(p->type))
s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS; s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS;
...@@ -2186,7 +2194,6 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, ...@@ -2186,7 +2194,6 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops,
if (ret) if (ret)
return ret; return ret;
p->defrect = s.r; p->defrect = s.r;
}
/* setting trivial pixelaspect */ /* setting trivial pixelaspect */
p->pixelaspect.numerator = 1; p->pixelaspect.numerator = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment