2023-06-26 12:21:54

by You Kangren

[permalink] [raw]
Subject: [PATCH] usb: typec: tcpm: Replace the ternary conditional operator with max()

Replace the ternary conditional operator with max() to make the code clean

Signed-off-by: You Kangren <[email protected]>
---
drivers/usb/typec/tcpm/tcpm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 829d75ebab42..2a0b33bd2eb8 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -6353,7 +6353,7 @@ static int tcpm_psy_get_input_power_limit(struct tcpm_port *port,
src_mv = pdo_fixed_voltage(pdo);
src_ma = pdo_max_current(pdo);
tmp = src_mv * src_ma;
- max_src_uw = tmp > max_src_uw ? tmp : max_src_uw;
+ max_src_uw = max(tmp, max_src_uw);
}
}

--
2.39.0



2023-06-30 13:10:07

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH] usb: typec: tcpm: Replace the ternary conditional operator with max()

On Mon, Jun 26, 2023 at 08:11:05PM +0800, You Kangren wrote:
> Replace the ternary conditional operator with max() to make the code clean
>
> Signed-off-by: You Kangren <[email protected]>
> ---
> drivers/usb/typec/tcpm/tcpm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 829d75ebab42..2a0b33bd2eb8 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -6353,7 +6353,7 @@ static int tcpm_psy_get_input_power_limit(struct tcpm_port *port,
> src_mv = pdo_fixed_voltage(pdo);
> src_ma = pdo_max_current(pdo);
> tmp = src_mv * src_ma;
> - max_src_uw = tmp > max_src_uw ? tmp : max_src_uw;
> + max_src_uw = max(tmp, max_src_uw);

Is that "tmp" useful anymore - why not drop it while at it?

thanks,

--
heikki