ALSA: usb-audio: add support for Akai MPD16
[safe/jmp/linux-2.6] / kernel / trace / trace_stat.c
index aea321c..96cffb2 100644 (file)
@@ -10,6 +10,7 @@
 
 
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/rbtree.h>
 #include <linux/debugfs.h>
 #include "trace_stat.h"
@@ -49,7 +50,8 @@ static struct dentry          *stat_dir;
  * but it will at least advance closer to the next one
  * to be released.
  */
-static struct rb_node *release_next(struct rb_node *node)
+static struct rb_node *release_next(struct tracer_stat *ts,
+                                   struct rb_node *node)
 {
        struct stat_node *snode;
        struct rb_node *parent = rb_parent(node);
@@ -67,6 +69,8 @@ static struct rb_node *release_next(struct rb_node *node)
                        parent->rb_right = NULL;
 
                snode = container_of(node, struct stat_node, node);
+               if (ts->stat_release)
+                       ts->stat_release(snode->stat);
                kfree(snode);
 
                return parent;
@@ -78,7 +82,7 @@ static void __reset_stat_session(struct stat_session *session)
        struct rb_node *node = session->stat_root.rb_node;
 
        while (node)
-               node = release_next(node);
+               node = release_next(session->ts, node);
 
        session->stat_root = RB_ROOT;
 }
@@ -200,17 +204,21 @@ static void *stat_seq_start(struct seq_file *s, loff_t *pos)
 {
        struct stat_session *session = s->private;
        struct rb_node *node;
+       int n = *pos;
        int i;
 
        /* Prevent from tracer switch or rbtree modification */
        mutex_lock(&session->stat_mutex);
 
        /* If we are in the beginning of the file, print the headers */
-       if (!*pos && session->ts->stat_headers)
-               return SEQ_START_TOKEN;
+       if (session->ts->stat_headers) {
+               if (n == 0)
+                       return SEQ_START_TOKEN;
+               n--;
+       }
 
        node = rb_first(&session->stat_root);
-       for (i = 0; node && i < *pos; i++)
+       for (i = 0; node && i < n; i++)
                node = rb_next(node);
 
        return node;