[PATCH] acerhdf: Fix fan activation with new thermal governor

Borislav Petkov
2013-02-23T19:20:20Z

From: Borislav Petkov <bp@suse.de>

The new step_wise thermal governor wasn't able to handle the one-trip
point design of acerhdf where we want to turn off the fan if we go under
the 'fanoff' temperature and to turn it on only after exceeding the
'fanon' temperature.

Do that by looking at the current fan state and return the temperature
accordingly.

Suggested-by: Zhang Rui <rui.zhang@intel.com>
Cc: Peter Feuerer <peter@piie.net>
Cc: Andreas Mohr <andi@lisas.de>
Cc: Alexander Lam <azl@andrew.cmu.edu>
Signed-off-by: Borislav Petkov <bp@suse.de>
---

Guys,

this fixes acerhdf to the old behavior. Testing here looks ok - I'd
appreciate if you could verify this too.

Thanks.

drivers/platform/x86/acerhdf.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index f94467c05225..b44033756909 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -405,13 +405,33 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
return 0;
}

+/*
+ * This is more or less a quirky wagging the dog so that a one-trip
+ * point can still work with the step_wise governor. Basically, we cheat
+ * with the trip temperature depending on whether the current state of
+ * the fan (on vs off).
+ */
static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
unsigned long *temp)
{
- if (trip == 0)
+ int err = 0, state;
+
+ err = acerhdf_get_fanstate(&state);
+ if (err) {
+ /*
+ * We want to be conservative here: in the unlikely event that
+ * reading the fanstate failed, we want to leave the fan on.
+ */
*temp = fanon;
+ return err;
+ }

- return 0;
+ if (state == ACERHDF_FAN_AUTO)
+ *temp = fanoff;
+ else
+ *temp = fanon;
+
+ return err;
}

static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal,
--
1.8.1.3.535.ga923c31