summaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_events.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2009-05-08 10:32:05 +0800
committerIngo Molnar <mingo@elte.hu>2009-05-08 14:00:36 +0200
commitc142b15dc56ee6d55cb97a062e3c8e9c61e384c0 (patch)
treed273ba8c5ce28bea224e4f48b9704e47ed68a2b4 /kernel/trace/trace_events.c
parent8f31bfe538ebafac187d2d4465a92e1d9ee6d8c2 (diff)
tracing/events: simplify system_enable_read()
A smarter way to figure out the output of an enable file. [ Impact: clean up ] Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <4A0399A5.2080603@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_events.c')
-rw-r--r--kernel/trace/trace_events.c40
1 files changed, 6 insertions, 34 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 45f1099386b..df394bc6d54 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -414,10 +414,11 @@ static ssize_t
system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
loff_t *ppos)
{
+ const char set_to_char[4] = { '?', '0', '1', 'X' };
const char *system = filp->private_data;
struct ftrace_event_call *call;
char buf[2];
- int set = -1;
+ int set = 0;
int ret;
mutex_lock(&event_mutex);
@@ -433,47 +434,18 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
* or if all events or cleared, or if we have
* a mixture.
*/
- if (call->enabled) {
- switch (set) {
- case -1:
- set = 1;
- break;
- case 0:
- set = 2;
- break;
- }
- } else {
- switch (set) {
- case -1:
- set = 0;
- break;
- case 1:
- set = 2;
- break;
- }
- }
+ set |= (1 << !!call->enabled);
+
/*
* If we have a mixture, no need to look further.
*/
- if (set == 2)
+ if (set == 3)
break;
}
mutex_unlock(&event_mutex);
+ buf[0] = set_to_char[set];
buf[1] = '\n';
- switch (set) {
- case 0:
- buf[0] = '0';
- break;
- case 1:
- buf[0] = '1';
- break;
- case 2:
- buf[0] = 'X';
- break;
- default:
- buf[0] = '?';
- }
ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);