aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-01-10 11:14:53 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-10 11:14:53 -0500
commitc8940eca75e6d1ea57f6c491a30bd1023c64c9ad (patch)
treed68944ab9fa8ba3c77b18edc2bd836c7e355b23e /drivers/spi
parent78c92a9fd4b6abbbc1fe1ec335c697cb4e63f252 (diff)
parent3ae22e8c8ac39daf88ae32f047fb23825be7c646 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6: spi / PM: Support dev_pm_ops PM: Prototype the pm_generic_ operations PM / Runtime: Generic resume shouldn't set RPM_ACTIVE unconditionally PM: Use dev_name() in core device suspend and resume routines PM: Permit registration of parentless devices during system suspend PM: Replace the device power.status field with a bit field PM: Remove redundant checks from core device resume routines PM: Use a different list of devices for each stage of device suspend PM: Avoid compiler warning in pm_noirq_op() PM: Use pm_wakeup_pending() in __device_suspend() PM / Wakeup: Replace pm_check_wakeup_events() with pm_wakeup_pending() PM: Prevent dpm_prepare() from returning errors unnecessarily PM: Fix references to basic-pm-debugging.txt in drivers-testing.txt PM / Runtime: Add synchronous runtime interface for interrupt handlers (v3) PM / Hibernate: When failed, in_suspend should be reset PM / Hibernate: hibernation_ops->leave should be checked too Freezer: Fix a race during freezing of TASK_STOPPED tasks PM: Use proper ccflag flag in kernel/power/Makefile PM / Runtime: Fix comments to match runtime callback code
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi.c92
1 files changed, 84 insertions, 8 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index b02d0cbce890..34bb17f03019 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -28,6 +28,7 @@
28#include <linux/mod_devicetable.h> 28#include <linux/mod_devicetable.h>
29#include <linux/spi/spi.h> 29#include <linux/spi/spi.h>
30#include <linux/of_spi.h> 30#include <linux/of_spi.h>
31#include <linux/pm_runtime.h>
31 32
32static void spidev_release(struct device *dev) 33static void spidev_release(struct device *dev)
33{ 34{
@@ -100,9 +101,8 @@ static int spi_uevent(struct device *dev, struct kobj_uevent_env *env)
100 return 0; 101 return 0;
101} 102}
102 103
103#ifdef CONFIG_PM 104#ifdef CONFIG_PM_SLEEP
104 105static int spi_legacy_suspend(struct device *dev, pm_message_t message)
105static int spi_suspend(struct device *dev, pm_message_t message)
106{ 106{
107 int value = 0; 107 int value = 0;
108 struct spi_driver *drv = to_spi_driver(dev->driver); 108 struct spi_driver *drv = to_spi_driver(dev->driver);
@@ -117,7 +117,7 @@ static int spi_suspend(struct device *dev, pm_message_t message)
117 return value; 117 return value;
118} 118}
119 119
120static int spi_resume(struct device *dev) 120static int spi_legacy_resume(struct device *dev)
121{ 121{
122 int value = 0; 122 int value = 0;
123 struct spi_driver *drv = to_spi_driver(dev->driver); 123 struct spi_driver *drv = to_spi_driver(dev->driver);
@@ -132,18 +132,94 @@ static int spi_resume(struct device *dev)
132 return value; 132 return value;
133} 133}
134 134
135static int spi_pm_suspend(struct device *dev)
136{
137 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
138
139 if (pm)
140 return pm_generic_suspend(dev);
141 else
142 return spi_legacy_suspend(dev, PMSG_SUSPEND);
143}
144
145static int spi_pm_resume(struct device *dev)
146{
147 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
148
149 if (pm)
150 return pm_generic_resume(dev);
151 else
152 return spi_legacy_resume(dev);
153}
154
155static int spi_pm_freeze(struct device *dev)
156{
157 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
158
159 if (pm)
160 return pm_generic_freeze(dev);
161 else
162 return spi_legacy_suspend(dev, PMSG_FREEZE);
163}
164
165static int spi_pm_thaw(struct device *dev)
166{
167 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
168
169 if (pm)
170 return pm_generic_thaw(dev);
171 else
172 return spi_legacy_resume(dev);
173}
174
175static int spi_pm_poweroff(struct device *dev)
176{
177 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
178
179 if (pm)
180 return pm_generic_poweroff(dev);
181 else
182 return spi_legacy_suspend(dev, PMSG_HIBERNATE);
183}
184
185static int spi_pm_restore(struct device *dev)
186{
187 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
188
189 if (pm)
190 return pm_generic_restore(dev);
191 else
192 return spi_legacy_resume(dev);
193}
135#else 194#else
136#define spi_suspend NULL 195#define spi_pm_suspend NULL
137#define spi_resume NULL 196#define spi_pm_resume NULL
197#define spi_pm_freeze NULL
198#define spi_pm_thaw NULL
199#define spi_pm_poweroff NULL
200#define spi_pm_restore NULL
138#endif 201#endif
139 202
203static const struct dev_pm_ops spi_pm = {
204 .suspend = spi_pm_suspend,
205 .resume = spi_pm_resume,
206 .freeze = spi_pm_freeze,
207 .thaw = spi_pm_thaw,
208 .poweroff = spi_pm_poweroff,
209 .restore = spi_pm_restore,
210 SET_RUNTIME_PM_OPS(
211 pm_generic_runtime_suspend,
212 pm_generic_runtime_resume,
213 pm_generic_runtime_idle
214 )
215};
216
140struct bus_type spi_bus_type = { 217struct bus_type spi_bus_type = {
141 .name = "spi", 218 .name = "spi",
142 .dev_attrs = spi_dev_attrs, 219 .dev_attrs = spi_dev_attrs,
143 .match = spi_match_device, 220 .match = spi_match_device,
144 .uevent = spi_uevent, 221 .uevent = spi_uevent,
145 .suspend = spi_suspend, 222 .pm = &spi_pm,
146 .resume = spi_resume,
147}; 223};
148EXPORT_SYMBOL_GPL(spi_bus_type); 224EXPORT_SYMBOL_GPL(spi_bus_type);
149 225