From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Tue, 18 Sep 2012 19:57:59 +0200 Subject: [U-Boot] [PATCH 08/71] serial: Implement serial_initfunc() macro In-Reply-To: <20120918173134.GK14937@bill-the-cat> References: <1347837696-3192-1-git-send-email-marex@denx.de> <1347837696-3192-9-git-send-email-marex@denx.de> <20120918173134.GK14937@bill-the-cat> Message-ID: <201209181957.59250.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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