Commit cc0140e2 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] v4l2-ctrls.c: Implement unlocked variant of v4l2_ctrl_handler_setup()

Sometimes the caller is already holding the control handler mutex and
using it to serialise something. Provide an unlocked variant of the same
function to be used in those cases.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent ec62c9a5
...@@ -2444,14 +2444,16 @@ int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd) ...@@ -2444,14 +2444,16 @@ int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd)
EXPORT_SYMBOL(v4l2_ctrl_subdev_log_status); EXPORT_SYMBOL(v4l2_ctrl_subdev_log_status);
/* Call s_ctrl for all controls owned by the handler */ /* Call s_ctrl for all controls owned by the handler */
int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
{ {
struct v4l2_ctrl *ctrl; struct v4l2_ctrl *ctrl;
int ret = 0; int ret = 0;
if (hdl == NULL) if (hdl == NULL)
return 0; return 0;
mutex_lock(hdl->lock);
lockdep_assert_held(hdl->lock);
list_for_each_entry(ctrl, &hdl->ctrls, node) list_for_each_entry(ctrl, &hdl->ctrls, node)
ctrl->done = false; ctrl->done = false;
...@@ -2476,7 +2478,22 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) ...@@ -2476,7 +2478,22 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
if (ret) if (ret)
break; break;
} }
return ret;
}
EXPORT_SYMBOL_GPL(__v4l2_ctrl_handler_setup);
int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
{
int ret;
if (hdl == NULL)
return 0;
mutex_lock(hdl->lock);
ret = __v4l2_ctrl_handler_setup(hdl);
mutex_unlock(hdl->lock); mutex_unlock(hdl->lock);
return ret; return ret;
} }
EXPORT_SYMBOL(v4l2_ctrl_handler_setup); EXPORT_SYMBOL(v4l2_ctrl_handler_setup);
......
...@@ -457,6 +457,19 @@ static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl) ...@@ -457,6 +457,19 @@ static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
mutex_unlock(ctrl->handler->lock); mutex_unlock(ctrl->handler->lock);
} }
/**
* __v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
* to the handler to initialize the hardware to the current control values. The
* caller is responsible for acquiring the control handler mutex on behalf of
* __v4l2_ctrl_handler_setup().
* @hdl: The control handler.
*
* Button controls will be skipped, as are read-only controls.
*
* If @hdl == NULL, then this just returns 0.
*/
int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
/** /**
* v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging * v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
* to the handler to initialize the hardware to the current control values. * to the handler to initialize the hardware to the current control values.
......
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