diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-12-07 22:16:11 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2009-12-13 12:37:27 -0500 |
commit | 13f16d209161c95e92aef40e350cc6cf56ac440b (patch) | |
tree | a8e3bc78c7b07f5dab8776d91642d29ea1783fb8 /kernel/trace/trace.c | |
parent | fdb372ed4cadbfe9dbba0e932a77d0523682e690 (diff) |
tracing: Use seq file for trace_clock
The buffer for the output is as small as 64 bytes, so it'll
overflow if we add more clock type. Use seq file instead.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <4B1DC4FB.5030407@cn.fujitsu.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index a6c41cc63285..886268e0d8ee 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -3366,21 +3366,18 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, | |||
3366 | return cnt; | 3366 | return cnt; |
3367 | } | 3367 | } |
3368 | 3368 | ||
3369 | static ssize_t tracing_clock_read(struct file *filp, char __user *ubuf, | 3369 | static int tracing_clock_show(struct seq_file *m, void *v) |
3370 | size_t cnt, loff_t *ppos) | ||
3371 | { | 3370 | { |
3372 | char buf[64]; | ||
3373 | int bufiter = 0; | ||
3374 | int i; | 3371 | int i; |
3375 | 3372 | ||
3376 | for (i = 0; i < ARRAY_SIZE(trace_clocks); i++) | 3373 | for (i = 0; i < ARRAY_SIZE(trace_clocks); i++) |
3377 | bufiter += snprintf(buf + bufiter, sizeof(buf) - bufiter, | 3374 | seq_printf(m, |
3378 | "%s%s%s%s", i ? " " : "", | 3375 | "%s%s%s%s", i ? " " : "", |
3379 | i == trace_clock_id ? "[" : "", trace_clocks[i].name, | 3376 | i == trace_clock_id ? "[" : "", trace_clocks[i].name, |
3380 | i == trace_clock_id ? "]" : ""); | 3377 | i == trace_clock_id ? "]" : ""); |
3381 | bufiter += snprintf(buf + bufiter, sizeof(buf) - bufiter, "\n"); | 3378 | seq_putc(m, '\n'); |
3382 | 3379 | ||
3383 | return simple_read_from_buffer(ubuf, cnt, ppos, buf, bufiter); | 3380 | return 0; |
3384 | } | 3381 | } |
3385 | 3382 | ||
3386 | static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf, | 3383 | static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf, |
@@ -3422,6 +3419,13 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf, | |||
3422 | return cnt; | 3419 | return cnt; |
3423 | } | 3420 | } |
3424 | 3421 | ||
3422 | static int tracing_clock_open(struct inode *inode, struct file *file) | ||
3423 | { | ||
3424 | if (tracing_disabled) | ||
3425 | return -ENODEV; | ||
3426 | return single_open(file, tracing_clock_show, NULL); | ||
3427 | } | ||
3428 | |||
3425 | static const struct file_operations tracing_max_lat_fops = { | 3429 | static const struct file_operations tracing_max_lat_fops = { |
3426 | .open = tracing_open_generic, | 3430 | .open = tracing_open_generic, |
3427 | .read = tracing_max_lat_read, | 3431 | .read = tracing_max_lat_read, |
@@ -3460,8 +3464,10 @@ static const struct file_operations tracing_mark_fops = { | |||
3460 | }; | 3464 | }; |
3461 | 3465 | ||
3462 | static const struct file_operations trace_clock_fops = { | 3466 | static const struct file_operations trace_clock_fops = { |
3463 | .open = tracing_open_generic, | 3467 | .open = tracing_clock_open, |
3464 | .read = tracing_clock_read, | 3468 | .read = seq_read, |
3469 | .llseek = seq_lseek, | ||
3470 | .release = single_release, | ||
3465 | .write = tracing_clock_write, | 3471 | .write = tracing_clock_write, |
3466 | }; | 3472 | }; |
3467 | 3473 | ||