ftrace: Unify effect of writing to trace_options and option/*
authorZhaolei <zhaolei@cn.fujitsu.com>
Fri, 7 Aug 2009 10:55:48 +0000 (18:55 +0800)
committerFrederic Weisbecker <fweisbec@gmail.com>
Tue, 18 Aug 2009 00:07:04 +0000 (02:07 +0200)
"echo noglobal-clock > trace_options" can be used to change trace
clock but "echo 0 > options/global-clock" can't. The flag toggling
will be silently accepted without actually changing the clock callback.

We can fix it by using set_tracer_flags() in
trace_options_core_write().

Changelog:
v1->v2: Simplified switch() after Li Zefan <lizf@cn.fujitsu.com>'s
        suggestion

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Cc: Steven Rostedt <srostedt@redhat.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
kernel/trace/trace.c

index c22b40f8f576c19e7c00dec5e8f1983667e7b084..8c358395d33828f1b3b6f0023027bf9e06638296 100644 (file)
@@ -3896,17 +3896,9 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
        if (ret < 0)
                return ret;
 
-       switch (val) {
-       case 0:
-               trace_flags &= ~(1 << index);
-               break;
-       case 1:
-               trace_flags |= 1 << index;
-               break;
-
-       default:
+       if (val != 0 && val != 1)
                return -EINVAL;
-       }
+       set_tracer_flags(1 << index, val);
 
        *ppos += cnt;