mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
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>
This commit is contained in:
parent
fdb372ed4c
commit
13f16d2091
1 changed files with 15 additions and 9 deletions
|
@ -3366,21 +3366,18 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t tracing_clock_read(struct file *filp, char __user *ubuf,
|
static int tracing_clock_show(struct seq_file *m, void *v)
|
||||||
size_t cnt, loff_t *ppos)
|
|
||||||
{
|
{
|
||||||
char buf[64];
|
|
||||||
int bufiter = 0;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(trace_clocks); i++)
|
for (i = 0; i < ARRAY_SIZE(trace_clocks); i++)
|
||||||
bufiter += snprintf(buf + bufiter, sizeof(buf) - bufiter,
|
seq_printf(m,
|
||||||
"%s%s%s%s", i ? " " : "",
|
"%s%s%s%s", i ? " " : "",
|
||||||
i == trace_clock_id ? "[" : "", trace_clocks[i].name,
|
i == trace_clock_id ? "[" : "", trace_clocks[i].name,
|
||||||
i == trace_clock_id ? "]" : "");
|
i == trace_clock_id ? "]" : "");
|
||||||
bufiter += snprintf(buf + bufiter, sizeof(buf) - bufiter, "\n");
|
seq_putc(m, '\n');
|
||||||
|
|
||||||
return simple_read_from_buffer(ubuf, cnt, ppos, buf, bufiter);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
|
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,
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tracing_clock_open(struct inode *inode, struct file *file)
|
||||||
|
{
|
||||||
|
if (tracing_disabled)
|
||||||
|
return -ENODEV;
|
||||||
|
return single_open(file, tracing_clock_show, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct file_operations tracing_max_lat_fops = {
|
static const struct file_operations tracing_max_lat_fops = {
|
||||||
.open = tracing_open_generic,
|
.open = tracing_open_generic,
|
||||||
.read = tracing_max_lat_read,
|
.read = tracing_max_lat_read,
|
||||||
|
@ -3460,8 +3464,10 @@ static const struct file_operations tracing_mark_fops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct file_operations trace_clock_fops = {
|
static const struct file_operations trace_clock_fops = {
|
||||||
.open = tracing_open_generic,
|
.open = tracing_clock_open,
|
||||||
.read = tracing_clock_read,
|
.read = seq_read,
|
||||||
|
.llseek = seq_lseek,
|
||||||
|
.release = single_release,
|
||||||
.write = tracing_clock_write,
|
.write = tracing_clock_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue