From patchwork Sun Oct 7 00:07:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [U-Boot,4/6] serial: Reorder get_current() Date: Sat, 06 Oct 2012 14:07:04 -0000 From: Marek Vasut X-Patchwork-Id: 189776 Message-Id: <1349568426-27219-5-git-send-email-marex@denx.de> To: u-boot@lists.denx.de Cc: Marek Vasut , Tom Rini Reorder the get_current() function to make it a bit more readable. The code does not grow and there is minor change in the code logic, where dev != NULL is now checked in any case. Signed-off-by: Marek Vasut Cc: Marek Vasut Cc: Tom Rini --- drivers/serial/serial.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 1054494..57e3b75 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -225,20 +225,23 @@ static struct serial_device *get_current(void) { struct serial_device *dev; - if (!(gd->flags & GD_FLG_RELOC) || !serial_current) { + if (!(gd->flags & GD_FLG_RELOC)) dev = default_serial_console(); + else if (!serial_current) + dev = default_serial_console(); + else + dev = serial_current; - /* We must have a console device */ - if (!dev) { + /* We must have a console device */ + if (!dev) { #ifdef CONFIG_SPL_BUILD - puts("Cannot find console\n"); - hang(); + puts("Cannot find console\n"); + hang(); #else - panic("Cannot find console\n"); + panic("Cannot find console\n"); #endif - } - } else - dev = serial_current; + } + return dev; }