aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/olpc
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2012-07-13 08:57:17 -0400
committerAndres Salomon <dilinger@queued.net>2012-07-31 23:27:30 -0400
commitac2504151f5af27bbf0c0362b7da5951e05dfc43 (patch)
tree21e163290e4e35e9151d50f90e58ce8c066c2f3c /drivers/platform/olpc
parent3d26c20bae9e97c98f7240184427d3a38515d406 (diff)
Platform: OLPC: turn EC driver into a platform_driver
The 1.75-based OLPC EC driver already does this; let's do it for all EC drivers. This gives us nice suspend/resume hooks, amongst other things. We want to run the EC's suspend hooks later than other drivers (which may be setting wakeup masks or be running EC commands). We also want to run the EC's resume hooks earlier than other drivers (which may want to run EC commands). Signed-off-by: Andres Salomon <dilinger@queued.net> Acked-by: Paul Fox <pgf@laptop.org> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/platform/olpc')
-rw-r--r--drivers/platform/olpc/olpc-ec.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 44e6a4fae79b..d00523c65191 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -8,6 +8,7 @@
8#include <linux/completion.h> 8#include <linux/completion.h>
9#include <linux/spinlock.h> 9#include <linux/spinlock.h>
10#include <linux/mutex.h> 10#include <linux/mutex.h>
11#include <linux/platform_device.h>
11#include <linux/workqueue.h> 12#include <linux/workqueue.h>
12#include <linux/module.h> 13#include <linux/module.h>
13#include <linux/list.h> 14#include <linux/list.h>
@@ -122,3 +123,50 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
122 return desc.err; 123 return desc.err;
123} 124}
124EXPORT_SYMBOL_GPL(olpc_ec_cmd); 125EXPORT_SYMBOL_GPL(olpc_ec_cmd);
126
127static int olpc_ec_probe(struct platform_device *pdev)
128{
129 int err;
130
131 if (!ec_driver)
132 return -ENODEV;
133
134 err = ec_driver->probe ? ec_driver->probe(pdev) : 0;
135
136 return err;
137}
138
139static int olpc_ec_suspend(struct device *dev)
140{
141 struct platform_device *pdev = to_platform_device(dev);
142 return ec_driver->suspend ? ec_driver->suspend(pdev) : 0;
143}
144
145static int olpc_ec_resume(struct device *dev)
146{
147 struct platform_device *pdev = to_platform_device(dev);
148 return ec_driver->resume ? ec_driver->resume(pdev) : 0;
149}
150
151static const struct dev_pm_ops olpc_ec_pm_ops = {
152 .suspend_late = olpc_ec_suspend,
153 .resume_early = olpc_ec_resume,
154};
155
156static struct platform_driver olpc_ec_plat_driver = {
157 .probe = olpc_ec_probe,
158 .driver = {
159 .name = "olpc-ec",
160 .pm = &olpc_ec_pm_ops,
161 },
162};
163
164static int __init olpc_ec_init_module(void)
165{
166 return platform_driver_register(&olpc_ec_plat_driver);
167}
168
169module_init(olpc_ec_init_module);
170
171MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
172MODULE_LICENSE("GPL");