Re: [PATCH 1/2] klist: implement KLIST_INIT() and DEFINE_KLIST()

From: Peter Zijlstra
Date: Tue Apr 22 2008 - 08:58:14 EST


On Tue, 2008-04-22 at 18:57 +0900, Tejun Heo wrote:
> klist is missing static initializers and definition helper. Add them.
>
> Signed-off-by: Tejun Heo <htejun@xxxxxxxxx>
> ---
> I can't tell who's in charge of this code, so I'm including last two
> people who made changes and Andrew :-) This will be used by later USB
> mode switch support, so I'm cc'ing USB people too.
>
> Thanks.
>
> include/linux/klist.h | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/klist.h b/include/linux/klist.h
> index 7407125..c6b697c 100644
> --- a/include/linux/klist.h
> +++ b/include/linux/klist.h
> @@ -25,6 +25,14 @@ struct klist {
> void (*put)(struct klist_node *);
> };
>
> +#define KLIST_INIT(_name, _get, _put) \
> + { .k_lock = __SPIN_LOCK_UNLOCKED(klist.k_lock), \

May I ask you make that: __SPIN_LOCK_UNLOCKED(_name.k_lock)

Otherwise we'll end up with multiple classes that have the same name.

> + .k_list = LIST_HEAD_INIT(_name.k_list), \
> + .get = _get, \
> + .put = _put, }
> +
> +#define DEFINE_KLIST(_name, _get, _put) \
> + struct klist _name = KLIST_INIT(_name, _get, _put)
>
> extern void klist_init(struct klist * k, void (*get)(struct klist_node *),
> void (*put)(struct klist_node *));

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/