2022-04-25 08:12:27

by Jiabing Wan

[permalink] [raw]
Subject: [PATCH] tty/hvc_opal: simplify if-if to if-else

Use if and else instead of if(A) and if (!A).

Signed-off-by: Wan Jiabing <[email protected]>
---
drivers/tty/hvc/hvc_opal.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index 84776bc641e6..2dafa0964c2a 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -344,14 +344,15 @@ void __init hvc_opal_init_early(void)
opal = of_find_node_by_path("/ibm,opal/consoles");
if (opal)
pr_devel("hvc_opal: Found consoles in new location\n");
- if (!opal) {
+ else {
opal = of_find_node_by_path("/ibm,opal");
if (opal)
pr_devel("hvc_opal: "
"Found consoles in old location\n");
+ else
+ return;
}
- if (!opal)
- return;
+
for_each_child_of_node(opal, np) {
if (of_node_name_eq(np, "serial")) {
stdout_node = np;
--
2.35.1


2022-04-25 14:11:09

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH] tty/hvc_opal: simplify if-if to if-else

On 24. 04. 22, 11:25, Wan Jiabing wrote:
> Use if and else instead of if(A) and if (!A).
>
> Signed-off-by: Wan Jiabing <[email protected]>
> ---
> drivers/tty/hvc/hvc_opal.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
> index 84776bc641e6..2dafa0964c2a 100644
> --- a/drivers/tty/hvc/hvc_opal.c
> +++ b/drivers/tty/hvc/hvc_opal.c
> @@ -344,14 +344,15 @@ void __init hvc_opal_init_early(void)
> opal = of_find_node_by_path("/ibm,opal/consoles");
> if (opal)
> pr_devel("hvc_opal: Found consoles in new location\n");
> - if (!opal) {
> + else {

This looks good, except missing braces as noted by Joe.

> opal = of_find_node_by_path("/ibm,opal");
> if (opal)
> pr_devel("hvc_opal: "
> "Found consoles in old location\n");
> + else
> + return;

I am not sure this return is more obvious than the previous one. Rather
the opposite, IMO.

> }
> - if (!opal)
> - return;
> +
> for_each_child_of_node(opal, np) {
> if (of_node_name_eq(np, "serial")) {
> stdout_node = np;

thanks,
--
js
suse labs