Skip to content

Commit

Permalink
ACPI: ibm-acpi: extend fan status functions
Browse files Browse the repository at this point in the history
This patch fixes fan_read to return correct values for all fan access
modes.  It also implements some fan access mode status output that was
missing, and normalizes the proc fan abi to return consistent data across
all fan read/write modes.

Userspace ABI changes and extensions:
	1. Return status: enable/disable for *all* modes
	   (this actually improves compatibility with userspace utils!)
	2. Return level: auto and level: disengaged for EC 2f access mode
	3. Return level: <number> for EC 0x2f access mode
	4. Return level 0 as well as "disabled" in level-aware modes

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
  • Loading branch information
Henrique de Moraes Holschuh authored and Len Brown committed Dec 7, 2006
1 parent a8b7a66 commit bab812a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions drivers/acpi/ibm_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ enum { /* Fan control constants */
fan_status_offset = 0x2f, /* EC register 0x2f */
fan_rpm_offset = 0x84, /* EC register 0x84: LSB, 0x85 MSB (RPM)
* 0x84 must be read before 0x85 */

IBMACPI_FAN_EC_DISENGAGED = 0x40, /* EC mode: tachometer
* disengaged */
IBMACPI_FAN_EC_AUTO = 0x80, /* EC mode: auto fan
* control */
};

static int ibm_thinkpad_ec_found;
Expand Down Expand Up @@ -1910,21 +1915,31 @@ static int fan_read(char *p)
if ((rc = fan_get_status(&status)) < 0)
return rc;

len += sprintf(p + len, "level:\t\t%d\n", status);

len += sprintf(p + len, "status:\t\t%s\n"
"level:\t\t%d\n",
(status != 0) ? "enabled" : "disabled", status);
break;

case IBMACPI_FAN_RD_TPEC:
/* all except 570, 600e/x, 770e, 770x */
if ((rc = fan_get_status(&status)) < 0)
return rc;

len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 7));
len += sprintf(p + len, "status:\t\t%s\n",
(status != 0) ? "enabled" : "disabled");

if ((rc = fan_get_speed(&speed)) < 0)
return rc;

len += sprintf(p + len, "speed:\t\t%d\n", speed);

if (status & IBMACPI_FAN_EC_DISENGAGED)
/* Disengaged mode takes precedence */
len += sprintf(p + len, "level:\t\tdisengaged\n");
else if (status & IBMACPI_FAN_EC_AUTO)
len += sprintf(p + len, "level:\t\tauto\n");
else
len += sprintf(p + len, "level:\t\t%d\n", status);
break;

case IBMACPI_FAN_NONE:
Expand Down

0 comments on commit bab812a

Please sign in to comment.