DSS2: VRAM: use debugfs, not procfs
authorTomi Valkeinen <tomi.valkeinen@nokia.com>
Wed, 22 Apr 2009 11:11:52 +0000 (14:11 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Fri, 1 May 2009 16:45:12 +0000 (19:45 +0300)
arch/arm/plat-omap/vram.c

index 90276ac..e847579 100644 (file)
 #include <linux/mm.h>
 #include <linux/list.h>
 #include <linux/dma-mapping.h>
-#include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/bootmem.h>
 #include <linux/omapfb.h>
 #include <linux/completion.h>
+#include <linux/debugfs.h>
 
 #include <asm/setup.h>
 
@@ -398,88 +398,54 @@ int omap_vram_alloc(int mtype, size_t size, unsigned long *paddr)
 }
 EXPORT_SYMBOL(omap_vram_alloc);
 
-#ifdef CONFIG_PROC_FS
-static void *r_next(struct seq_file *m, void *v, loff_t *pos)
-{
-       struct list_head *l = v;
-
-       (*pos)++;
-
-       if (list_is_last(l, &region_list))
-               return NULL;
-
-       return l->next;
-}
-
-static void *r_start(struct seq_file *m, loff_t *pos)
-{
-       loff_t p = *pos;
-       struct list_head *l = &region_list;
-
-       mutex_lock(&region_mutex);
-
-       do {
-               l = l->next;
-               if (l == &region_list)
-                       return NULL;
-       } while (p--);
-
-       return l;
-}
-
-static void r_stop(struct seq_file *m, void *v)
-{
-       mutex_unlock(&region_mutex);
-}
-
-static int r_show(struct seq_file *m, void *v)
+#if defined(CONFIG_DEBUG_FS)
+static int vram_debug_show(struct seq_file *s, void *unused)
 {
        struct vram_region *vr;
        struct vram_alloc *va;
        unsigned size;
 
-       vr = list_entry(v, struct vram_region, list);
-
-       size = vr->pages << PAGE_SHIFT;
-
-       seq_printf(m, "%08lx-%08lx (%d bytes)\n",
-                       vr->paddr, vr->paddr + size - 1,
-                       size);
+       mutex_lock(&region_mutex);
 
-       list_for_each_entry(va, &vr->alloc_list, list) {
-               size = va->pages << PAGE_SHIFT;
-               seq_printf(m, "    %08lx-%08lx (%d bytes)\n",
-                               va->paddr, va->paddr + size - 1,
+       list_for_each_entry(vr, &region_list, list) {
+               size = vr->pages << PAGE_SHIFT;
+               seq_printf(s, "%08lx-%08lx (%d bytes)\n",
+                               vr->paddr, vr->paddr + size - 1,
                                size);
-       }
 
+               list_for_each_entry(va, &vr->alloc_list, list) {
+                       size = va->pages << PAGE_SHIFT;
+                       seq_printf(s, "    %08lx-%08lx (%d bytes)\n",
+                                       va->paddr, va->paddr + size - 1,
+                                       size);
+               }
+       }
 
+       mutex_unlock(&region_mutex);
 
        return 0;
 }
 
-static const struct seq_operations resource_op = {
-       .start  = r_start,
-       .next   = r_next,
-       .stop   = r_stop,
-       .show   = r_show,
-};
-
-static int vram_open(struct inode *inode, struct file *file)
+static int vram_debug_open(struct inode *inode, struct file *file)
 {
-       return seq_open(file, &resource_op);
+       return single_open(file, vram_debug_show, inode->i_private);
 }
 
-static const struct file_operations proc_vram_operations = {
-       .open           = vram_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = seq_release,
+static const struct file_operations vram_debug_fops = {
+       .open           = vram_debug_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
 };
 
-static int __init omap_vram_create_proc(void)
+static int __init omap_vram_create_debugfs(void)
 {
-       proc_create("omap-vram", 0, NULL, &proc_vram_operations);
+       struct dentry *d;
+
+       d = debugfs_create_file("vram", S_IRUGO, NULL,
+                       NULL, &vram_debug_fops);
+       if (IS_ERR(d))
+               return PTR_ERR(d);
 
        return 0;
 }
@@ -487,7 +453,7 @@ static int __init omap_vram_create_proc(void)
 
 static __init int omap_vram_init(void)
 {
-       int i, r;
+       int i;
 
        vram_initialized = 1;
 
@@ -495,10 +461,9 @@ static __init int omap_vram_init(void)
                omap_vram_add_region(postponed_regions[i].paddr,
                                postponed_regions[i].size);
 
-#ifdef CONFIG_PROC_FS
-       r = omap_vram_create_proc();
-       if (r)
-               return -ENOMEM;
+#ifdef CONFIG_DEBUG_FS
+       if (omap_vram_create_debugfs())
+               pr_err("VRAM: Failed to create debugfs file\n");
 #endif
 
        return 0;