From: Thorsten Blum <blum@kernel.org>
To: Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
Thorsten Blum <blum@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [PATCH] powerpc/boot: Simplify serial console control flow
Date: Mon, 14 Sep 2026 12:41:36 +0200 [thread overview]
Message-ID: <20260914104136.74312-3-blum@kernel.org> (raw)
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;
}
reply other threads:[~2026-09-14 10:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260914104136.74312-3-blum@kernel.org \
--to=blum@kernel.org \
--cc=chleroy@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=ritesh.list@gmail.com \
--cc=sshegde@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.