brcm2708: switch to 3.14
[15.05/openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0144-vc_mem-tidy-up-debug-procfs-code.patch
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
5
6 Remove commented-out procfs code, which was generating
7 a warning and no longer worked. Replace this with
8 equivalent debugfs entries.
9
10 Signed-off-by: Luke Diamand <luked@broadcom.com>
11 ---
12  arch/arm/mach-bcm2708/vc_mem.c | 119 +++++++++++++++++------------------------
13  1 file changed, 49 insertions(+), 70 deletions(-)
14
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
19 @@ -19,7 +19,7 @@
20  #include <linux/cdev.h>
21  #include <linux/mm.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>
27  
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;
31  
32 -// Proc entry
33 -static struct proc_dir_entry *vc_mem_proc_entry;
34 +#ifdef CONFIG_DEBUG_FS
35 +static struct dentry *vc_mem_debugfs_entry;
36 +#endif
37  
38  /*
39   * Videocore memory addresses and size
40 @@ -280,75 +281,60 @@ static const struct file_operations vc_mem_fops = {
41         .mmap = vc_mem_mmap,
42  };
43  
44 -/****************************************************************************
45 -*
46 -*   vc_mem_proc_read
47 -*
48 -***************************************************************************/
49 -
50 -static int
51 -vc_mem_proc_read(char *buf, char **start, off_t offset, int count, int *eof,
52 -                void *data)
53 +#ifdef CONFIG_DEBUG_FS
54 +static void vc_mem_debugfs_deinit(void)
55  {
56 -       char *p = buf;
57 -
58 -       (void) start;
59 -       (void) count;
60 -       (void) data;
61 -
62 -       if (offset > 0) {
63 -               *eof = 1;
64 -               return 0;
65 -       }
66 -       // Get the videocore memory size first
67 -       vc_mem_get_size();
68 -
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);
73 -       else
74 -               p += sprintf(p, "   Physical address: 0x00000000\n");
75 -       p += sprintf(p, "   Length (bytes):   %u\n", mm_vc_mem_size);
76 -
77 -       *eof = 1;
78 -       return p - buf;
79 +       debugfs_remove_recursive(vc_mem_debugfs_entry);
80 +       vc_mem_debugfs_entry = NULL;
81  }
82  
83 -/****************************************************************************
84 -*
85 -*   vc_mem_proc_write
86 -*
87 -***************************************************************************/
88  
89 -static int
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(
93 +       struct device *dev)
94  {
95 -       int rc = -EFAULT;
96 -       char input_str[10];
97 -
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");
102 +               return -EFAULT;
103 +       }
104  
105 -       if (count > sizeof (input_str)) {
106 -               LOG_ERR("%s: input string length too long", __func__);
107 -               goto out;
108 +       if (!debugfs_create_x32("vc_mem_phys_addr",
109 +                               0444,
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",
113 +                       __func__);
114 +               goto fail;
115         }
116  
117 -       if (copy_from_user(input_str, buffer, count - 1)) {
118 -               LOG_ERR("%s: failed to get input string", __func__);
119 -               goto out;
120 +       if (!debugfs_create_x32("vc_mem_size",
121 +                               0444,
122 +                               vc_mem_debugfs_entry,
123 +                               (u32 *)&mm_vc_mem_size)) {
124 +               dev_warn(dev, "%s:could not create vc_mem_size entry\n",
125 +                       __func__);
126 +               goto fail;
127         }
128  
129 -       if (strncmp(input_str, "connect", strlen("connect")) == 0) {
130 -               // Get the videocore memory size from the videocore
131 -               vc_mem_get_size();
132 +       if (!debugfs_create_x32("vc_mem_base",
133 +                               0444,
134 +                               vc_mem_debugfs_entry,
135 +                               (u32 *)&mm_vc_mem_base)) {
136 +               dev_warn(dev, "%s:could not create vc_mem_base entry\n",
137 +                        __func__);
138 +               goto fail;
139         }
140  
141 -      out:
142 -       return rc;
143 +       return 0;
144 +
145 +fail:
146 +       vc_mem_debugfs_deinit();
147 +       return -EFAULT;
148  }
149  
150 +#endif /* CONFIG_DEBUG_FS */
151 +
152 +
153  /****************************************************************************
154  *
155  *   vc_mem_init
156 @@ -398,21 +384,14 @@ vc_mem_init(void)
157                 goto out_class_destroy;
158         }
159  
160 -#if 0
161 -       vc_mem_proc_entry = create_proc_entry(DRIVER_NAME, 0444, NULL);
162 -       if (vc_mem_proc_entry == NULL) {
163 -               rc = -EFAULT;
164 -               LOG_ERR("%s: create_proc_entry failed", __func__);
165 -               goto out_device_destroy;
166 -       }
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);
172  #endif
173  
174         vc_mem_inited = 1;
175         return 0;
176  
177 -      out_device_destroy:
178         device_destroy(vc_mem_class, vc_mem_devnum);
179  
180        out_class_destroy:
181 @@ -441,8 +420,8 @@ vc_mem_exit(void)
182         LOG_DBG("%s: called", __func__);
183  
184         if (vc_mem_inited) {
185 -#if 0
186 -               remove_proc_entry(vc_mem_proc_entry->name, NULL);
187 +#if CONFIG_DEBUG_FS
188 +               vc_mem_debugfs_deinit();
189  #endif
190                 device_destroy(vc_mem_class, vc_mem_devnum);
191                 class_destroy(vc_mem_class);
192 -- 
193 1.9.1
194