From: Sakari Ailus <sakari.ai...@linux.intel.com>

Commonly the control mutex is shared with the rest of the driver, which
already holds the mutex when accessing the control framework. Add
unlocked v4l2_grab_ctrl(), __v4l2_grab_ctrl() for this purpose.

Signed-off-by: Sakari Ailus <sakari.ai...@linux.intel.com>
---
 drivers/media/v4l2-core/v4l2-ctrls.c |    6 ++----
 include/media/v4l2-ctrls.h           |   13 ++++++++++++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 45c5b47..a80bc9f 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -2344,14 +2344,13 @@ EXPORT_SYMBOL(v4l2_ctrl_activate);
 
    Just call this and the framework will block any attempts to change
    these controls. */
-void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed)
+void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed)
 {
        bool old;
 
        if (ctrl == NULL)
                return;
 
-       v4l2_ctrl_lock(ctrl);
        if (grabbed)
                /* set V4L2_CTRL_FLAG_GRABBED */
                old = test_and_set_bit(1, &ctrl->flags);
@@ -2360,9 +2359,8 @@ void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed)
                old = test_and_clear_bit(1, &ctrl->flags);
        if (old != grabbed)
                send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS);
-       v4l2_ctrl_unlock(ctrl);
 }
-EXPORT_SYMBOL(v4l2_ctrl_grab);
+EXPORT_SYMBOL(__v4l2_ctrl_grab);
 
 /* Log the control name and value */
 static void log_ctrl(const struct v4l2_ctrl *ctrl,
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 911f3e5..b50d1dd 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -607,6 +607,9 @@ struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler 
*hdl, u32 id);
   */
 void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
 
+/** __v4l2_ctrl_grab() - Unlocked variant of v4l2_ctrl_grab() */
+void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
+
 /** v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
   * @ctrl:     The control to (de)activate.
   * @grabbed:  True if the control should become grabbed.
@@ -620,7 +623,15 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool 
active);
   * This function assumes that the control handler is not locked and will
   * take the lock itself.
   */
-void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
+static inline void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed)
+{
+       if (!ctrl)
+               return;
+
+       v4l2_ctrl_lock(ctrl);
+       __v4l2_ctrl_grab(ctrl, grabbed);
+       v4l2_ctrl_unlock(ctrl);
+}
 
 
 /** __v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range() 
*/
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to