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

From: Heikki Krogerus
Date: Fri Jun 30 2023 - 08:48:37 EST


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 <youkangren@xxxxxxxx>
> ---
> 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