summaryrefslogtreecommitdiff
path: root/target/linux/brcm2708/patches-3.10/0144-vc_mem-tidy-up-debug-procfs-code.patch
blob: 06c10295a408e493e5005ade073de4ed4d5516ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
From e9db9a1035224a30ebb6be44e760e57518d19533 Mon Sep 17 00:00:00 2001
From: Luke Diamand <luked@broadcom.com>
Date: Sat, 28 Dec 2013 07:39:51 +0000
Subject: [PATCH 144/174] vc_mem: tidy up debug procfs code

Remove commented-out procfs code, which was generating
a warning and no longer worked. Replace this with
equivalent debugfs entries.

Signed-off-by: Luke Diamand <luked@broadcom.com>
---
 arch/arm/mach-bcm2708/vc_mem.c | 119 +++++++++++++++++------------------------
 1 file changed, 49 insertions(+), 70 deletions(-)

--- a/arch/arm/mach-bcm2708/vc_mem.c
+++ b/arch/arm/mach-bcm2708/vc_mem.c
@@ -19,7 +19,7 @@
 #include <linux/cdev.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
-#include <linux/proc_fs.h>
+#include <linux/debugfs.h>
 #include <asm/uaccess.h>
 #include <linux/dma-mapping.h>
 
@@ -51,8 +51,9 @@ static struct class *vc_mem_class = NULL
 static struct cdev vc_mem_cdev;
 static int vc_mem_inited = 0;
 
-// Proc entry
-static struct proc_dir_entry *vc_mem_proc_entry;
+#ifdef CONFIG_DEBUG_FS
+static struct dentry *vc_mem_debugfs_entry;
+#endif
 
 /*
  * Videocore memory addresses and size
@@ -280,75 +281,60 @@ static const struct file_operations vc_m
 	.mmap = vc_mem_mmap,
 };
 
-/****************************************************************************
-*
-*   vc_mem_proc_read
-*
-***************************************************************************/
-
-static int
-vc_mem_proc_read(char *buf, char **start, off_t offset, int count, int *eof,
-		 void *data)
+#ifdef CONFIG_DEBUG_FS
+static void vc_mem_debugfs_deinit(void)
 {
-	char *p = buf;
-
-	(void) start;
-	(void) count;
-	(void) data;
-
-	if (offset > 0) {
-		*eof = 1;
-		return 0;
-	}
-	// Get the videocore memory size first
-	vc_mem_get_size();
-
-	p += sprintf(p, "Videocore memory:\n");
-	if (mm_vc_mem_phys_addr != 0)
-		p += sprintf(p, "   Physical address: 0x%p\n",
-			     (void *) mm_vc_mem_phys_addr);
-	else
-		p += sprintf(p, "   Physical address: 0x00000000\n");
-	p += sprintf(p, "   Length (bytes):   %u\n", mm_vc_mem_size);
-
-	*eof = 1;
-	return p - buf;
+	debugfs_remove_recursive(vc_mem_debugfs_entry);
+	vc_mem_debugfs_entry = NULL;
 }
 
-/****************************************************************************
-*
-*   vc_mem_proc_write
-*
-***************************************************************************/
 
-static int
-vc_mem_proc_write(struct file *file, const char __user * buffer,
-		  unsigned long count, void *data)
+static int vc_mem_debugfs_init(
+	struct device *dev)
 {
-	int rc = -EFAULT;
-	char input_str[10];
-
-	memset(input_str, 0, sizeof (input_str));
-
-	if (count > sizeof (input_str)) {
-		LOG_ERR("%s: input string length too long", __func__);
-		goto out;
-	}
-
-	if (copy_from_user(input_str, buffer, count - 1)) {
-		LOG_ERR("%s: failed to get input string", __func__);
-		goto out;
+	vc_mem_debugfs_entry = debugfs_create_dir(DRIVER_NAME, NULL);
+	if (!vc_mem_debugfs_entry) {
+		dev_warn(dev, "could not create debugfs entry\n");
+		return -EFAULT;
+	}
+
+	if (!debugfs_create_x32("vc_mem_phys_addr",
+				0444,
+				vc_mem_debugfs_entry,
+				(u32 *)&mm_vc_mem_phys_addr)) {
+		dev_warn(dev, "%s:could not create vc_mem_phys entry\n",
+			__func__);
+		goto fail;
+	}
+
+	if (!debugfs_create_x32("vc_mem_size",
+				0444,
+				vc_mem_debugfs_entry,
+				(u32 *)&mm_vc_mem_size)) {
+		dev_warn(dev, "%s:could not create vc_mem_size entry\n",
+			__func__);
+		goto fail;
+	}
+
+	if (!debugfs_create_x32("vc_mem_base",
+				0444,
+				vc_mem_debugfs_entry,
+				(u32 *)&mm_vc_mem_base)) {
+		dev_warn(dev, "%s:could not create vc_mem_base entry\n",
+			 __func__);
+		goto fail;
 	}
 
-	if (strncmp(input_str, "connect", strlen("connect")) == 0) {
-		// Get the videocore memory size from the videocore
-		vc_mem_get_size();
-	}
+	return 0;
 
-      out:
-	return rc;
+fail:
+	vc_mem_debugfs_deinit();
+	return -EFAULT;
 }
 
+#endif /* CONFIG_DEBUG_FS */
+
+
 /****************************************************************************
 *
 *   vc_mem_init
@@ -398,21 +384,14 @@ vc_mem_init(void)
 		goto out_class_destroy;
 	}
 
-#if 0
-	vc_mem_proc_entry = create_proc_entry(DRIVER_NAME, 0444, NULL);
-	if (vc_mem_proc_entry == NULL) {
-		rc = -EFAULT;
-		LOG_ERR("%s: create_proc_entry failed", __func__);
-		goto out_device_destroy;
-	}
-	vc_mem_proc_entry->read_proc = vc_mem_proc_read;
-	vc_mem_proc_entry->write_proc = vc_mem_proc_write;
+#ifdef CONFIG_DEBUG_FS
+	/* don't fail if the debug entries cannot be created */
+	vc_mem_debugfs_init(dev);
 #endif
 
 	vc_mem_inited = 1;
 	return 0;
 
-      out_device_destroy:
 	device_destroy(vc_mem_class, vc_mem_devnum);
 
       out_class_destroy:
@@ -441,8 +420,8 @@ vc_mem_exit(void)
 	LOG_DBG("%s: called", __func__);
 
 	if (vc_mem_inited) {
-#if 0
-		remove_proc_entry(vc_mem_proc_entry->name, NULL);
+#if CONFIG_DEBUG_FS
+		vc_mem_debugfs_deinit();
 #endif
 		device_destroy(vc_mem_class, vc_mem_devnum);
 		class_destroy(vc_mem_class);