Re: device_for_each_child() before device_add() doesn't work

From: David Vrabel
Date: Wed Apr 15 2009 - 10:52:28 EST


Greg KH wrote:
>
> So the problem is for the first device being added, right? Can't you
> just have a flag for this?

It's trivial to fix in the UWB stack.

>> This address must be assigned during initialization and during normal
>> operation and in the past we didn't need to special case the address
>> assignment during initialization.
>
> Does the patch below fix the problem for you?

Yes.

> drivers/base/core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -1142,6 +1142,9 @@ int device_for_each_child(struct device
> struct device *child;
> int error = 0;
>
> + if (!parent->p)
> + return 0;
> +
> klist_iter_init(&parent->p->klist_children, &i);
> while ((child = next_device(&i)) && !error)
> error = fn(child, data);
>
>

David
--
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park, Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/
--
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/