> Date: Sun, 10 Apr 2016 20:49:48 +0200
> From: Patrick Wildt <[email protected]>
>
> > > /*
> > > - * void mainbusattach(struct device *parent, struct device *self, void
> > > *aux)
> > > + * Usually you should be able to attach devices in the order
> > > + * specified in the device tree. Due to how a few drivers
> > > + * are written we need to make sure we attach them in the
> > > + * order stated in files.xxx.
> >
> > Isn't it actually the order they're listed in the kernel config file
> > that determines the order?
>
> I thought it would work like that, too, but the order of cfdata[] seems
> to be decided by the order of appearance in files.conf.
Right...
> > > *
> > > - * probe and attach all children
> > > + * This means for every driver enabled, we go through the
> > > + * FDT and look for compatible nodes.
> > > */
> >
> > Is this just a temporary thing until the drivers are changed such that
> > they can be attached in tree order?
>
> In this case it's meant only as temporary thing. I think maybe we
> should make a decision about how we want to approach this. We can
> either say we'll do it right from the beginning and attach it like
> it's sorted in the tree. This means that the first platform to be
> supported has to support the correct way right away. Which forces
> us to work on doing it correctly from the start. The other way is
> to start with this temporary solution.
>
> Thinking about it, maybe it's better to not do it like in this diff.
> That would also make the code look a lot better and remove all that
> SLIST cruft.
>
> What do you think?
Not sure how much work it is to do it "right". But if it isn't too
much of an issue, that's probably the way to go.
> > > +/* Passed as third arg to attach functions. */
> > > +struct simplebus_attach_args {
> > > + const char *sa_name;
> > > + int sa_node;
> > > + bus_space_tag_t sa_iot;
> > > + bus_dma_tag_t sa_dmat;
> > > +};
> >
> > Since mainbus and simplebus both use the same attach_args structure.
>
> Should I create some fdt.h that defines fdt_attach_args, or should
> I just use mainbus_attach_args in every driver?
fdt_attach_args sounds like a better idea. Perhaps
mainbus_attach_args should become a union:
union mainbus_attach_args {
const char *ma_name;
struct fdt_attach_args ma_faa;
};
That way you don't have to change all the legacy drivers.