aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_events.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-29 14:50:17 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-29 14:50:17 -0400
commit9c5891bd4342349a200676d33f742dd1b864822c (patch)
treeb14c1698f2d8ce5276e1befd562f6398a46b48b9 /kernel/trace/trace_events.c
parentecda040ff3724f021a96491ecee88d48e968c153 (diff)
parent5ae90d8e467e625e447000cb4335c4db973b1095 (diff)
Merge 3.11-rc3 into char-misc-next.
This resolves a merge issue with: drivers/misc/mei/init.c Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/trace/trace_events.c')
-rw-r--r--kernel/trace/trace_events.c98
1 files changed, 45 insertions, 53 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 7d854290bf81..898f868833f2 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -826,59 +826,33 @@ enum {
826static void *f_next(struct seq_file *m, void *v, loff_t *pos) 826static void *f_next(struct seq_file *m, void *v, loff_t *pos)
827{ 827{
828 struct ftrace_event_call *call = m->private; 828 struct ftrace_event_call *call = m->private;
829 struct ftrace_event_field *field;
830 struct list_head *common_head = &ftrace_common_fields; 829 struct list_head *common_head = &ftrace_common_fields;
831 struct list_head *head = trace_get_fields(call); 830 struct list_head *head = trace_get_fields(call);
831 struct list_head *node = v;
832 832
833 (*pos)++; 833 (*pos)++;
834 834
835 switch ((unsigned long)v) { 835 switch ((unsigned long)v) {
836 case FORMAT_HEADER: 836 case FORMAT_HEADER:
837 if (unlikely(list_empty(common_head))) 837 node = common_head;
838 return NULL; 838 break;
839
840 field = list_entry(common_head->prev,
841 struct ftrace_event_field, link);
842 return field;
843 839
844 case FORMAT_FIELD_SEPERATOR: 840 case FORMAT_FIELD_SEPERATOR:
845 if (unlikely(list_empty(head))) 841 node = head;
846 return NULL; 842 break;
847
848 field = list_entry(head->prev, struct ftrace_event_field, link);
849 return field;
850 843
851 case FORMAT_PRINTFMT: 844 case FORMAT_PRINTFMT:
852 /* all done */ 845 /* all done */
853 return NULL; 846 return NULL;
854 } 847 }
855 848
856 field = v; 849 node = node->prev;
857 if (field->link.prev == common_head) 850 if (node == common_head)
858 return (void *)FORMAT_FIELD_SEPERATOR; 851 return (void *)FORMAT_FIELD_SEPERATOR;
859 else if (field->link.prev == head) 852 else if (node == head)
860 return (void *)FORMAT_PRINTFMT; 853 return (void *)FORMAT_PRINTFMT;
861 854 else
862 field = list_entry(field->link.prev, struct ftrace_event_field, link); 855 return node;
863
864 return field;
865}
866
867static void *f_start(struct seq_file *m, loff_t *pos)
868{
869 loff_t l = 0;
870 void *p;
871
872 /* Start by showing the header */
873 if (!*pos)
874 return (void *)FORMAT_HEADER;
875
876 p = (void *)FORMAT_HEADER;
877 do {
878 p = f_next(m, p, &l);
879 } while (p && l < *pos);
880
881 return p;
882} 856}
883 857
884static int f_show(struct seq_file *m, void *v) 858static int f_show(struct seq_file *m, void *v)
@@ -904,8 +878,7 @@ static int f_show(struct seq_file *m, void *v)
904 return 0; 878 return 0;
905 } 879 }
906 880
907 field = v; 881 field = list_entry(v, struct ftrace_event_field, link);
908
909 /* 882 /*
910 * Smartly shows the array type(except dynamic array). 883 * Smartly shows the array type(except dynamic array).
911 * Normal: 884 * Normal:
@@ -932,6 +905,17 @@ static int f_show(struct seq_file *m, void *v)
932 return 0; 905 return 0;
933} 906}
934 907
908static void *f_start(struct seq_file *m, loff_t *pos)
909{
910 void *p = (void *)FORMAT_HEADER;
911 loff_t l = 0;
912
913 while (l < *pos && p)
914 p = f_next(m, p, &l);
915
916 return p;
917}
918
935static void f_stop(struct seq_file *m, void *p) 919static void f_stop(struct seq_file *m, void *p)
936{ 920{
937} 921}
@@ -963,23 +947,14 @@ static ssize_t
963event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) 947event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
964{ 948{
965 struct ftrace_event_call *call = filp->private_data; 949 struct ftrace_event_call *call = filp->private_data;
966 struct trace_seq *s; 950 char buf[32];
967 int r; 951 int len;
968 952
969 if (*ppos) 953 if (*ppos)
970 return 0; 954 return 0;
971 955
972 s = kmalloc(sizeof(*s), GFP_KERNEL); 956 len = sprintf(buf, "%d\n", call->event.type);
973 if (!s) 957 return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
974 return -ENOMEM;
975
976 trace_seq_init(s);
977 trace_seq_printf(s, "%d\n", call->event.type);
978
979 r = simple_read_from_buffer(ubuf, cnt, ppos,
980 s->buffer, s->len);
981 kfree(s);
982 return r;
983} 958}
984 959
985static ssize_t 960static ssize_t
@@ -1218,6 +1193,7 @@ show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
1218 1193
1219static int ftrace_event_avail_open(struct inode *inode, struct file *file); 1194static int ftrace_event_avail_open(struct inode *inode, struct file *file);
1220static int ftrace_event_set_open(struct inode *inode, struct file *file); 1195static int ftrace_event_set_open(struct inode *inode, struct file *file);
1196static int ftrace_event_release(struct inode *inode, struct file *file);
1221 1197
1222static const struct seq_operations show_event_seq_ops = { 1198static const struct seq_operations show_event_seq_ops = {
1223 .start = t_start, 1199 .start = t_start,
@@ -1245,7 +1221,7 @@ static const struct file_operations ftrace_set_event_fops = {
1245 .read = seq_read, 1221 .read = seq_read,
1246 .write = ftrace_event_write, 1222 .write = ftrace_event_write,
1247 .llseek = seq_lseek, 1223 .llseek = seq_lseek,
1248 .release = seq_release, 1224 .release = ftrace_event_release,
1249}; 1225};
1250 1226
1251static const struct file_operations ftrace_enable_fops = { 1227static const struct file_operations ftrace_enable_fops = {
@@ -1323,6 +1299,15 @@ ftrace_event_open(struct inode *inode, struct file *file,
1323 return ret; 1299 return ret;
1324} 1300}
1325 1301
1302static int ftrace_event_release(struct inode *inode, struct file *file)
1303{
1304 struct trace_array *tr = inode->i_private;
1305
1306 trace_array_put(tr);
1307
1308 return seq_release(inode, file);
1309}
1310
1326static int 1311static int
1327ftrace_event_avail_open(struct inode *inode, struct file *file) 1312ftrace_event_avail_open(struct inode *inode, struct file *file)
1328{ 1313{
@@ -1336,12 +1321,19 @@ ftrace_event_set_open(struct inode *inode, struct file *file)
1336{ 1321{
1337 const struct seq_operations *seq_ops = &show_set_event_seq_ops; 1322 const struct seq_operations *seq_ops = &show_set_event_seq_ops;
1338 struct trace_array *tr = inode->i_private; 1323 struct trace_array *tr = inode->i_private;
1324 int ret;
1325
1326 if (trace_array_get(tr) < 0)
1327 return -ENODEV;
1339 1328
1340 if ((file->f_mode & FMODE_WRITE) && 1329 if ((file->f_mode & FMODE_WRITE) &&
1341 (file->f_flags & O_TRUNC)) 1330 (file->f_flags & O_TRUNC))
1342 ftrace_clear_events(tr); 1331 ftrace_clear_events(tr);
1343 1332
1344 return ftrace_event_open(inode, file, seq_ops); 1333 ret = ftrace_event_open(inode, file, seq_ops);
1334 if (ret < 0)
1335 trace_array_put(tr);
1336 return ret;
1345} 1337}
1346 1338
1347static struct event_subsystem * 1339static struct event_subsystem *