public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
To: lenb@kernel.org
Cc: ibm-acpi-devel@lists.sourceforge.net, linux-acpi@vger.kernel.org,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Subject: [PATCH 7/9] ACPI: thinkpad-acpi: add a safety net for TPEC fan control mode
Date: Tue, 24 Apr 2007 11:48:18 -0300	[thread overview]
Message-ID: <11774261023730-git-send-email-hmh@hmh.eng.br> (raw)
In-Reply-To: <11774261003184-git-send-email-hmh@hmh.eng.br>

The Linux ThinkPad community is not positive that all ThinkPads that do
HFSP EC fan control do implement full-speed and auto modes, some of the
earlier ones supporting HFSP might not.

If the EC ignores the AUTO or FULL-SPEED bits, it will pay attention to the
lower three bits that set the fan level.  And as thinkpad-acpi was leaving
these set to zero, it would stop(!) the fan, which is Not A Good Thing.

So, as a safety net, we now make sure to also set the fan level part of the
HFSP register to speed 7 for full-speed, and a minimum of speed 4 for auto
mode.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
 drivers/misc/thinkpad_acpi.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index a4d7ee4..79abc68 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -3185,6 +3185,13 @@ static int fan_set_level(int level)
 		    ((level < 0) || (level > 7)))
 			return -EINVAL;
 
+		/* safety net should the EC not support AUTO
+		 * or FULLSPEED mode bits and just ignore them */
+		if (level & TP_EC_FAN_FULLSPEED)
+			level |= 7;	/* safety min speed 7 */
+		else if (level & TP_EC_FAN_FULLSPEED)
+			level |= 4;	/* safety min speed 4 */
+
 		if (!acpi_ec_write(fan_status_offset, level))
 			return -EIO;
 		else
@@ -3233,8 +3240,10 @@ static int fan_set_enable(void)
 			break;
 
 		/* Don't go out of emergency fan mode */
-		if (s != 7)
-			s = TP_EC_FAN_AUTO;
+		if (s != 7) {
+			s &= 0x07;
+			s |= TP_EC_FAN_AUTO | 4; /* min fan speed 4 */
+		}
 
 		if (!acpi_ec_write(fan_status_offset, s))
 			rc = -EIO;
@@ -3252,8 +3261,7 @@ static int fan_set_enable(void)
 		s &= 0x07;
 
 		/* Set fan to at least level 4 */
-		if (s < 4)
-			s = 4;
+		s |= 4;
 
 		if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", s))
 			rc= -EIO;
-- 
1.5.1


  parent reply	other threads:[~2007-04-24 14:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-24 14:48 [GIT PULL] thinkpad-acpi sysfs support part 1 Henrique de Moraes Holschuh
2007-04-24 14:48 ` [PATCH 1/9] ACPI: thinkpad-acpi: register with the device model Henrique de Moraes Holschuh
2007-04-24 14:48 ` [PATCH 3/9] ACPI: thinkpad-acpi: add infrastructure for the sysfs device attributes Henrique de Moraes Holschuh
     [not found] ` <11774261003184-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2007-04-24 14:48   ` [PATCH 2/9] ACPI: thinkpad-acpi: driver sysfs conversion Henrique de Moraes Holschuh
2007-04-24 14:48   ` [PATCH 4/9] ACPI: thinkpad-acpi: protect fan and hotkey data structures Henrique de Moraes Holschuh
2007-04-24 14:48   ` [PATCH 5/9] ACPI: thinkpad-acpi: add sysfs support to the thermal subdriver Henrique de Moraes Holschuh
2007-04-24 14:48   ` [PATCH 8/9] ACPI: thinkpad-acpi: add sysfs support to the cmos command subdriver Henrique de Moraes Holschuh
2007-04-24 14:48 ` [PATCH 6/9] ACPI: thinkpad-acpi: add sysfs support to fan subdriver Henrique de Moraes Holschuh
2007-04-25  5:58   ` Len Brown
2007-04-25 12:49     ` Henrique de Moraes Holschuh
     [not found]     ` <200704250158.18297.lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2007-04-25 12:59       ` Henrique de Moraes Holschuh
2007-04-24 14:48 ` Henrique de Moraes Holschuh [this message]
2007-04-24 14:48 ` [PATCH 9/9] ACPI: thinkpad-acpi: update brightness sysfs interface support Henrique de Moraes Holschuh
2007-04-25  6:04 ` [GIT PULL] thinkpad-acpi sysfs support part 1 Len Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11774261023730-git-send-email-hmh@hmh.eng.br \
    --to=hmh@hmh.eng.br \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox