From 5a573925159aeec1dd159627d849dc6c66000faf Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Thu, 12 Jun 2014 13:09:40 -0300 Subject: [media] v4l: ctrls: Provide an unlocked variant of v4l2_ctrl_modify_range() Drivers may use the v4l2_ctrl_modify_range() internally as part of other operations that need to be both serialised using a driver's lock which can also be used to serialise access to the control handler. Provide an unlocked version of the function, __v4l2_ctrl_modify_range() which then may be used by drivers for the purpose. Signed-off-by: Sakari Ailus Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-ctrls.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'include/media/v4l2-ctrls.h') diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 4546233a9a3d..5d1a30ca29af 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -620,6 +620,11 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active); */ void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); + +/** __v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range() */ +int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, + s64 min, s64 max, u64 step, s64 def); + /** v4l2_ctrl_modify_range() - Update the range of a control. * @ctrl: The control to update. * @min: The control's minimum value. @@ -637,8 +642,17 @@ void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); * This function assumes that the control handler is not locked and will * take the lock itself. */ -int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, - s64 min, s64 max, u64 step, s64 def); +static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, + s64 min, s64 max, u64 step, s64 def) +{ + int rval; + + v4l2_ctrl_lock(ctrl); + rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def); + v4l2_ctrl_unlock(ctrl); + + return rval; +} /** v4l2_ctrl_notify() - Function to set a notify callback for a control. * @ctrl: The control. -- cgit v1.2.1