Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c317143 authored by Steven Rostedt (Red Hat)'s avatar Steven Rostedt (Red Hat) Committed by Steven Rostedt
Browse files

tracing: Consolidate updating of count for traceon/off



Remove some duplicate code and replace it with a helper function.
This makes the code a it cleaner.

Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 1b22e382
Loading
Loading
Loading
Loading
+16 −17
Original line number Diff line number Diff line
@@ -214,37 +214,36 @@ 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)--;

	return 1;
}

static void
ftrace_traceon(unsigned long ip, unsigned long parent_ip, void **data)
{
	if (tracing_is_on())
		return;

	if (update_count(data))
		tracing_on();
}

static void
ftrace_traceoff(unsigned long ip, unsigned long parent_ip, void **data)
{
	long *count = (long *)data;

	if (!tracing_is_on())
		return;

	if (!*count)
		return;

	if (*count != -1)
		(*count)--;

	if (update_count(data))
		tracing_off();
}