diff mbox

[U-Boot,v2,03/47] dm: serial: Correct logic in serial_find_console_or_panic()

Message ID 1438356724-6561-4-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass July 31, 2015, 3:31 p.m. UTC
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>
---

Changes in v2: None

 drivers/serial/serial-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass Aug. 2, 2015, 11:37 p.m. UTC | #1
On 31 July 2015 at 09:31, Simon Glass <sjg@chromium.org> wrote:
> 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>
> ---
>
> Changes in v2: None
>
>  drivers/serial/serial-uclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index 815fec3..bbc366b 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;
>                 }
> --
> 2.5.0.rc2.392.g76e840b
>

Applied to u-boot-x86.
diff mbox

Patch

diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 815fec3..bbc366b 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;
 		}