aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ibm_acpi.c
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2006-11-24 08:47:10 -0500
committerLen Brown <len.brown@intel.com>2006-12-07 01:38:39 -0500
commit3ef8a6096ca98d45a54999a97c7c8e14977d2e3e (patch)
treef1ebed3d60e21778a277759a0a3f5ff08938e058 /drivers/acpi/ibm_acpi.c
parent69ba91cbd6d79aa197adbdd10a44e71c84044b44 (diff)
ACPI: ibm-acpi: clean up fan_read
This patch cleans up fan_read so that it is much easier to read and extend. The patch fixes the userspace ABI to return "status: not supported" (like all other ibm-acpi functions) when neither fan status or fan control are possible. It also fixes the userspace ABI to return EIO if ACPI access to the EC fails, instead of returning "status: unreadable" or "speed: unreadable". Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Diffstat (limited to 'drivers/acpi/ibm_acpi.c')
-rw-r--r--drivers/acpi/ibm_acpi.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index 7d0bd61eebc7..e8de5e349d21 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -1741,40 +1741,48 @@ static int fan_init(void)
1741static int fan_read(char *p) 1741static int fan_read(char *p)
1742{ 1742{
1743 int len = 0; 1743 int len = 0;
1744 int s;
1745 u8 lo, hi, status; 1744 u8 lo, hi, status;
1746 1745
1747 if (gfan_handle) { 1746 switch (fan_status_access_mode) {
1747 case IBMACPI_FAN_RD_ACPI_GFAN:
1748 /* 570, 600e/x, 770e, 770x */ 1748 /* 570, 600e/x, 770e, 770x */
1749 if (!acpi_evalf(gfan_handle, &s, NULL, "d")) 1749 if (unlikely(!acpi_evalf(gfan_handle, &status, NULL, "d")))
1750 return -EIO; 1750 return -EIO;
1751 1751
1752 len += sprintf(p + len, "level:\t\t%d\n", s); 1752 len += sprintf(p + len, "level:\t\t%d\n", status);
1753 } else { 1753
1754 break;
1755
1756 case IBMACPI_FAN_RD_TPEC:
1754 /* all except 570, 600e/x, 770e, 770x */ 1757 /* all except 570, 600e/x, 770e, 770x */
1755 if (!acpi_ec_read(fan_status_offset, &status)) 1758 if (unlikely(!acpi_ec_read(fan_status_offset, &status)))
1756 len += sprintf(p + len, "status:\t\tunreadable\n"); 1759 return -EIO;
1757 else 1760 else
1758 len += sprintf(p + len, "status:\t\t%s\n", 1761 len += sprintf(p + len, "status:\t\t%s\n",
1759 enabled(status, 7)); 1762 enabled(status, 7));
1760 1763
1761 if (!acpi_ec_read(fan_rpm_offset, &lo) || 1764 if (unlikely(!acpi_ec_read(fan_rpm_offset, &lo) ||
1762 !acpi_ec_read(fan_rpm_offset + 1, &hi)) 1765 !acpi_ec_read(fan_rpm_offset + 1, &hi)))
1763 len += sprintf(p + len, "speed:\t\tunreadable\n"); 1766 return -EIO;
1764 else 1767 else
1765 len += sprintf(p + len, "speed:\t\t%d\n", 1768 len += sprintf(p + len, "speed:\t\t%d\n",
1766 (hi << 8) + lo); 1769 (hi << 8) + lo);
1770
1771 break;
1772
1773 case IBMACPI_FAN_NONE:
1774 default:
1775 len += sprintf(p + len, "status:\t\tnot supported\n");
1767 } 1776 }
1768 1777
1769 if (sfan_handle) 1778 if (fan_control_commands & IBMACPI_FAN_CMD_LEVEL)
1770 /* 570, 770x-JL */
1771 len += sprintf(p + len, "commands:\tlevel <level>" 1779 len += sprintf(p + len, "commands:\tlevel <level>"
1772 " (<level> is 0-7)\n"); 1780 " (<level> is 0-7)\n");
1773 if (!gfan_handle) 1781
1774 /* all except 570, 600e/x, 770e, 770x */ 1782 if (fan_control_commands & IBMACPI_FAN_CMD_ENABLE)
1775 len += sprintf(p + len, "commands:\tenable, disable\n"); 1783 len += sprintf(p + len, "commands:\tenable, disable\n");
1776 if (fans_handle) 1784
1777 /* X31, X40 */ 1785 if (fan_control_commands & IBMACPI_FAN_CMD_SPEED)
1778 len += sprintf(p + len, "commands:\tspeed <speed>" 1786 len += sprintf(p + len, "commands:\tspeed <speed>"
1779 " (<speed> is 0-65535)\n"); 1787 " (<speed> is 0-65535)\n");
1780 1788