Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / macintosh / therm_pm72.c
index 82336a5..231146f 100644 (file)
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
-#include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
 #include <linux/reboot.h>
 #include <linux/kmod.h>
 #include <linux/i2c.h>
-#include <linux/i2c-dev.h>
 #include <asm/prom.h>
 #include <asm/machdep.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/sections.h>
 #include <asm/of_device.h>
+#include <asm/macio.h>
 
 #include "therm_pm72.h"
 
@@ -282,9 +281,9 @@ static int therm_pm72_detach(struct i2c_adapter *adapter);
 
 static struct i2c_driver therm_pm72_driver =
 {
-       .owner          = THIS_MODULE,
-       .name           = "therm_pm72",
-       .flags          = I2C_DF_NOTIFY,
+       .driver = {
+               .name   = "therm_pm72",
+       },
        .attach_adapter = therm_pm72_attach,
        .detach_adapter = therm_pm72_detach,
 };
@@ -629,12 +628,12 @@ static int read_eeprom(int cpu, struct mpu_data *out)
        sprintf(nodename, "/u3@0,f8000000/i2c@f8001000/cpuid@a%d", cpu ? 2 : 0);
        np = of_find_node_by_path(nodename);
        if (np == NULL) {
-               printk(KERN_ERR "therm_pm72: Failed to retreive cpuid node from device-tree\n");
+               printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid node from device-tree\n");
                return -ENODEV;
        }
        data = (u8 *)get_property(np, "cpuid", &len);
        if (data == NULL) {
-               printk(KERN_ERR "therm_pm72: Failed to retreive cpuid property from device-tree\n");
+               printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid property from device-tree\n");
                of_node_put(np);
                return -ENODEV;
        }
@@ -685,7 +684,7 @@ static void fetch_cpu_pumps_minmax(void)
  * the input twice... I accept patches :)
  */
 #define BUILD_SHOW_FUNC_FIX(name, data)                                \
-static ssize_t show_##name(struct device *dev, char *buf)      \
+static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf)       \
 {                                                              \
        ssize_t r;                                              \
        down(&driver_lock);                                     \
@@ -694,7 +693,7 @@ static ssize_t show_##name(struct device *dev, char *buf)   \
        return r;                                               \
 }
 #define BUILD_SHOW_FUNC_INT(name, data)                                \
-static ssize_t show_##name(struct device *dev, char *buf)      \
+static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf)       \
 {                                                              \
        return sprintf(buf, "%d", data);                        \
 }
@@ -922,7 +921,7 @@ static void do_monitor_cpu_combined(void)
        if (temp_combi >= ((state0->mpu.tmax + 8) << 16)) {
                printk(KERN_WARNING "Warning ! Temperature way above maximum (%d) !\n",
                       temp_combi >> 16);
-               state0->overtemp = CPU_MAX_OVERTEMP;
+               state0->overtemp += CPU_MAX_OVERTEMP / 4;
        } else if (temp_combi > (state0->mpu.tmax << 16))
                state0->overtemp++;
        else
@@ -932,7 +931,7 @@ static void do_monitor_cpu_combined(void)
        if (state0->overtemp > 0) {
                state0->rpm = state0->mpu.rmaxn_exhaust_fan;
                state0->intake_rpm = intake = state0->mpu.rmaxn_intake_fan;
-               pump = state0->pump_min;
+               pump = state0->pump_max;
                goto do_set_fans;
        }
 
@@ -997,7 +996,7 @@ static void do_monitor_cpu_split(struct cpu_pid_state *state)
                printk(KERN_WARNING "Warning ! CPU %d temperature way above maximum"
                       " (%d) !\n",
                       state->index, temp >> 16);
-               state->overtemp = CPU_MAX_OVERTEMP;
+               state->overtemp += CPU_MAX_OVERTEMP / 4;
        } else if (temp > (state->mpu.tmax << 16))
                state->overtemp++;
        else
@@ -1059,7 +1058,7 @@ static void do_monitor_cpu_rack(struct cpu_pid_state *state)
                printk(KERN_WARNING "Warning ! CPU %d temperature way above maximum"
                       " (%d) !\n",
                       state->index, temp >> 16);
-               state->overtemp = CPU_MAX_OVERTEMP;
+               state->overtemp = CPU_MAX_OVERTEMP / 4;
        } else if (temp > (state->mpu.tmax << 16))
                state->overtemp++;
        else
@@ -1677,10 +1676,9 @@ static int main_control_loop(void *x)
                }
 
                // FIXME: Deal with signals
-               set_current_state(TASK_INTERRUPTIBLE);
                elapsed = jiffies - start;
                if (elapsed < HZ)
-                       schedule_timeout(HZ - elapsed);
+                       schedule_timeout_interruptible(HZ - elapsed);
        }
 
  out:
@@ -1986,20 +1984,15 @@ static void fcu_lookup_fans(struct device_node *fcu_node)
        }
 }
 
-static int fcu_of_probe(struct of_device* dev, const struct of_match *match)
+static int fcu_of_probe(struct of_device* dev, const struct of_device_id *match)
 {
-       int rc;
-
        state = state_detached;
 
        /* Lookup the fans in the device tree */
        fcu_lookup_fans(dev->node);
 
        /* Add the driver */
-       rc = i2c_add_driver(&therm_pm72_driver);
-       if (rc < 0)
-               return rc;
-       return 0;
+       return i2c_add_driver(&therm_pm72_driver);
 }
 
 static int fcu_of_remove(struct of_device* dev)
@@ -2009,12 +2002,10 @@ static int fcu_of_remove(struct of_device* dev)
        return 0;
 }
 
-static struct of_match fcu_of_match[] = 
+static struct of_device_id fcu_match[] = 
 {
        {
-       .name           = OF_ANY_MATCH,
        .type           = "fcu",
-       .compatible     = OF_ANY_MATCH
        },
        {},
 };
@@ -2022,7 +2013,7 @@ static struct of_match fcu_of_match[] =
 static struct of_platform_driver fcu_of_platform_driver = 
 {
        .name           = "temperature",
-       .match_table    = fcu_of_match,
+       .match_table    = fcu_match,
        .probe          = fcu_of_probe,
        .remove         = fcu_of_remove
 };
@@ -2052,7 +2043,7 @@ static int __init therm_pm72_init(void)
                            return -ENODEV;
                }
        }
-       of_dev = of_platform_device_create(np, "temperature");
+       of_dev = of_platform_device_create(np, "temperature", NULL);
        if (of_dev == NULL) {
                printk(KERN_ERR "Can't register FCU platform device !\n");
                return -ENODEV;