On Fri, Apr 08, 2016 at 09:38:25PM +0200, Mark Kettenis wrote: > > Date: Fri, 8 Apr 2016 20:26:14 +0200 > > From: Patrick Wildt <patr...@blueri.se> > > > > +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.
Fully agreed. I am aware of the limitations of the approach taken in this diff and also agree that this does not scale well. > > 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. Thank you for the input. I will try to gather more information about the autoconf framework with those attributes in mind. I will come up with something better once I have understood that and came up with a better design and implementation. Thanks, Patrick > > Cheers, > > Mark >