tracing: Consolidate updating of count for traceon/off
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Sat, 9 Mar 2013 13:36:53 +0000 (08:36 -0500)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 15 Mar 2013 04:35:58 +0000 (00:35 -0400)
Remove some duplicate code and replace it with a helper function.
This makes the code a it cleaner.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_functions.c

index e467c0c7bdd567663bf7f1275aed5a69949c058f..38cfb290ecd9516d8292264ed987e4c886224e03 100644 (file)
@@ -214,38 +214,37 @@ static struct tracer function_trace __read_mostly =
 };
 
 #ifdef CONFIG_DYNAMIC_FTRACE
-static void
-ftrace_traceon(unsigned long ip, unsigned long parent_ip, void **data)
+static int update_count(void **data)
 {
-       long *count = (long *)data;
-
-       if (tracing_is_on())
-               return;
+       unsigned long *count = (long *)data;
 
        if (!*count)
-               return;
+               return 0;
 
        if (*count != -1)
                (*count)--;
 
-       tracing_on();
+       return 1;
 }
 
 static void
-ftrace_traceoff(unsigned long ip, unsigned long parent_ip, void **data)
+ftrace_traceon(unsigned long ip, unsigned long parent_ip, void **data)
 {
-       long *count = (long *)data;
-
-       if (!tracing_is_on())
+       if (tracing_is_on())
                return;
 
-       if (!*count)
-               return;
+       if (update_count(data))
+               tracing_on();
+}
 
-       if (*count != -1)
-               (*count)--;
+static void
+ftrace_traceoff(unsigned long ip, unsigned long parent_ip, void **data)
+{
+       if (!tracing_is_on())
+               return;
 
-       tracing_off();
+       if (update_count(data))
+               tracing_off();
 }
 
 static int