1 From bab812a329cc244ca63c2675b0e05016518855ce Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Fri, 24 Nov 2006 11:47:12 -0200
4 Subject: [PATCH 13/28] ACPI: ibm-acpi: extend fan status functions
6 This patch fixes fan_read to return correct values for all fan access
7 modes. It also implements some fan access mode status output that was
8 missing, and normalizes the proc fan abi to return consistent data across
9 all fan read/write modes.
11 Userspace ABI changes and extensions:
12 1. Return status: enable/disable for *all* modes
13 (this actually improves compatibility with userspace utils!)
14 2. Return level: auto and level: disengaged for EC 2f access mode
15 3. Return level: <number> for EC 0x2f access mode
16 4. Return level 0 as well as "disabled" in level-aware modes
18 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
20 drivers/acpi/ibm_acpi.c | 21 ++++++++++++++++++---
21 1 files changed, 18 insertions(+), 3 deletions(-)
23 diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
24 index faf78d3..b6ad2ed 100644
25 --- a/drivers/acpi/ibm_acpi.c
26 +++ b/drivers/acpi/ibm_acpi.c
27 @@ -354,6 +354,11 @@ enum { /* Fan control constants */
28 fan_status_offset = 0x2f, /* EC register 0x2f */
29 fan_rpm_offset = 0x84, /* EC register 0x84: LSB, 0x85 MSB (RPM)
30 * 0x84 must be read before 0x85 */
32 + IBMACPI_FAN_EC_DISENGAGED = 0x40, /* EC mode: tachometer
34 + IBMACPI_FAN_EC_AUTO = 0x80, /* EC mode: auto fan
38 static int ibm_thinkpad_ec_found;
39 @@ -1910,8 +1915,9 @@ static int fan_read(char *p)
40 if ((rc = fan_get_status(&status)) < 0)
43 - len += sprintf(p + len, "level:\t\t%d\n", status);
45 + len += sprintf(p + len, "status:\t\t%s\n"
47 + (status != 0) ? "enabled" : "disabled", status);
50 case IBMACPI_FAN_RD_TPEC:
51 @@ -1919,12 +1925,21 @@ static int fan_read(char *p)
52 if ((rc = fan_get_status(&status)) < 0)
55 - len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 7));
56 + len += sprintf(p + len, "status:\t\t%s\n",
57 + (status != 0) ? "enabled" : "disabled");
59 if ((rc = fan_get_speed(&speed)) < 0)
62 len += sprintf(p + len, "speed:\t\t%d\n", speed);
64 + if (status & IBMACPI_FAN_EC_DISENGAGED)
65 + /* Disengaged mode takes precedence */
66 + len += sprintf(p + len, "level:\t\tdisengaged\n");
67 + else if (status & IBMACPI_FAN_EC_AUTO)
68 + len += sprintf(p + len, "level:\t\tauto\n");
70 + len += sprintf(p + len, "level:\t\t%d\n", status);
73 case IBMACPI_FAN_NONE: