All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/boot: Simplify serial console control flow
@ 2026-09-14 10:41 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-09-14 10:41 UTC (permalink / raw)
  To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Ritesh Harjani (IBM),
	Shrikanth Hegde, Thorsten Blum
  Cc: linuxppc-dev, linux-kernel

In serial_get_stdout_devp() and serial_console_init(), remove the goto
statements and return NULL and rc directly.

In serial_console_init(), handle errors early to reduce indentation.

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 arch/powerpc/boot/serial.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
index 1d221ff420fd..f46943c21a22 100644
--- a/arch/powerpc/boot/serial.c
+++ b/arch/powerpc/boot/serial.c
@@ -87,19 +87,18 @@ static void *serial_get_stdout_devp(void)
 
 	devp = finddevice("/chosen");
 	if (devp == NULL)
-		goto err_out;
+		return NULL;
 
 	if (getprop(devp, "linux,stdout-path", path, MAX_PATH_LEN) > 0 ||
 		getprop(devp, "stdout-path", path, MAX_PATH_LEN) > 0) {
 		devp = finddevice(path);
 		if (devp == NULL)
-			goto err_out;
+			return NULL;
 
 		if ((getprop(devp, "device_type", devtype, sizeof(devtype)) > 0)
 				&& !strcmp(devtype, "serial"))
 			return devp;
 	}
-err_out:
 	return NULL;
 }
 
@@ -113,7 +112,7 @@ int serial_console_init(void)
 
 	devp = serial_get_stdout_devp();
 	if (devp == NULL)
-		goto err_out;
+		return rc;
 
 	if (dt_is_compatible(devp, "ns16550") ||
 	    dt_is_compatible(devp, "pnpPNP,501"))
@@ -134,19 +133,16 @@ int serial_console_init(void)
 		rc = opal_console_init(devp, &serial_cd);
 #endif
 
-	/* Add other serial console driver calls here */
+	if (rc)
+		return rc;
 
-	if (!rc) {
-		console_ops.open = serial_open;
-		console_ops.write = serial_write;
-		console_ops.close = serial_close;
-		console_ops.data = &serial_cd;
+	console_ops.open = serial_open;
+	console_ops.write = serial_write;
+	console_ops.close = serial_close;
+	console_ops.data = &serial_cd;
 
-		if (serial_cd.getc)
-			console_ops.edit_cmdline = serial_edit_cmdline;
+	if (serial_cd.getc)
+		console_ops.edit_cmdline = serial_edit_cmdline;
 
-		return 0;
-	}
-err_out:
-	return -1;
+	return 0;
 }


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-14 10:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-14 10:41 [PATCH] powerpc/boot: Simplify serial console control flow Thorsten Blum

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.