From: Simon Glass Date: Fri, 31 Jul 2015 15:31:20 +0000 (-0600) Subject: dm: serial: Correct logic in serial_find_console_or_panic() X-Git-Tag: v2015.10-rc2~410^2~55 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=753812cb2eccf18f0f1537fd1a5dd9659b60a505;p=oweals%2Fu-boot.git dm: serial: Correct logic in serial_find_console_or_panic() 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 Reviewed-by: Bin Meng --- diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 815fec3264..bbc366b322 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -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; }