From: Lu Dai <dai.lu@exordes.com>
To: npiggin@gmail.com, christophe.leroy@csgroup.eu,
naveen.n.rao@linux.ibm.com
Cc: Lu Dai <dai.lu@exordes.com>,
mpe@ellerman.id.au, gregkh@linuxfoundation.org,
jirislaby@kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
javier.carrasco.cruz@gmail.com, shuah@kernel.org,
julia.lawall@inria.fr
Subject: [PATCH V2] tty: hvc: hvc_opal: eliminate uses of of_node_put()
Date: Fri, 3 May 2024 16:52:15 +0300 [thread overview]
Message-ID: <20240503135215.252635-1-dai.lu@exordes.com> (raw)
Make use of the __free() cleanup handler to automatically free nodes
when they get out of scope.
Remove the need for a 'goto' as an effect.
Signed-off-by: Lu Dai <dai.lu@exordes.com>
---
Changes since v1:
Move the assignment of 'opal' to its declaration
Seperate the declaration of 'np'
drivers/tty/hvc/hvc_opal.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index 095c33ad10f8..c17e8343ea60 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -327,19 +327,18 @@ static void udbg_init_opal_common(void)
void __init hvc_opal_init_early(void)
{
- struct device_node *stdout_node = of_node_get(of_stdout);
+ struct device_node *stdout_node __free(device_node) = of_node_get(of_stdout);
const __be32 *termno;
const struct hv_ops *ops;
u32 index;
/* If the console wasn't in /chosen, try /ibm,opal */
if (!stdout_node) {
- struct device_node *opal, *np;
-
/* Current OPAL takeover doesn't provide the stdout
* path, so we hard wire it
*/
- opal = of_find_node_by_path("/ibm,opal/consoles");
+ struct device_node *opal __free(device_node) =
+ of_find_node_by_path("/ibm,opal/consoles");
if (opal) {
pr_devel("hvc_opal: Found consoles in new location\n");
} else {
@@ -350,13 +349,13 @@ void __init hvc_opal_init_early(void)
}
if (!opal)
return;
+ struct device_node *np;
for_each_child_of_node(opal, np) {
if (of_node_name_eq(np, "serial")) {
stdout_node = np;
break;
}
}
- of_node_put(opal);
}
if (!stdout_node)
return;
@@ -382,13 +381,11 @@ void __init hvc_opal_init_early(void)
hvsilib_establish(&hvc_opal_boot_priv.hvsi);
pr_devel("hvc_opal: Found HVSI console\n");
} else
- goto out;
+ return;
hvc_opal_boot_termno = index;
udbg_init_opal_common();
add_preferred_console("hvc", index, NULL);
hvc_instantiate(index, index, ops);
-out:
- of_node_put(stdout_node);
}
#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL_RAW
--
2.39.2
next reply other threads:[~2024-05-03 15:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 13:52 Lu Dai [this message]
2024-05-03 13:58 ` [PATCH V2] tty: hvc: hvc_opal: eliminate uses of of_node_put() Greg KH
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=20240503135215.252635-1-dai.lu@exordes.com \
--to=dai.lu@exordes.com \
--cc=christophe.leroy@csgroup.eu \
--cc=gregkh@linuxfoundation.org \
--cc=javier.carrasco.cruz@gmail.com \
--cc=jirislaby@kernel.org \
--cc=julia.lawall@inria.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=shuah@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox