dm: serial: Correct logic in serial_find_console_or_panic()
authorSimon Glass <sjg@chromium.org>
Fri, 31 Jul 2015 15:31:20 +0000 (09:31 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 5 Aug 2015 14:42:40 +0000 (08:42 -0600)
In a final attempt to find a console UART this function uses the first
first available serial device. However the check for a valid device is
inverted.

This code is only executed when there is in fact no serial UART, but at
present it can fail to reach the panic_str() call in this case, and start
trying to use a non-existent UART.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/serial/serial-uclass.c

index 815fec32646924c2c8000cbb25798cd6b227460a..bbc366b32283d9b29320a714063705de934c8db6 100644 (file)
@@ -71,7 +71,7 @@ static void serial_find_console_or_panic(void)
 #endif
                if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) ||
                    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev) ||
-                   (!uclass_first_device(UCLASS_SERIAL, &dev) || dev)) {
+                   (!uclass_first_device(UCLASS_SERIAL, &dev) && dev)) {
                        gd->cur_serial_dev = dev;
                        return;
                }