diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2009-02-09 15:05:50 -0500 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2009-03-30 12:26:56 -0400 |
commit | de5b31bd47de7e6f41be2e271318dbc8f1af354d (patch) | |
tree | d222e4ce03706e5047b78e060f85ed0b31727eaa /drivers/xen/xenbus/xenbus_probe.c | |
parent | a1ce1be578365a4da7e7d7db4812539d2d5da763 (diff) |
xen: use device model for suspending xenbus devices
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'drivers/xen/xenbus/xenbus_probe.c')
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe.c | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index bd20361fb099..4649213bed9e 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c | |||
@@ -71,6 +71,9 @@ static int xenbus_probe_frontend(const char *type, const char *name); | |||
71 | 71 | ||
72 | static void xenbus_dev_shutdown(struct device *_dev); | 72 | static void xenbus_dev_shutdown(struct device *_dev); |
73 | 73 | ||
74 | static int xenbus_dev_suspend(struct device *dev, pm_message_t state); | ||
75 | static int xenbus_dev_resume(struct device *dev); | ||
76 | |||
74 | /* If something in array of ids matches this device, return it. */ | 77 | /* If something in array of ids matches this device, return it. */ |
75 | static const struct xenbus_device_id * | 78 | static const struct xenbus_device_id * |
76 | match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev) | 79 | match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev) |
@@ -188,6 +191,9 @@ static struct xen_bus_type xenbus_frontend = { | |||
188 | .remove = xenbus_dev_remove, | 191 | .remove = xenbus_dev_remove, |
189 | .shutdown = xenbus_dev_shutdown, | 192 | .shutdown = xenbus_dev_shutdown, |
190 | .dev_attrs = xenbus_dev_attrs, | 193 | .dev_attrs = xenbus_dev_attrs, |
194 | |||
195 | .suspend = xenbus_dev_suspend, | ||
196 | .resume = xenbus_dev_resume, | ||
191 | }, | 197 | }, |
192 | }; | 198 | }; |
193 | 199 | ||
@@ -669,7 +675,7 @@ static struct xenbus_watch fe_watch = { | |||
669 | .callback = frontend_changed, | 675 | .callback = frontend_changed, |
670 | }; | 676 | }; |
671 | 677 | ||
672 | static int suspend_dev(struct device *dev, void *data) | 678 | static int xenbus_dev_suspend(struct device *dev, pm_message_t state) |
673 | { | 679 | { |
674 | int err = 0; | 680 | int err = 0; |
675 | struct xenbus_driver *drv; | 681 | struct xenbus_driver *drv; |
@@ -682,14 +688,14 @@ static int suspend_dev(struct device *dev, void *data) | |||
682 | drv = to_xenbus_driver(dev->driver); | 688 | drv = to_xenbus_driver(dev->driver); |
683 | xdev = container_of(dev, struct xenbus_device, dev); | 689 | xdev = container_of(dev, struct xenbus_device, dev); |
684 | if (drv->suspend) | 690 | if (drv->suspend) |
685 | err = drv->suspend(xdev); | 691 | err = drv->suspend(xdev, state); |
686 | if (err) | 692 | if (err) |
687 | printk(KERN_WARNING | 693 | printk(KERN_WARNING |
688 | "xenbus: suspend %s failed: %i\n", dev_name(dev), err); | 694 | "xenbus: suspend %s failed: %i\n", dev_name(dev), err); |
689 | return 0; | 695 | return 0; |
690 | } | 696 | } |
691 | 697 | ||
692 | static int resume_dev(struct device *dev, void *data) | 698 | static int xenbus_dev_resume(struct device *dev) |
693 | { | 699 | { |
694 | int err; | 700 | int err; |
695 | struct xenbus_driver *drv; | 701 | struct xenbus_driver *drv; |
@@ -734,31 +740,6 @@ static int resume_dev(struct device *dev, void *data) | |||
734 | return 0; | 740 | return 0; |
735 | } | 741 | } |
736 | 742 | ||
737 | void xenbus_suspend(void) | ||
738 | { | ||
739 | DPRINTK(""); | ||
740 | |||
741 | bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev); | ||
742 | xenbus_backend_suspend(suspend_dev); | ||
743 | xs_suspend(); | ||
744 | } | ||
745 | EXPORT_SYMBOL_GPL(xenbus_suspend); | ||
746 | |||
747 | void xenbus_resume(void) | ||
748 | { | ||
749 | xb_init_comms(); | ||
750 | xs_resume(); | ||
751 | bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev); | ||
752 | xenbus_backend_resume(resume_dev); | ||
753 | } | ||
754 | EXPORT_SYMBOL_GPL(xenbus_resume); | ||
755 | |||
756 | void xenbus_suspend_cancel(void) | ||
757 | { | ||
758 | xs_suspend_cancel(); | ||
759 | } | ||
760 | EXPORT_SYMBOL_GPL(xenbus_suspend_cancel); | ||
761 | |||
762 | /* A flag to determine if xenstored is 'ready' (i.e. has started) */ | 743 | /* A flag to determine if xenstored is 'ready' (i.e. has started) */ |
763 | int xenstored_ready = 0; | 744 | int xenstored_ready = 0; |
764 | 745 | ||