Commit 30bd39cd authored by Li Zefan's avatar Li Zefan Committed by Steven Rostedt

tracing/events: use list_for_entry_continue

Simplify s_next() and t_next().
Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4AB32389.1030005@cn.fujitsu.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent ee6c2c1b
...@@ -271,42 +271,32 @@ ftrace_event_write(struct file *file, const char __user *ubuf, ...@@ -271,42 +271,32 @@ ftrace_event_write(struct file *file, const char __user *ubuf,
static void * static void *
t_next(struct seq_file *m, void *v, loff_t *pos) t_next(struct seq_file *m, void *v, loff_t *pos)
{ {
struct list_head *list = m->private; struct ftrace_event_call *call = v;
struct ftrace_event_call *call;
(*pos)++; (*pos)++;
for (;;) { list_for_each_entry_continue(call, &ftrace_events, list) {
if (list == &ftrace_events)
return NULL;
call = list_entry(list, struct ftrace_event_call, list);
/* /*
* The ftrace subsystem is for showing formats only. * The ftrace subsystem is for showing formats only.
* They can not be enabled or disabled via the event files. * They can not be enabled or disabled via the event files.
*/ */
if (call->regfunc) if (call->regfunc)
break; return call;
list = list->next;
} }
m->private = list->next; return NULL;
return call;
} }
static void *t_start(struct seq_file *m, loff_t *pos) static void *t_start(struct seq_file *m, loff_t *pos)
{ {
struct ftrace_event_call *call = NULL; struct ftrace_event_call *call;
loff_t l; loff_t l;
mutex_lock(&event_mutex); mutex_lock(&event_mutex);
m->private = ftrace_events.next; call = list_entry(&ftrace_events, struct ftrace_event_call, list);
for (l = 0; l <= *pos; ) { for (l = 0; l <= *pos; ) {
call = t_next(m, NULL, &l); call = t_next(m, call, &l);
if (!call) if (!call)
break; break;
} }
...@@ -316,37 +306,28 @@ static void *t_start(struct seq_file *m, loff_t *pos) ...@@ -316,37 +306,28 @@ static void *t_start(struct seq_file *m, loff_t *pos)
static void * static void *
s_next(struct seq_file *m, void *v, loff_t *pos) s_next(struct seq_file *m, void *v, loff_t *pos)
{ {
struct list_head *list = m->private; struct ftrace_event_call *call = v;
struct ftrace_event_call *call;
(*pos)++; (*pos)++;
retry: list_for_each_entry_continue(call, &ftrace_events, list) {
if (list == &ftrace_events) if (call->enabled)
return NULL; return call;
call = list_entry(list, struct ftrace_event_call, list);
if (!call->enabled) {
list = list->next;
goto retry;
} }
m->private = list->next; return NULL;
return call;
} }
static void *s_start(struct seq_file *m, loff_t *pos) static void *s_start(struct seq_file *m, loff_t *pos)
{ {
struct ftrace_event_call *call = NULL; struct ftrace_event_call *call;
loff_t l; loff_t l;
mutex_lock(&event_mutex); mutex_lock(&event_mutex);
m->private = ftrace_events.next; call = list_entry(&ftrace_events, struct ftrace_event_call, list);
for (l = 0; l <= *pos; ) { for (l = 0; l <= *pos; ) {
call = s_next(m, NULL, &l); call = s_next(m, call, &l);
if (!call) if (!call)
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment