diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-05-07 22:32:05 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-08 08:00:36 -0400 |
commit | c142b15dc56ee6d55cb97a062e3c8e9c61e384c0 (patch) | |
tree | d273ba8c5ce28bea224e4f48b9704e47ed68a2b4 /kernel/trace | |
parent | 8f31bfe538ebafac187d2d4465a92e1d9ee6d8c2 (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')
-rw-r--r-- | kernel/trace/trace_events.c | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 45f1099386b6..df394bc6d54b 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -414,10 +414,11 @@ static ssize_t | |||
414 | system_enable_read(struct file *filp, char __user *ubuf, size_t cnt, | 414 | system_enable_read(struct file *filp, char __user *ubuf, size_t cnt, |
415 | loff_t *ppos) | 415 | loff_t *ppos) |
416 | { | 416 | { |
417 | const char set_to_char[4] = { '?', '0', '1', 'X' }; | ||
417 | const char *system = filp->private_data; | 418 | const char *system = filp->private_data; |
418 | struct ftrace_event_call *call; | 419 | struct ftrace_event_call *call; |
419 | char buf[2]; | 420 | char buf[2]; |
420 | int set = -1; | 421 | int set = 0; |
421 | int ret; | 422 | int ret; |
422 | 423 | ||
423 | mutex_lock(&event_mutex); | 424 | mutex_lock(&event_mutex); |
@@ -433,47 +434,18 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt, | |||
433 | * or if all events or cleared, or if we have | 434 | * or if all events or cleared, or if we have |
434 | * a mixture. | 435 | * a mixture. |
435 | */ | 436 | */ |
436 | if (call->enabled) { | 437 | set |= (1 << !!call->enabled); |
437 | switch (set) { | 438 | |
438 | case -1: | ||
439 | set = 1; | ||
440 | break; | ||
441 | case 0: | ||
442 | set = 2; | ||
443 | break; | ||
444 | } | ||
445 | } else { | ||
446 | switch (set) { | ||
447 | case -1: | ||
448 | set = 0; | ||
449 | break; | ||
450 | case 1: | ||
451 | set = 2; | ||
452 | break; | ||
453 | } | ||
454 | } | ||
455 | /* | 439 | /* |
456 | * If we have a mixture, no need to look further. | 440 | * If we have a mixture, no need to look further. |
457 | */ | 441 | */ |
458 | if (set == 2) | 442 | if (set == 3) |
459 | break; | 443 | break; |
460 | } | 444 | } |
461 | mutex_unlock(&event_mutex); | 445 | mutex_unlock(&event_mutex); |
462 | 446 | ||
447 | buf[0] = set_to_char[set]; | ||
463 | buf[1] = '\n'; | 448 | buf[1] = '\n'; |
464 | switch (set) { | ||
465 | case 0: | ||
466 | buf[0] = '0'; | ||
467 | break; | ||
468 | case 1: | ||
469 | buf[0] = '1'; | ||
470 | break; | ||
471 | case 2: | ||
472 | buf[0] = 'X'; | ||
473 | break; | ||
474 | default: | ||
475 | buf[0] = '?'; | ||
476 | } | ||
477 | 449 | ||
478 | ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, 2); | 450 | ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, 2); |
479 | 451 | ||