From 1420def4661ce67113f65fd4b7e739b480e5690c Mon Sep 17 00:00:00 2001 From: Andy Walls Date: Sat, 9 Mar 2013 05:55:11 -0300 Subject: [PATCH] --- yaml --- r: 366759 b: refs/heads/master c: 6cd247ef22e493e1884e576c066661538b031981 h: refs/heads/master i: 366757: 0a9ab67ed8b99e2f64e4e4205fe66b3c817ac57a 366755: 762de09af01d539ae6e6736c6f75912829604fe8 366751: 671a3ccfe59af9e0a89190a69795c6eaaef50dda v: v3 --- [refs] | 2 +- trunk/drivers/media/v4l2-core/v4l2-ctrls.c | 8 +++--- trunk/include/media/v4l2-ctrls.h | 29 +++++++++++++++++++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index 93d013ebf86b..f150264e4423 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 842059aa4796d7c59bc3801d48896ba06b1a1287 +refs/heads/master: 6cd247ef22e493e1884e576c066661538b031981 diff --git a/trunk/drivers/media/v4l2-core/v4l2-ctrls.c b/trunk/drivers/media/v4l2-core/v4l2-ctrls.c index 6b28b5800500..b36d1ec13ee6 100644 --- a/trunk/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/trunk/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1362,11 +1362,13 @@ static inline int handler_set_err(struct v4l2_ctrl_handler *hdl, int err) } /* Initialize the handler */ -int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler *hdl, - unsigned nr_of_controls_hint) +int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, + unsigned nr_of_controls_hint, + struct lock_class_key *key, const char *name) { hdl->lock = &hdl->_lock; mutex_init(hdl->lock); + lockdep_set_class_and_name(hdl->lock, key, name); INIT_LIST_HEAD(&hdl->ctrls); INIT_LIST_HEAD(&hdl->ctrl_refs); hdl->nr_of_buckets = 1 + nr_of_controls_hint / 8; @@ -1375,7 +1377,7 @@ int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler *hdl, hdl->error = hdl->buckets ? 0 : -ENOMEM; return hdl->error; } -EXPORT_SYMBOL(v4l2_ctrl_handler_init); +EXPORT_SYMBOL(v4l2_ctrl_handler_init_class); /* Free all controls and control refs */ void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) diff --git a/trunk/include/media/v4l2-ctrls.h b/trunk/include/media/v4l2-ctrls.h index f00d42bc01a6..7343a27fe819 100644 --- a/trunk/include/media/v4l2-ctrls.h +++ b/trunk/include/media/v4l2-ctrls.h @@ -259,7 +259,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags); -/** v4l2_ctrl_handler_init() - Initialize the control handler. +/** v4l2_ctrl_handler_init_class() - Initialize the control handler. * @hdl: The control handler. * @nr_of_controls_hint: A hint of how many controls this handler is * expected to refer to. This is the total number, so including @@ -268,12 +268,35 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, * are allocated) or the control lookup becomes slower (not enough * buckets are allocated, so there are more slow list lookups). * It will always work, though. + * @key: Used by the lock validator if CONFIG_LOCKDEP is set. + * @name: Used by the lock validator if CONFIG_LOCKDEP is set. * * Returns an error if the buckets could not be allocated. This error will * also be stored in @hdl->error. + * + * Never use this call directly, always use the v4l2_ctrl_handler_init + * macro that hides the @key and @name arguments. */ -int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler *hdl, - unsigned nr_of_controls_hint); +int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, + unsigned nr_of_controls_hint, + struct lock_class_key *key, const char *name); + +#ifdef CONFIG_LOCKDEP +#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \ +( \ + ({ \ + static struct lock_class_key _key; \ + v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, \ + &_key, \ + KBUILD_BASENAME ":" \ + __stringify(__LINE__) ":" \ + "(" #hdl ")->_lock"); \ + }) \ +) +#else +#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \ + v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL) +#endif /** v4l2_ctrl_handler_free() - Free all controls owned by the handler and free * the control list.