1 From e9db9a1035224a30ebb6be44e760e57518d19533 Mon Sep 17 00:00:00 2001
2 From: Luke Diamand <luked@broadcom.com>
3 Date: Sat, 28 Dec 2013 07:39:51 +0000
4 Subject: [PATCH 144/174] vc_mem: tidy up debug procfs code
6 Remove commented-out procfs code, which was generating
7 a warning and no longer worked. Replace this with
8 equivalent debugfs entries.
10 Signed-off-by: Luke Diamand <luked@broadcom.com>
12 arch/arm/mach-bcm2708/vc_mem.c | 119 +++++++++++++++++------------------------
13 1 file changed, 49 insertions(+), 70 deletions(-)
15 --- a/arch/arm/mach-bcm2708/vc_mem.c
16 +++ b/arch/arm/mach-bcm2708/vc_mem.c
18 #include <linux/cdev.h>
20 #include <linux/slab.h>
21 -#include <linux/proc_fs.h>
22 +#include <linux/debugfs.h>
23 #include <asm/uaccess.h>
24 #include <linux/dma-mapping.h>
26 @@ -51,8 +51,9 @@ static struct class *vc_mem_class = NULL
27 static struct cdev vc_mem_cdev;
28 static int vc_mem_inited = 0;
31 -static struct proc_dir_entry *vc_mem_proc_entry;
32 +#ifdef CONFIG_DEBUG_FS
33 +static struct dentry *vc_mem_debugfs_entry;
37 * Videocore memory addresses and size
38 @@ -280,75 +281,60 @@ static const struct file_operations vc_m
42 -/****************************************************************************
46 -***************************************************************************/
49 -vc_mem_proc_read(char *buf, char **start, off_t offset, int count, int *eof,
51 +#ifdef CONFIG_DEBUG_FS
52 +static void vc_mem_debugfs_deinit(void)
64 - // Get the videocore memory size first
67 - p += sprintf(p, "Videocore memory:\n");
68 - if (mm_vc_mem_phys_addr != 0)
69 - p += sprintf(p, " Physical address: 0x%p\n",
70 - (void *) mm_vc_mem_phys_addr);
72 - p += sprintf(p, " Physical address: 0x00000000\n");
73 - p += sprintf(p, " Length (bytes): %u\n", mm_vc_mem_size);
77 + debugfs_remove_recursive(vc_mem_debugfs_entry);
78 + vc_mem_debugfs_entry = NULL;
81 -/****************************************************************************
85 -***************************************************************************/
88 -vc_mem_proc_write(struct file *file, const char __user * buffer,
89 - unsigned long count, void *data)
90 +static int vc_mem_debugfs_init(
96 - memset(input_str, 0, sizeof (input_str));
98 - if (count > sizeof (input_str)) {
99 - LOG_ERR("%s: input string length too long", __func__);
103 - if (copy_from_user(input_str, buffer, count - 1)) {
104 - LOG_ERR("%s: failed to get input string", __func__);
106 + vc_mem_debugfs_entry = debugfs_create_dir(DRIVER_NAME, NULL);
107 + if (!vc_mem_debugfs_entry) {
108 + dev_warn(dev, "could not create debugfs entry\n");
112 + if (!debugfs_create_x32("vc_mem_phys_addr",
114 + vc_mem_debugfs_entry,
115 + (u32 *)&mm_vc_mem_phys_addr)) {
116 + dev_warn(dev, "%s:could not create vc_mem_phys entry\n",
121 + if (!debugfs_create_x32("vc_mem_size",
123 + vc_mem_debugfs_entry,
124 + (u32 *)&mm_vc_mem_size)) {
125 + dev_warn(dev, "%s:could not create vc_mem_size entry\n",
130 + if (!debugfs_create_x32("vc_mem_base",
132 + vc_mem_debugfs_entry,
133 + (u32 *)&mm_vc_mem_base)) {
134 + dev_warn(dev, "%s:could not create vc_mem_base entry\n",
139 - if (strncmp(input_str, "connect", strlen("connect")) == 0) {
140 - // Get the videocore memory size from the videocore
148 + vc_mem_debugfs_deinit();
152 +#endif /* CONFIG_DEBUG_FS */
155 /****************************************************************************
158 @@ -398,21 +384,14 @@ vc_mem_init(void)
159 goto out_class_destroy;
163 - vc_mem_proc_entry = create_proc_entry(DRIVER_NAME, 0444, NULL);
164 - if (vc_mem_proc_entry == NULL) {
166 - LOG_ERR("%s: create_proc_entry failed", __func__);
167 - goto out_device_destroy;
169 - vc_mem_proc_entry->read_proc = vc_mem_proc_read;
170 - vc_mem_proc_entry->write_proc = vc_mem_proc_write;
171 +#ifdef CONFIG_DEBUG_FS
172 + /* don't fail if the debug entries cannot be created */
173 + vc_mem_debugfs_init(dev);
179 - out_device_destroy:
180 device_destroy(vc_mem_class, vc_mem_devnum);
183 @@ -441,8 +420,8 @@ vc_mem_exit(void)
184 LOG_DBG("%s: called", __func__);
188 - remove_proc_entry(vc_mem_proc_entry->name, NULL);
190 + vc_mem_debugfs_deinit();
192 device_destroy(vc_mem_class, vc_mem_devnum);
193 class_destroy(vc_mem_class);