Re: [PATCH] correct attribute_container list usage

Patrick Mansfield
2005-08-22T21:46:22Z

On Mon, Aug 22, 2005 at 10:06:19AM -0500, James Bottomley wrote:

> +/* FIXME: can't break out of this unless klist_iter_exit is also
> + * called before doing the break
> + */
> +#define klist_for_each_entry(pos, head, member, iter) \
> + for (klist_iter_init(head, iter); (pos = ({ \
> + struct klist_node *n = klist_next(iter); \
> + n ? ({ klist_iter_exit(iter) ; NULL; }) : \
> + container_of(n, typeof(*pos), member);\
> + }) ) != NULL; )
> +
> +

> - spin_lock(&cont->containers_lock);
> - list_for_each_entry_safe(ic, tmp, &cont->containers, node) {
> +
> + klist_for_each_entry(ic, &cont->containers, node, &iter) {
> if (dev != ic->classdev.dev)
> continue;
> - list_del(&ic->node);
> + klist_remove(&ic->node);
> if (fn)
> fn(cont, dev, &ic->classdev);

Did you test with CONFIG_DEBUG_SLAB enabled?

I have a workaround for problems with device_for_each_child() not being
"safe", I'm trying to verify it right now, but the underlying problem is
in klist_next(), I don't have a general solution for it (it looks hard to
fix).

-- Patrick Mansfield