Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 366759
b: refs/heads/master
c: 6cd247e
h: refs/heads/master
i:
  366757: 0a9ab67
  366755: 762de09
  366751: 671a3cc
v: v3
  • Loading branch information
Andy Walls authored and Mauro Carvalho Chehab committed Mar 24, 2013
1 parent aa8e189 commit 1420def
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 842059aa4796d7c59bc3801d48896ba06b1a1287
refs/heads/master: 6cd247ef22e493e1884e576c066661538b031981
8 changes: 5 additions & 3 deletions trunk/drivers/media/v4l2-core/v4l2-ctrls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
29 changes: 26 additions & 3 deletions trunk/include/media/v4l2-ctrls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 1420def

Please sign in to comment.