1 From 1533d883e78022ef323358cadf73d8cf059fe1fa 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/196] 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 diff --git a/arch/arm/mach-bcm2708/vc_mem.c b/arch/arm/mach-bcm2708/vc_mem.c
16 index aeae4d5..007754d 100644
17 --- a/arch/arm/mach-bcm2708/vc_mem.c
18 +++ b/arch/arm/mach-bcm2708/vc_mem.c
20 #include <linux/cdev.h>
22 #include <linux/slab.h>
23 -#include <linux/proc_fs.h>
24 +#include <linux/debugfs.h>
25 #include <asm/uaccess.h>
26 #include <linux/dma-mapping.h>
28 @@ -51,8 +51,9 @@ static struct class *vc_mem_class = NULL;
29 static struct cdev vc_mem_cdev;
30 static int vc_mem_inited = 0;
33 -static struct proc_dir_entry *vc_mem_proc_entry;
34 +#ifdef CONFIG_DEBUG_FS
35 +static struct dentry *vc_mem_debugfs_entry;
39 * Videocore memory addresses and size
40 @@ -280,75 +281,60 @@ static const struct file_operations vc_mem_fops = {
44 -/****************************************************************************
48 -***************************************************************************/
51 -vc_mem_proc_read(char *buf, char **start, off_t offset, int count, int *eof,
53 +#ifdef CONFIG_DEBUG_FS
54 +static void vc_mem_debugfs_deinit(void)
66 - // Get the videocore memory size first
69 - p += sprintf(p, "Videocore memory:\n");
70 - if (mm_vc_mem_phys_addr != 0)
71 - p += sprintf(p, " Physical address: 0x%p\n",
72 - (void *) mm_vc_mem_phys_addr);
74 - p += sprintf(p, " Physical address: 0x00000000\n");
75 - p += sprintf(p, " Length (bytes): %u\n", mm_vc_mem_size);
79 + debugfs_remove_recursive(vc_mem_debugfs_entry);
80 + vc_mem_debugfs_entry = NULL;
83 -/****************************************************************************
87 -***************************************************************************/
90 -vc_mem_proc_write(struct file *file, const char __user * buffer,
91 - unsigned long count, void *data)
92 +static int vc_mem_debugfs_init(
98 - memset(input_str, 0, sizeof (input_str));
99 + vc_mem_debugfs_entry = debugfs_create_dir(DRIVER_NAME, NULL);
100 + if (!vc_mem_debugfs_entry) {
101 + dev_warn(dev, "could not create debugfs entry\n");
105 - if (count > sizeof (input_str)) {
106 - LOG_ERR("%s: input string length too long", __func__);
108 + if (!debugfs_create_x32("vc_mem_phys_addr",
110 + vc_mem_debugfs_entry,
111 + (u32 *)&mm_vc_mem_phys_addr)) {
112 + dev_warn(dev, "%s:could not create vc_mem_phys entry\n",
117 - if (copy_from_user(input_str, buffer, count - 1)) {
118 - LOG_ERR("%s: failed to get input string", __func__);
120 + if (!debugfs_create_x32("vc_mem_size",
122 + vc_mem_debugfs_entry,
123 + (u32 *)&mm_vc_mem_size)) {
124 + dev_warn(dev, "%s:could not create vc_mem_size entry\n",
129 - if (strncmp(input_str, "connect", strlen("connect")) == 0) {
130 - // Get the videocore memory size from the videocore
132 + if (!debugfs_create_x32("vc_mem_base",
134 + vc_mem_debugfs_entry,
135 + (u32 *)&mm_vc_mem_base)) {
136 + dev_warn(dev, "%s:could not create vc_mem_base entry\n",
146 + vc_mem_debugfs_deinit();
150 +#endif /* CONFIG_DEBUG_FS */
153 /****************************************************************************
156 @@ -398,21 +384,14 @@ vc_mem_init(void)
157 goto out_class_destroy;
161 - vc_mem_proc_entry = create_proc_entry(DRIVER_NAME, 0444, NULL);
162 - if (vc_mem_proc_entry == NULL) {
164 - LOG_ERR("%s: create_proc_entry failed", __func__);
165 - goto out_device_destroy;
167 - vc_mem_proc_entry->read_proc = vc_mem_proc_read;
168 - vc_mem_proc_entry->write_proc = vc_mem_proc_write;
169 +#ifdef CONFIG_DEBUG_FS
170 + /* don't fail if the debug entries cannot be created */
171 + vc_mem_debugfs_init(dev);
177 - out_device_destroy:
178 device_destroy(vc_mem_class, vc_mem_devnum);
181 @@ -441,8 +420,8 @@ vc_mem_exit(void)
182 LOG_DBG("%s: called", __func__);
186 - remove_proc_entry(vc_mem_proc_entry->name, NULL);
188 + vc_mem_debugfs_deinit();
190 device_destroy(vc_mem_class, vc_mem_devnum);
191 class_destroy(vc_mem_class);