diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2016-02-29 07:16:39 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-04-13 16:43:27 -0300 |
commit | 54ace1cfd4358fd11112f17cc711eea234d5ab9e (patch) | |
tree | 08518c4ee0bf6460ed31881df5c2aeccb387a7b8 /drivers/media/v4l2-core | |
parent | 9765a32cd802709d152a0d73d0cbfd07c9f49808 (diff) | |
download | linux-54ace1cfd4358fd11112f17cc711eea234d5ab9e.tar.gz linux-54ace1cfd4358fd11112f17cc711eea234d5ab9e.tar.bz2 linux-54ace1cfd4358fd11112f17cc711eea234d5ab9e.zip |
[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: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ioctl.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 6bf5a3ecd126..3cf8d3adab03 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -2160,33 +2160,40 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { struct v4l2_cropcap *p = arg; + struct v4l2_selection s = { .type = p->type }; + int ret; - if (ops->vidioc_g_selection) { - struct v4l2_selection s = { .type = p->type }; - 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 */ - if (V4L2_TYPE_IS_OUTPUT(p->type)) - s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS; - else - s.target = V4L2_SEL_TGT_CROP_BOUNDS; + /* obtaining bounds */ + if (V4L2_TYPE_IS_OUTPUT(p->type)) + s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS; + else + s.target = V4L2_SEL_TGT_CROP_BOUNDS; - ret = ops->vidioc_g_selection(file, fh, &s); - if (ret) - return ret; - p->bounds = s.r; + ret = ops->vidioc_g_selection(file, fh, &s); + if (ret) + return ret; + p->bounds = s.r; - /* obtaining defrect */ - if (V4L2_TYPE_IS_OUTPUT(p->type)) - s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT; - else - s.target = V4L2_SEL_TGT_CROP_DEFAULT; + /* obtaining defrect */ + if (V4L2_TYPE_IS_OUTPUT(p->type)) + s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT; + else + s.target = V4L2_SEL_TGT_CROP_DEFAULT; - ret = ops->vidioc_g_selection(file, fh, &s); - if (ret) - return ret; - p->defrect = s.r; - } + ret = ops->vidioc_g_selection(file, fh, &s); + if (ret) + return ret; + p->defrect = s.r; /* setting trivial pixelaspect */ p->pixelaspect.numerator = 1; |