Skip to content

Commit ac25041

Browse files
committed
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>
1 parent 3d26c20 commit ac25041

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

drivers/platform/olpc/olpc-ec.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/completion.h>
99
#include <linux/spinlock.h>
1010
#include <linux/mutex.h>
11+
#include <linux/platform_device.h>
1112
#include <linux/workqueue.h>
1213
#include <linux/module.h>
1314
#include <linux/list.h>
@@ -122,3 +123,50 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
122123
return desc.err;
123124
}
124125
EXPORT_SYMBOL_GPL(olpc_ec_cmd);
126+
127+
static 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+
139+
static 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+
145+
static 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+
151+
static const struct dev_pm_ops olpc_ec_pm_ops = {
152+
.suspend_late = olpc_ec_suspend,
153+
.resume_early = olpc_ec_resume,
154+
};
155+
156+
static 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+
164+
static int __init olpc_ec_init_module(void)
165+
{
166+
return platform_driver_register(&olpc_ec_plat_driver);
167+
}
168+
169+
module_init(olpc_ec_init_module);
170+
171+
MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
172+
MODULE_LICENSE("GPL");

include/linux/olpc-ec.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
#define EC_SCI_QUERY 0x84
1515
#define EC_EXT_SCI_QUERY 0x85
1616

17+
struct platform_device;
18+
1719
struct olpc_ec_driver {
20+
int (*probe)(struct platform_device *);
21+
int (*suspend)(struct platform_device *);
22+
int (*resume)(struct platform_device *);
23+
1824
int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *);
1925
};
2026

0 commit comments

Comments
 (0)