xen: suspend: refactor non-arch specific pre/post suspend hooks
authorIan Campbell <ian.campbell@citrix.com>
Thu, 17 Feb 2011 11:04:20 +0000 (11:04 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Fri, 25 Feb 2011 16:43:12 +0000 (16:43 +0000)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/xen/manage.c

index 134eb73ca59669dcc1ac081b0083e17cb63f30df..33312c09829e00f8432f24c8770d6c7d969596cf 100644 (file)
@@ -39,6 +39,23 @@ struct suspend_info {
        unsigned long arg; /* extra hypercall argument */
 };
 
+static void xen_hvm_post_suspend(void)
+{
+       gnttab_resume();
+}
+
+static void xen_pre_suspend(void)
+{
+       xen_mm_pin_all();
+       gnttab_suspend();
+}
+
+static void xen_post_suspend(void)
+{
+       gnttab_resume();
+       xen_mm_unpin_all();
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int xen_hvm_suspend(void *data)
 {
@@ -62,7 +79,7 @@ static int xen_hvm_suspend(void *data)
        si->cancelled = HYPERVISOR_suspend(si->arg);
 
        xen_arch_hvm_post_suspend(si->cancelled);
-       gnttab_resume();
+       xen_hvm_post_suspend();
 
        if (!si->cancelled) {
                xen_irq_resume();
@@ -89,8 +106,7 @@ static int xen_suspend(void *data)
                return err;
        }
 
-       xen_mm_pin_all();
-       gnttab_suspend();
+       xen_pre_suspend();
        xen_arch_pre_suspend();
 
        /*
@@ -101,8 +117,7 @@ static int xen_suspend(void *data)
        si->cancelled = HYPERVISOR_suspend(si->arg);
 
        xen_arch_post_suspend(si->cancelled);
-       gnttab_resume();
-       xen_mm_unpin_all();
+       xen_post_suspend();
 
        if (!si->cancelled) {
                xen_irq_resume();