patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / ieee1394 / nodemgr.c
index 1d22fe8..c912be4 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/moduleparam.h>
+#include <linux/suspend.h>
 #include <asm/atomic.h>
 
 #include "ieee1394_types.h"
@@ -1474,11 +1475,20 @@ static int nodemgr_host_thread(void *__hi)
 
        /* Sit and wait for a signal to probe the nodes on the bus. This
         * happens when we get a bus reset. */
-       while (!down_interruptible(&hi->reset_sem) &&
-              !down_interruptible(&nodemgr_serialize)) {
+       while (1) {
                unsigned int generation = 0;
                int i;
 
+               if (down_interruptible(&hi->reset_sem) ||
+                   down_interruptible(&nodemgr_serialize)) {
+                       if (current->flags & PF_FREEZE) {
+                               refrigerator(0);
+                               continue;
+                       }
+                       printk("NodeMgr: received unexpected signal?!\n" );
+                       break;
+               }
+
                if (hi->kill_me)
                        break;
 
@@ -1502,6 +1512,10 @@ static int nodemgr_host_thread(void *__hi)
                         * start the the waiting over again */
                        while (!down_trylock(&hi->reset_sem))
                                i = 0;
+
+                       /* Check the kill_me again */
+                       if (hi->kill_me)
+                               goto caught_signal;
                }
 
                if (!nodemgr_check_irm_capability(host, reset_cycles)) {
@@ -1702,12 +1716,23 @@ static struct hpsb_highlevel nodemgr_highlevel = {
        .remove_host =  nodemgr_remove_host,
 };
 
-void init_ieee1394_nodemgr(void)
+int init_ieee1394_nodemgr(void)
 {
-       class_register(&nodemgr_ne_class);
-       class_register(&nodemgr_ud_class);
+       int ret;
+
+       ret = class_register(&nodemgr_ne_class);
+       if (ret < 0)
+               return ret;
+
+       ret = class_register(&nodemgr_ud_class);
+       if (ret < 0) {
+               class_unregister(&nodemgr_ne_class);
+               return ret;
+       }
 
        hpsb_register_highlevel(&nodemgr_highlevel);
+
+       return 0;
 }
 
 void cleanup_ieee1394_nodemgr(void)