xen: fix build when SYSRQ is disabled
[safe/jmp/linux-2.6] / drivers / xen / manage.c
index 7b69a1a..07e857b 100644 (file)
@@ -3,6 +3,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/reboot.h>
 #include <linux/sysrq.h>
 #include <linux/stop_machine.h>
@@ -86,14 +87,14 @@ static void do_suspend(void)
        err = freeze_processes();
        if (err) {
                printk(KERN_ERR "xen suspend: freeze failed %d\n", err);
-               return;
+               goto out;
        }
 #endif
 
        err = dpm_suspend_start(PMSG_SUSPEND);
        if (err) {
                printk(KERN_ERR "xen suspend: dpm_suspend_start %d\n", err);
-               goto out;
+               goto out_thaw;
        }
 
        printk(KERN_DEBUG "suspending xenstore...\n");
@@ -102,7 +103,7 @@ static void do_suspend(void)
        err = dpm_suspend_noirq(PMSG_SUSPEND);
        if (err) {
                printk(KERN_ERR "dpm_suspend_noirq failed: %d\n", err);
-               goto resume_devices;
+               goto out_resume;
        }
 
        err = stop_machine(xen_suspend, &cancelled, cpumask_of(0));
@@ -111,23 +112,25 @@ static void do_suspend(void)
 
        if (err) {
                printk(KERN_ERR "failed to start xen_suspend: %d\n", err);
-               goto out;
+               cancelled = 1;
        }
 
+out_resume:
        if (!cancelled) {
                xen_arch_resume();
                xs_resume();
        } else
                xs_suspend_cancel();
 
-resume_devices:
        dpm_resume_end(PMSG_RESUME);
 
        /* Make sure timer events get retriggered on all CPUs */
        clock_was_set();
-out:
+
+out_thaw:
 #ifdef CONFIG_PREEMPT
        thaw_processes();
+out:
 #endif
        shutting_down = SHUTDOWN_INVALID;
 }
@@ -182,6 +185,7 @@ static void shutdown_handler(struct xenbus_watch *watch,
        kfree(str);
 }
 
+#ifdef CONFIG_MAGIC_SYSRQ
 static void sysrq_handler(struct xenbus_watch *watch, const char **vec,
                          unsigned int len)
 {
@@ -211,15 +215,16 @@ static void sysrq_handler(struct xenbus_watch *watch, const char **vec,
                handle_sysrq(sysrq_key, NULL);
 }
 
-static struct xenbus_watch shutdown_watch = {
-       .node = "control/shutdown",
-       .callback = shutdown_handler
-};
-
 static struct xenbus_watch sysrq_watch = {
        .node = "control/sysrq",
        .callback = sysrq_handler
 };
+#endif
+
+static struct xenbus_watch shutdown_watch = {
+       .node = "control/shutdown",
+       .callback = shutdown_handler
+};
 
 static int setup_shutdown_watcher(void)
 {
@@ -231,11 +236,13 @@ static int setup_shutdown_watcher(void)
                return err;
        }
 
+#ifdef CONFIG_MAGIC_SYSRQ
        err = register_xenbus_watch(&sysrq_watch);
        if (err) {
                printk(KERN_ERR "Failed to set sysrq watcher\n");
                return err;
        }
+#endif
 
        return 0;
 }