* [PATCH linux-next] usb: typec: tcpm: use max() to get higher value
@ 2024-09-25 12:20 R Sundar
2024-09-26 13:03 ` Heikki Krogerus
0 siblings, 1 reply; 2+ messages in thread
From: R Sundar @ 2024-09-25 12:20 UTC (permalink / raw)
To: Heikki Krogerus, Greg Kroah-Hartman, RD Babiera, Guenter Roeck,
Badhri Jagan Sridharan, Kyle Tso, Xu Yang
Cc: linux-usb, linux-kernel, frank.wang, R Sundar, kernel test robot,
Julia Lawall
Use max() for better readability and to fix cocci warnings.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@inria.fr>
Closes: https://lore.kernel.org/r/202409231009.2efXAh9b-lkp@intel.com/
Signed-off-by: R Sundar <prosunofficial@gmail.com>
---
Reported in linux repo.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
cocci warnings: (new ones prefixed by >>)
>> drivers/usb/typec/tcpm/tcpm.c:6356:20-21: WARNING opportunity for max()
vim +6356 drivers/usb/typec/tcpm/tcpm.c
compile-tested only.
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 fc619478200f..aac4de1d53a8 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -7367,7 +7367,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.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH linux-next] usb: typec: tcpm: use max() to get higher value
2024-09-25 12:20 [PATCH linux-next] usb: typec: tcpm: use max() to get higher value R Sundar
@ 2024-09-26 13:03 ` Heikki Krogerus
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2024-09-26 13:03 UTC (permalink / raw)
To: R Sundar
Cc: Greg Kroah-Hartman, RD Babiera, Guenter Roeck,
Badhri Jagan Sridharan, Kyle Tso, Xu Yang, linux-usb,
linux-kernel, frank.wang, kernel test robot, Julia Lawall
On Wed, Sep 25, 2024 at 05:50:14PM +0530, R Sundar wrote:
> Use max() for better readability and to fix cocci warnings.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Julia Lawall <julia.lawall@inria.fr>
> Closes: https://lore.kernel.org/r/202409231009.2efXAh9b-lkp@intel.com/
> Signed-off-by: R Sundar <prosunofficial@gmail.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>
> Reported in linux repo.
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>
> cocci warnings: (new ones prefixed by >>)
> >> drivers/usb/typec/tcpm/tcpm.c:6356:20-21: WARNING opportunity for max()
>
> vim +6356 drivers/usb/typec/tcpm/tcpm.c
>
> compile-tested only.
>
> 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 fc619478200f..aac4de1d53a8 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -7367,7 +7367,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.34.1
--
heikki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-26 13:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25 12:20 [PATCH linux-next] usb: typec: tcpm: use max() to get higher value R Sundar
2024-09-26 13:03 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox