public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI: thermal: replace ternary operator with min_t()
@ 2023-03-28  3:16 Jiangshan Yi
  2023-03-30 17:11 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Jiangshan Yi @ 2023-03-28  3:16 UTC (permalink / raw)
  To: rafael; +Cc: rui.zhang, lenb, linux-acpi, linux-kernel, 13667453960,
	Jiangshan Yi

Fix the following coccicheck warning:

drivers/acpi/thermal.c:422: WARNING opportunity for min().

min_t() macro is defined in include/linux/minmax.h. It avoids multiple
evaluations of the arguments when non-constant and performs strict
type-checking.

Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
---
 drivers/acpi/thermal.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 0b4b844f9d4c..179f41196a9d 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -419,10 +419,9 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
 					 * the next higher trip point
 					 */
 					tz->trips.active[i-1].temperature =
-						(tz->trips.active[i-2].temperature <
-						celsius_to_deci_kelvin(act) ?
-						tz->trips.active[i-2].temperature :
-						celsius_to_deci_kelvin(act));
+						min_t(unsigned long,
+						      tz->trips.active[i-2].temperature,
+						      celsius_to_deci_kelvin(act));
 
 				break;
 			} else {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-31  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-28  3:16 [PATCH] ACPI: thermal: replace ternary operator with min_t() Jiangshan Yi
2023-03-30 17:11 ` Rafael J. Wysocki
2023-03-31  8:58   ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox