From b47aef28536f3c276d232c41cd3084c69389dca4 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Wed, 22 Apr 2009 14:11:52 +0300 Subject: [PATCH 51/69] DSS2: VRAM: use debugfs, not procfs --- arch/arm/plat-omap/vram.c | 103 +++++++++++++++------------------------------ 1 files changed, 34 insertions(+), 69 deletions(-) diff --git a/arch/arm/plat-omap/vram.c b/arch/arm/plat-omap/vram.c index 90276ac..e847579 100644 --- a/arch/arm/plat-omap/vram.c +++ b/arch/arm/plat-omap/vram.c @@ -27,11 +27,11 @@ #include #include #include -#include #include #include #include #include +#include #include @@ -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, ®ion_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 = ®ion_list; - - mutex_lock(®ion_mutex); - - do { - l = l->next; - if (l == ®ion_list) - return NULL; - } while (p--); - - return l; -} - -static void r_stop(struct seq_file *m, void *v) -{ - mutex_unlock(®ion_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(®ion_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, ®ion_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(®ion_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; -- 1.6.2.4