diff options
author | Andres Salomon <dilinger@queued.net> | 2012-07-12 23:45:14 -0400 |
---|---|---|
committer | Andres Salomon <dilinger@queued.net> | 2012-07-31 23:27:31 -0400 |
commit | 6cca83d498bda0999302079bd59786370590c5c2 (patch) | |
tree | 2827895b5552696013d6809c3313b02578673ef3 /arch/x86 | |
parent | 85f90cf6ca569b19cee212844b543a7355b77163 (diff) |
Platform: OLPC: move debugfs support from x86 EC driver
There's nothing about the debugfs interface for the EC driver that is
architecture-specific, so move it into the arch-independent driver.
The code is mostly unchanged with the exception of renamed variables, coding
style changes, and API updates.
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 'arch/x86')
-rw-r--r-- | arch/x86/platform/olpc/olpc.c | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c index 45900968fb89..ed41b437b37b 100644 --- a/arch/x86/platform/olpc/olpc.c +++ b/arch/x86/platform/olpc/olpc.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/of.h> | 20 | #include <linux/of.h> |
21 | #include <linux/syscore_ops.h> | 21 | #include <linux/syscore_ops.h> |
22 | #include <linux/debugfs.h> | ||
23 | #include <linux/mutex.h> | 22 | #include <linux/mutex.h> |
24 | #include <linux/olpc-ec.h> | 23 | #include <linux/olpc-ec.h> |
25 | 24 | ||
@@ -31,15 +30,6 @@ | |||
31 | struct olpc_platform_t olpc_platform_info; | 30 | struct olpc_platform_t olpc_platform_info; |
32 | EXPORT_SYMBOL_GPL(olpc_platform_info); | 31 | EXPORT_SYMBOL_GPL(olpc_platform_info); |
33 | 32 | ||
34 | /* debugfs interface to EC commands */ | ||
35 | #define EC_MAX_CMD_ARGS (5 + 1) /* cmd byte + 5 args */ | ||
36 | #define EC_MAX_CMD_REPLY (8) | ||
37 | |||
38 | static struct dentry *ec_debugfs_dir; | ||
39 | static DEFINE_MUTEX(ec_debugfs_cmd_lock); | ||
40 | static unsigned char ec_debugfs_resp[EC_MAX_CMD_REPLY]; | ||
41 | static unsigned int ec_debugfs_resp_bytes; | ||
42 | |||
43 | /* EC event mask to be applied during suspend (defining wakeup sources). */ | 33 | /* EC event mask to be applied during suspend (defining wakeup sources). */ |
44 | static u16 ec_wakeup_mask; | 34 | static u16 ec_wakeup_mask; |
45 | 35 | ||
@@ -273,91 +263,6 @@ int olpc_ec_sci_query(u16 *sci_value) | |||
273 | } | 263 | } |
274 | EXPORT_SYMBOL_GPL(olpc_ec_sci_query); | 264 | EXPORT_SYMBOL_GPL(olpc_ec_sci_query); |
275 | 265 | ||
276 | static ssize_t ec_debugfs_cmd_write(struct file *file, const char __user *buf, | ||
277 | size_t size, loff_t *ppos) | ||
278 | { | ||
279 | int i, m; | ||
280 | unsigned char ec_cmd[EC_MAX_CMD_ARGS]; | ||
281 | unsigned int ec_cmd_int[EC_MAX_CMD_ARGS]; | ||
282 | char cmdbuf[64]; | ||
283 | int ec_cmd_bytes; | ||
284 | |||
285 | mutex_lock(&ec_debugfs_cmd_lock); | ||
286 | |||
287 | size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size); | ||
288 | |||
289 | m = sscanf(cmdbuf, "%x:%u %x %x %x %x %x", &ec_cmd_int[0], | ||
290 | &ec_debugfs_resp_bytes, | ||
291 | &ec_cmd_int[1], &ec_cmd_int[2], &ec_cmd_int[3], | ||
292 | &ec_cmd_int[4], &ec_cmd_int[5]); | ||
293 | if (m < 2 || ec_debugfs_resp_bytes > EC_MAX_CMD_REPLY) { | ||
294 | /* reset to prevent overflow on read */ | ||
295 | ec_debugfs_resp_bytes = 0; | ||
296 | |||
297 | printk(KERN_DEBUG "olpc-ec: bad ec cmd: " | ||
298 | "cmd:response-count [arg1 [arg2 ...]]\n"); | ||
299 | size = -EINVAL; | ||
300 | goto out; | ||
301 | } | ||
302 | |||
303 | /* convert scanf'd ints to char */ | ||
304 | ec_cmd_bytes = m - 2; | ||
305 | for (i = 0; i <= ec_cmd_bytes; i++) | ||
306 | ec_cmd[i] = ec_cmd_int[i]; | ||
307 | |||
308 | printk(KERN_DEBUG "olpc-ec: debugfs cmd 0x%02x with %d args " | ||
309 | "%02x %02x %02x %02x %02x, want %d returns\n", | ||
310 | ec_cmd[0], ec_cmd_bytes, ec_cmd[1], ec_cmd[2], ec_cmd[3], | ||
311 | ec_cmd[4], ec_cmd[5], ec_debugfs_resp_bytes); | ||
312 | |||
313 | olpc_ec_cmd(ec_cmd[0], (ec_cmd_bytes == 0) ? NULL : &ec_cmd[1], | ||
314 | ec_cmd_bytes, ec_debugfs_resp, ec_debugfs_resp_bytes); | ||
315 | |||
316 | printk(KERN_DEBUG "olpc-ec: response " | ||
317 | "%02x %02x %02x %02x %02x %02x %02x %02x (%d bytes expected)\n", | ||
318 | ec_debugfs_resp[0], ec_debugfs_resp[1], ec_debugfs_resp[2], | ||
319 | ec_debugfs_resp[3], ec_debugfs_resp[4], ec_debugfs_resp[5], | ||
320 | ec_debugfs_resp[6], ec_debugfs_resp[7], ec_debugfs_resp_bytes); | ||
321 | |||
322 | out: | ||
323 | mutex_unlock(&ec_debugfs_cmd_lock); | ||
324 | return size; | ||
325 | } | ||
326 | |||
327 | static ssize_t ec_debugfs_cmd_read(struct file *file, char __user *buf, | ||
328 | size_t size, loff_t *ppos) | ||
329 | { | ||
330 | unsigned int i, r; | ||
331 | char *rp; | ||
332 | char respbuf[64]; | ||
333 | |||
334 | mutex_lock(&ec_debugfs_cmd_lock); | ||
335 | rp = respbuf; | ||
336 | rp += sprintf(rp, "%02x", ec_debugfs_resp[0]); | ||
337 | for (i = 1; i < ec_debugfs_resp_bytes; i++) | ||
338 | rp += sprintf(rp, ", %02x", ec_debugfs_resp[i]); | ||
339 | mutex_unlock(&ec_debugfs_cmd_lock); | ||
340 | rp += sprintf(rp, "\n"); | ||
341 | |||
342 | r = rp - respbuf; | ||
343 | return simple_read_from_buffer(buf, size, ppos, respbuf, r); | ||
344 | } | ||
345 | |||
346 | static const struct file_operations ec_debugfs_genops = { | ||
347 | .write = ec_debugfs_cmd_write, | ||
348 | .read = ec_debugfs_cmd_read, | ||
349 | }; | ||
350 | |||
351 | static void setup_debugfs(void) | ||
352 | { | ||
353 | ec_debugfs_dir = debugfs_create_dir("olpc-ec", 0); | ||
354 | if (ec_debugfs_dir == ERR_PTR(-ENODEV)) | ||
355 | return; | ||
356 | |||
357 | debugfs_create_file("cmd", 0600, ec_debugfs_dir, NULL, | ||
358 | &ec_debugfs_genops); | ||
359 | } | ||
360 | |||
361 | static int olpc_ec_suspend(struct platform_device *pdev) | 266 | static int olpc_ec_suspend(struct platform_device *pdev) |
362 | { | 267 | { |
363 | return olpc_ec_mask_write(ec_wakeup_mask); | 268 | return olpc_ec_mask_write(ec_wakeup_mask); |
@@ -470,8 +375,6 @@ static int __init olpc_init(void) | |||
470 | return r; | 375 | return r; |
471 | } | 376 | } |
472 | 377 | ||
473 | setup_debugfs(); | ||
474 | |||
475 | return 0; | 378 | return 0; |
476 | } | 379 | } |
477 | 380 | ||