serial: Reorder get_current()
authorMarek Vasut <marex@denx.de>
Sat, 6 Oct 2012 14:07:04 +0000 (14:07 +0000)
committerTom Rini <trini@ti.com>
Wed, 17 Oct 2012 14:55:51 +0000 (07:55 -0700)
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 <marex@denx.de>
Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Tom Rini <trini@ti.com>
drivers/serial/serial.c

index 3ab323bcb884070cf21b9d24272cf06bee03e36c..18b9ed4330f6449958e3e0fbf01b63f0b2d2e6bf 100644 (file)
@@ -227,20 +227,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;
 }