On Fri, Jul 13, 2018 at 1:15 PM Ulf Hansson <ulf.hansson@xxxxxxxxxx> wrote: > To be able to better support different mmci variants, we need to be able to > use variant specific callbacks, rather than continue to sprinkle the code > with additional variant data. To move in this direction, let's add an > optional ->init() callback to the variant data struct, which variants shall > use to assign the mmci_host_ops pointer. > > Using an ->init() callback enables us to partition the code between > different files. To allow separate mmci variant files to implement the > variant specifics, let's also move the definition of the struct > variant_data to the common mmci header file. > > Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx> Good idea! > + if (variant->init) > + variant->init(host); (...) > +struct variant_data { (...) > + void (*init)(struct mmci_host *host); > +}; > + > +/* mmci variant callbacks */ > +struct mmci_host_ops { > +}; Why not have the .init() callback inside the struct mmci_host_ops vtable? If you think it's hairy to dereference twice like mmci->variant->ops(foo) you can always copy the pointer mmci->ops = variant->ops and be done with it. It's easy to just assign it directly in the variant data that way: variant_foo = { (...) .ops = { .init = ... Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html