Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c52f0aa574246f133a0bc2041e9468a06d34da7b
Commit:     c52f0aa574246f133a0bc2041e9468a06d34da7b
Parent:     3ef8a6096ca98d45a54999a97c7c8e14977d2e3e
Author:     Henrique de Moraes Holschuh <[EMAIL PROTECTED]>
AuthorDate: Fri Nov 24 11:47:10 2006 -0200
Committer:  Len Brown <[EMAIL PROTECTED]>
CommitDate: Thu Dec 7 01:38:39 2006 -0500

    ACPI: ibm-acpi: break fan_read into separate functions
    
    This patch breaks fan_read mechanics into a generic function to get fan
    status and speed, and leaves only the procfs interface code in fan_read.
    
    Signed-off-by: Henrique de Moraes Holschuh <[EMAIL PROTECTED]>
---
 drivers/acpi/ibm_acpi.c |   78 +++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 66 insertions(+), 12 deletions(-)

diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index e8de5e3..9275dfc 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -1738,36 +1738,90 @@ static int fan_init(void)
        return 0;
 }
 
-static int fan_read(char *p)
+static int fan_get_status(u8 *status)
 {
-       int len = 0;
-       u8 lo, hi, status;
+       u8 s;
 
        switch (fan_status_access_mode) {
        case IBMACPI_FAN_RD_ACPI_GFAN:
                /* 570, 600e/x, 770e, 770x */
-               if (unlikely(!acpi_evalf(gfan_handle, &status, NULL, "d")))
+
+               if (unlikely(!acpi_evalf(gfan_handle, &s, NULL, "d")))
                        return -EIO;
 
-               len += sprintf(p + len, "level:\t\t%d\n", status);
+               if (likely(status))
+                       *status = s & 0x07;
 
                break;
 
        case IBMACPI_FAN_RD_TPEC:
                /* all except 570, 600e/x, 770e, 770x */
-               if (unlikely(!acpi_ec_read(fan_status_offset, &status)))
+               if (unlikely(!acpi_ec_read(fan_status_offset, &s)))
                        return -EIO;
-               else
-                       len += sprintf(p + len, "status:\t\t%s\n",
-                                      enabled(status, 7));
 
+               if (likely(status))
+                       *status = s;
+
+               break;
+
+       default:
+               return -ENXIO;
+       }
+
+       return 0;
+}
+
+static int fan_get_speed(unsigned int *speed)
+{
+       u8 hi, lo;
+
+       switch (fan_status_access_mode) {
+       case IBMACPI_FAN_RD_TPEC:
+               /* all except 570, 600e/x, 770e, 770x */
                if (unlikely(!acpi_ec_read(fan_rpm_offset, &lo) ||
                             !acpi_ec_read(fan_rpm_offset + 1, &hi)))
                        return -EIO;
-               else
-                       len += sprintf(p + len, "speed:\t\t%d\n",
-                                      (hi << 8) + lo);
 
+               if (likely(speed))
+                       *speed = (hi << 8) | lo;
+
+               break;
+
+       default:
+               return -ENXIO;
+       }
+
+       return 0;
+}
+
+static int fan_read(char *p)
+{
+       int len = 0;
+       int rc;
+       u8 status;
+       unsigned int speed = 0;
+
+       switch (fan_status_access_mode) {
+       case IBMACPI_FAN_RD_ACPI_GFAN:
+               /* 570, 600e/x, 770e, 770x */
+               if ((rc = fan_get_status(&status)) < 0)
+                       return rc;
+
+               len += sprintf(p + len, "level:\t\t%d\n", 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));
+
+               if ((rc = fan_get_speed(&speed)) < 0)
+                       return rc;
+
+               len += sprintf(p + len, "speed:\t\t%d\n", speed);
                break;
 
        case IBMACPI_FAN_NONE:
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to