Merge master.kernel.org:/home/rmk/linux-2.6-arm
[safe/jmp/linux-2.6] / drivers / macintosh / windfarm_core.c
index 6c0ba04..ce88979 100644 (file)
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
-#include <linux/smp_lock.h>
 #include <linux/kthread.h>
 #include <linux/jiffies.h>
 #include <linux/reboot.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
+#include <linux/freezer.h>
 
 #include <asm/prom.h>
 
@@ -52,7 +53,7 @@
 static LIST_HEAD(wf_controls);
 static LIST_HEAD(wf_sensors);
 static DEFINE_MUTEX(wf_lock);
-static struct notifier_block *wf_client_list;
+static BLOCKING_NOTIFIER_HEAD(wf_client_list);
 static int wf_client_count;
 static unsigned int wf_overtemp;
 static unsigned int wf_overtemp_counter;
@@ -68,7 +69,7 @@ static struct platform_device wf_platform_device = {
 
 static inline void wf_notify(int event, void *param)
 {
-       notifier_call_chain(&wf_client_list, event, param);
+       blocking_notifier_call_chain(&wf_client_list, event, param);
 }
 
 int wf_critical_overtemp(void)
@@ -80,7 +81,8 @@ int wf_critical_overtemp(void)
                                "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
                                NULL };
 
-       return call_usermodehelper(critical_overtemp_path, argv, envp, 0);
+       return call_usermodehelper(critical_overtemp_path,
+                                  argv, envp, UMH_WAIT_EXEC);
 }
 EXPORT_SYMBOL_GPL(wf_critical_overtemp);
 
@@ -92,7 +94,8 @@ static int wf_thread_func(void *data)
 
        DBG("wf: thread started\n");
 
-       while(!kthread_should_stop()) {
+       set_freezable();
+       while (!kthread_should_stop()) {
                try_to_freeze();
 
                if (time_after_eq(jiffies, next)) {
@@ -116,12 +119,6 @@ static int wf_thread_func(void *data)
                delay = next - jiffies;
                if (delay <= HZ)
                        schedule_timeout_interruptible(delay);
-
-               /* there should be no signal, but oh well */
-               if (signal_pending(current)) {
-                       printk(KERN_WARNING "windfarm: thread got sigl !\n");
-                       break;
-               }
        }
 
        DBG("wf: thread stopped\n");
@@ -213,12 +210,15 @@ int wf_register_control(struct wf_control *new_ct)
        kref_init(&new_ct->ref);
        list_add(&new_ct->link, &wf_controls);
 
+       sysfs_attr_init(&new_ct->attr.attr);
        new_ct->attr.attr.name = new_ct->name;
-       new_ct->attr.attr.owner = THIS_MODULE;
        new_ct->attr.attr.mode = 0644;
        new_ct->attr.show = wf_show_control;
        new_ct->attr.store = wf_store_control;
-       device_create_file(&wf_platform_device.dev, &new_ct->attr);
+       if (device_create_file(&wf_platform_device.dev, &new_ct->attr))
+               printk(KERN_WARNING "windfarm: device_create_file failed"
+                       " for %s\n", new_ct->name);
+               /* the subsystem still does useful work without the file */
 
        DBG("wf: Registered control %s\n", new_ct->name);
 
@@ -323,12 +323,15 @@ int wf_register_sensor(struct wf_sensor *new_sr)
        kref_init(&new_sr->ref);
        list_add(&new_sr->link, &wf_sensors);
 
+       sysfs_attr_init(&new_sr->attr.attr);
        new_sr->attr.attr.name = new_sr->name;
-       new_sr->attr.attr.owner = THIS_MODULE;
        new_sr->attr.attr.mode = 0444;
        new_sr->attr.show = wf_show_sensor;
        new_sr->attr.store = NULL;
-       device_create_file(&wf_platform_device.dev, &new_sr->attr);
+       if (device_create_file(&wf_platform_device.dev, &new_sr->attr))
+               printk(KERN_WARNING "windfarm: device_create_file failed"
+                       " for %s\n", new_sr->name);
+               /* the subsystem still does useful work without the file */
 
        DBG("wf: Registered sensor %s\n", new_sr->name);
 
@@ -398,7 +401,7 @@ int wf_register_client(struct notifier_block *nb)
        struct wf_sensor *sr;
 
        mutex_lock(&wf_lock);
-       rc = notifier_chain_register(&wf_client_list, nb);
+       rc = blocking_notifier_chain_register(&wf_client_list, nb);
        if (rc != 0)
                goto bail;
        wf_client_count++;
@@ -417,7 +420,7 @@ EXPORT_SYMBOL_GPL(wf_register_client);
 int wf_unregister_client(struct notifier_block *nb)
 {
        mutex_lock(&wf_lock);
-       notifier_chain_unregister(&wf_client_list, nb);
+       blocking_notifier_chain_unregister(&wf_client_list, nb);
        wf_client_count++;
        if (wf_client_count == 0)
                wf_stop_thread();
@@ -468,9 +471,9 @@ static int __init windfarm_core_init(void)
        DBG("wf: core loaded\n");
 
        /* Don't register on old machines that use therm_pm72 for now */
-       if (machine_is_compatible("PowerMac7,2") ||
-           machine_is_compatible("PowerMac7,3") ||
-           machine_is_compatible("RackMac3,1"))
+       if (of_machine_is_compatible("PowerMac7,2") ||
+           of_machine_is_compatible("PowerMac7,3") ||
+           of_machine_is_compatible("RackMac3,1"))
                return -ENODEV;
        platform_device_register(&wf_platform_device);
        return 0;