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

From: Borislav Petkov
Date: Sat Feb 23 2013 - 14:22:07 EST


From: Borislav Petkov <bp@xxxxxxx>

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@xxxxxxxxx>
Cc: Peter Feuerer <peter@xxxxxxxx>
Cc: Andreas Mohr <andi@xxxxxxxx>
Cc: Alexander Lam <azl@xxxxxxxxxxxxxx>
Signed-off-by: Borislav Petkov <bp@xxxxxxx>
---

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/