summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2016-05-23 04:52:51 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2016-05-23 04:52:51 +0000
commitd98a7caa05abd31a2396fecd7f7082cad1775c09 (patch)
treee279c4bf68e23a9434a60eb4ead17f5e0062f0ae
parent043d44d75893d89876ab3e38e1d47c2ba4b640a6 (diff)
Some of our fan scaling calculations with the muK temperature unit above
59 degC require temporary values larger than 32bit signed. Therefore bump those involved variables to int64_t and replace imin/imax with ulmin/ulmax to get proper results.
-rw-r--r--sys/arch/macppc/dev/thermal.c12
-rw-r--r--sys/arch/macppc/dev/thermal.h4
2 files changed, 8 insertions, 8 deletions
diff --git a/sys/arch/macppc/dev/thermal.c b/sys/arch/macppc/dev/thermal.c
index 650c3020100..80eed28e206 100644
--- a/sys/arch/macppc/dev/thermal.c
+++ b/sys/arch/macppc/dev/thermal.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: thermal.c,v 1.2 2016/05/20 22:00:45 mglocker Exp $ */
+/* $OpenBSD: thermal.c,v 1.3 2016/05/23 04:52:50 mglocker Exp $ */
/*-
* Copyright (c) 2009-2011 Nathan Whitehorn
@@ -101,7 +101,7 @@ thermal_manage_fans(void)
{
struct thermal_sens_le *sensor;
struct thermal_fan_le *fan;
- int average_excess, max_excess_zone, frac_excess;
+ int64_t average_excess, max_excess_zone, frac_excess;
int fan_speed;
int nsens, nsens_zone;
int temp;
@@ -115,7 +115,7 @@ thermal_manage_fans(void)
if (sensor->last_val > sensor->sensor->max_temp) {
sensor->critical_count++;
printf("WARNING: Current temperature (%s: %d.%d C) "
- "exceeds critical temperature (%d.%d C); "
+ "exceeds critical temperature (%lld.%lld C); "
"count=%d\n",
sensor->sensor->name,
(sensor->last_val - ZERO_C_TO_MUK)/1000000,
@@ -142,7 +142,7 @@ thermal_manage_fans(void)
nsens = nsens_zone = 0;
average_excess = max_excess_zone = 0;
SLIST_FOREACH(sensor, &sensors, entries) {
- temp = imin(sensor->last_val,
+ temp = ulmin(sensor->last_val,
sensor->sensor->max_temp);
frac_excess = (temp -
sensor->sensor->target_temp)*100 /
@@ -150,7 +150,7 @@ thermal_manage_fans(void)
if (frac_excess < 0)
frac_excess = 0;
if (sensor->sensor->zone == fan->fan->zone) {
- max_excess_zone = imax(max_excess_zone,
+ max_excess_zone = ulmax(max_excess_zone,
frac_excess);
nsens_zone++;
}
@@ -172,7 +172,7 @@ thermal_manage_fans(void)
* Scale the fan linearly in the max temperature in its
* thermal zone.
*/
- max_excess_zone = imin(max_excess_zone, 100);
+ max_excess_zone = ulmin(max_excess_zone, 100);
fan_speed = max_excess_zone *
(fan->fan->max_rpm - fan->fan->min_rpm)/100 +
fan->fan->min_rpm;
diff --git a/sys/arch/macppc/dev/thermal.h b/sys/arch/macppc/dev/thermal.h
index ac512d0d8d5..56d58a4b52f 100644
--- a/sys/arch/macppc/dev/thermal.h
+++ b/sys/arch/macppc/dev/thermal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: thermal.h,v 1.1 2016/05/20 21:45:04 mglocker Exp $ */
+/* $OpenBSD: thermal.h,v 1.2 2016/05/23 04:52:50 mglocker Exp $ */
/*-
* Copyright (c) 2009-2011 Nathan Whitehorn
@@ -39,7 +39,7 @@ struct thermal_fan {
};
struct thermal_temp {
- int target_temp, max_temp; /* muK */
+ int64_t target_temp, max_temp; /* muK */
char name[32];
int zone;