diff options
| -rw-r--r-- | drivers/platform/olpc/olpc-ec.c | 48 | ||||
| -rw-r--r-- | include/linux/olpc-ec.h | 6 |
2 files changed, 54 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 | } |
| 124 | EXPORT_SYMBOL_GPL(olpc_ec_cmd); | 125 | 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"); | ||
diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h index 231e96f5dfe2..5bb6e760aa61 100644 --- a/include/linux/olpc-ec.h +++ b/include/linux/olpc-ec.h | |||
| @@ -14,7 +14,13 @@ | |||
| 14 | #define EC_SCI_QUERY 0x84 | 14 | #define EC_SCI_QUERY 0x84 |
| 15 | #define EC_EXT_SCI_QUERY 0x85 | 15 | #define EC_EXT_SCI_QUERY 0x85 |
| 16 | 16 | ||
| 17 | struct platform_device; | ||
| 18 | |||
| 17 | struct olpc_ec_driver { | 19 | struct olpc_ec_driver { |
| 20 | int (*probe)(struct platform_device *); | ||
| 21 | int (*suspend)(struct platform_device *); | ||
| 22 | int (*resume)(struct platform_device *); | ||
| 23 | |||
| 18 | int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *); | 24 | int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *); |
| 19 | }; | 25 | }; |
| 20 | 26 | ||
