diff mbox series

usb: typec: tcpm: Replace the ternary conditional operator with max()

Message ID 20230626121105.3252-1-youkangren@vivo.com
State New
Headers show
Series usb: typec: tcpm: Replace the ternary conditional operator with max() | expand

Commit Message

You Kangren June 26, 2023, 12:11 p.m. UTC
Replace the ternary conditional operator with max() to make the code clean

Signed-off-by: You Kangren <youkangren@vivo.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Heikki Krogerus June 30, 2023, 12:48 p.m. UTC | #1
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@vivo.com>
> ---
>  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,
diff mbox series

Patch

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);
 		}
 	}