openwrtv4/target/linux/brcm2708/patches-3.10/0144-vc_mem-tidy-up-debug-procfs-code.patch
Florian Fainelli 6918ea2484 brcm2708: update 3.10 patches with raspberrypi/rpi-3.10.y of 27 Apr. 2014
Update the 3.10 rasperry patches by rebasing raspberry/rpi-3.10-y
against linux-stable/v3.10.49.

Signed-off-by: Florian Fainelli <florian@openwrt.org>

SVN-Revision: 42678
2014-09-27 19:10:51 +00:00

194 lines
5 KiB
Diff

From 1533d883e78022ef323358cadf73d8cf059fe1fa 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/196] 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(-)
diff --git a/arch/arm/mach-bcm2708/vc_mem.c b/arch/arm/mach-bcm2708/vc_mem.c
index aeae4d5..007754d 100644
--- 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_mem_fops = {
.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));
+ 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 (count > sizeof (input_str)) {
- LOG_ERR("%s: input string length too long", __func__);
- goto out;
+ 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 (copy_from_user(input_str, buffer, count - 1)) {
- LOG_ERR("%s: failed to get input string", __func__);
- goto out;
+ 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 (strncmp(input_str, "connect", strlen("connect")) == 0) {
- // Get the videocore memory size from the videocore
- vc_mem_get_size();
+ 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;
}
- out:
- return rc;
+ return 0;
+
+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);
--
1.9.1