> Date: Fri, 8 Apr 2016 20:26:14 +0200
> From: Patrick Wildt <[email protected]>
> 
> +void
> +mainbus_iterate(struct device *self, struct device *match, int node)
> +{
> +     for (;
> +         node != 0;
> +         node = OF_peer(node))
> +     {
> +             /* skip nodes that are already handled by some driver */
> +             if (!mainbus_is_attached(node))
> +                     mainbus_attach_node(self, match, node);
> +
> +             mainbus_iterate(self, match, OF_child(node));
> +     }
> +}

Sorry, but this really is wrong.  You're completely ignoring the tree
aspect if the FDT.  That is not going to work for more complex designs
with i2c busses or pci busses.  And it is going to be essential if you
want to support suspend/resume.

The autoconf framework is really quite clever and flexible.  It is
possible to re-use glue code quite easily.  As files.conf(5)
documents, device don't directly attach to parents, but to attributes.
You can re-use those attributes, and parents can define multiple
attributes.

You could for example define a generic fdt attribute.  Simple devices
can then attach directly to that attribute.  And you could also have
some soc-specific attributes, that you then use to attach devices that
need some additional glue.

It'll take a bit of time to figure out the best way to define your
attributes.  But the end result will be worth it.  And don't be afraid
to make mistakes.  As long as you drivers use the same "attach_args"
structure, we can move around attributes without the need to change
the code.  So it will be easy to adjust the design as we learn more.

Cheers,

Mark

Reply via email to