All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: goldfish: return error when device address is invalid
@ 2026-06-07 15:45 Naveen Kumar Chaudhary
  2026-06-08 15:26 ` Kuan-Wei Chiu
  0 siblings, 1 reply; 2+ messages in thread
From: Naveen Kumar Chaudhary @ 2026-06-07 15:45 UTC (permalink / raw)
  To: visitorckw, trini; +Cc: u-boot

goldfish_serial_of_to_plat() returns success even when dev_read_addr()
fails to find a valid address. This leaves plat->reg unset and defers
the failure to probe().

Return -EINVAL immediately when the address is FDT_ADDR_T_NONE so the
failure is reported at the of_to_plat stage where it belongs.

Signed-off-by: Naveen Kumar Chaudhary <naveen.osdev@gmail.com>
---
 drivers/serial/serial_goldfish.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_goldfish.c b/drivers/serial/serial_goldfish.c
index 91dc040fcf2..732f167caae 100644
--- a/drivers/serial/serial_goldfish.c
+++ b/drivers/serial/serial_goldfish.c
@@ -74,8 +74,10 @@ static int goldfish_serial_of_to_plat(struct udevice *dev)
 	fdt_addr_t addr;
 
 	addr = dev_read_addr(dev);
-	if (addr != FDT_ADDR_T_NONE)
-		plat->reg = addr;
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	plat->reg = addr;
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] serial: goldfish: return error when device address is invalid
  2026-06-07 15:45 [PATCH] serial: goldfish: return error when device address is invalid Naveen Kumar Chaudhary
@ 2026-06-08 15:26 ` Kuan-Wei Chiu
  0 siblings, 0 replies; 2+ messages in thread
From: Kuan-Wei Chiu @ 2026-06-08 15:26 UTC (permalink / raw)
  To: Naveen Kumar Chaudhary; +Cc: trini, u-boot

On Sun, Jun 07, 2026 at 09:15:42PM +0530, Naveen Kumar Chaudhary wrote:
> goldfish_serial_of_to_plat() returns success even when dev_read_addr()
> fails to find a valid address. This leaves plat->reg unset and defers
> the failure to probe().
> 
> Return -EINVAL immediately when the address is FDT_ADDR_T_NONE so the
> failure is reported at the of_to_plat stage where it belongs.
> 
> Signed-off-by: Naveen Kumar Chaudhary <naveen.osdev@gmail.com>

Acked-by: Kuan-Wei Chiu <visitorckw@gmail.com>

Thanks for the patch.

When I originally wrote this code, I assumed of_to_plat() would always
be called by the driver core regardless of the instantiation method.
After double-checking how the m68k virt instantiates the driver, I
realize it actually bypasses this function. Furthermore, there are
currently no in-tree users passing a device tree to this driver anyway.

Regards,
Kuan-Wei

> ---
>  drivers/serial/serial_goldfish.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/serial/serial_goldfish.c b/drivers/serial/serial_goldfish.c
> index 91dc040fcf2..732f167caae 100644
> --- a/drivers/serial/serial_goldfish.c
> +++ b/drivers/serial/serial_goldfish.c
> @@ -74,8 +74,10 @@ static int goldfish_serial_of_to_plat(struct udevice *dev)
>  	fdt_addr_t addr;
>  
>  	addr = dev_read_addr(dev);
> -	if (addr != FDT_ADDR_T_NONE)
> -		plat->reg = addr;
> +	if (addr == FDT_ADDR_T_NONE)
> +		return -EINVAL;
> +
> +	plat->reg = addr;
>  
>  	return 0;
>  }
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-08 15:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-07 15:45 [PATCH] serial: goldfish: return error when device address is invalid Naveen Kumar Chaudhary
2026-06-08 15:26 ` Kuan-Wei Chiu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.