[U-Boot] [PATCH 08/71] serial: Implement serial_initfunc() macro

Marek Vasut marex at denx.de
Tue Sep 18 19:57:59 CEST 2012


Dear Tom Rini,

> On Mon, Sep 17, 2012 at 01:20:33AM +0200, Marek Vasut wrote:
> > This macro simplifies declaration of weak aliases for per-driver
> > functions, which register these drivers with the serial subsystem.
> > The idea here is to push serial_register() calls from serial.c into
> > the drivers. To avoid pile of ifdef construct as it is now, create
> > weak aliases to these functions, which in case the driver is not
> > present alias onto an empty function, which is in turn optimized out
> > altogether.
> 
> So, did you consider and throw out the idea of something like:
> common/serial.c:
> void serial_initalize(void) {
>   platform_serial_register();
>   serial_assign(default_serial_console()->name);
> }
> 
> And then every serial driver, instead of having to add a new weak
> function to common/serial.c and a new function call just defines
> platform_serial_register.

Yes

> Or do you run into platforms that want two different serial drivers AND
> you couldn't solve that with a combination of weak functions and
> board-specific platform_serial_register?

The point is to allow compiling in any possible combination of serial drivers, 
thus the per-driver separate init call. I'd like to get rid of this once the DM 
is present, since there'll be a method of generating the driver list 
automagically, thus dissolving this all.

So this is pretty much temporary. Yet, you are right, there are a few boards 
(really minor amount, some PPC ancient goo) that do need two drivers in.

Best regards,
Marek Vasut


More information about the U-Boot mailing list