diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2011-06-07 11:40:04 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-28 00:53:16 +0400 |
commit | 37cd3b73683f15f1b6313d0de476726aa0942a75 (patch) | |
tree | c947c202742fb4e86434e3231f12b929120e5c88 /drivers/media/video/v4l2-ctrls.c | |
parent | 54c911eb919b44b178bda67564f274197872bd04 (diff) | |
download | linux-37cd3b73683f15f1b6313d0de476726aa0942a75.tar.xz |
[media] v4l2-ctrls: simplify error_idx handling
The lower-level prepare functions just set error_idx for each control that
might have an error. The high-level functions will override this with
cs->count in the get and set cases. Only try will keep the error_idx.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l2-ctrls.c')
-rw-r--r-- | drivers/media/video/v4l2-ctrls.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 3f2a0c5a1c3a..d9e04394c856 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -1450,8 +1450,7 @@ EXPORT_SYMBOL(v4l2_subdev_querymenu); Find the controls in the control array and do some basic checks. */ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs, - struct ctrl_helper *helpers, - bool try) + struct ctrl_helper *helpers) { u32 i; @@ -1460,8 +1459,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ctrl *ctrl; u32 id = c->id & V4L2_CTRL_ID_MASK; - if (try) - cs->error_idx = i; + cs->error_idx = i; if (cs->ctrl_class && V4L2_CTRL_ID2CLASS(id) != cs->ctrl_class) return -EINVAL; @@ -1554,7 +1552,8 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs return -ENOMEM; } - ret = prepare_ext_ctrls(hdl, cs, helpers, false); + ret = prepare_ext_ctrls(hdl, cs, helpers); + cs->error_idx = cs->count; for (i = 0; !ret && i < cs->count; i++) if (helpers[i].ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) @@ -1701,12 +1700,10 @@ static int try_or_set_ext_ctrls(struct v4l2_ctrl_handler *hdl, unsigned i, j; int ret = 0; - cs->error_idx = cs->count; for (i = 0; i < cs->count; i++) { struct v4l2_ctrl *ctrl = helpers[i].ctrl; - if (!set) - cs->error_idx = i; + cs->error_idx = i; if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) return -EACCES; @@ -1724,11 +1721,10 @@ static int try_or_set_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ctrl *ctrl = helpers[i].ctrl; struct v4l2_ctrl *master = ctrl->cluster[0]; - cs->error_idx = i; - if (helpers[i].handled) continue; + cs->error_idx = i; v4l2_ctrl_lock(ctrl); /* Reset the 'is_new' flags of the cluster */ @@ -1777,12 +1773,11 @@ static int try_set_ext_ctrls(struct v4l2_ctrl_handler *hdl, if (!helpers) return -ENOMEM; } - ret = prepare_ext_ctrls(hdl, cs, helpers, !set); - if (ret) - goto free; + ret = prepare_ext_ctrls(hdl, cs, helpers); /* First 'try' all controls and abort on error */ - ret = try_or_set_ext_ctrls(hdl, cs, helpers, false); + if (!ret) + ret = try_or_set_ext_ctrls(hdl, cs, helpers, false); /* If this is a 'set' operation and the initial 'try' failed, then set error_idx to count to tell the application that no controls changed value yet. */ @@ -1795,7 +1790,6 @@ static int try_set_ext_ctrls(struct v4l2_ctrl_handler *hdl, ret = try_or_set_ext_ctrls(hdl, cs, helpers, true); } -free: if (cs->count > ARRAY_SIZE(helper)) kfree(helpers); return ret; |