brcm63xx: rename target to bcm63xx
[openwrt/staging/wigyori.git] / target / linux / brcm2708 / patches-4.19 / 950-0275-char-vc_mem-Fix-all-coding-style-issues.patch
1 From 8d64f178c3568d212f3ddf05ea1ad7f103beeb86 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Wed, 23 Jan 2019 18:37:29 +0000
4 Subject: [PATCH] char: vc_mem: Fix all coding style issues.
5
6 Cleans up all checkpatch errors in vc_mem.c and vc_mem.h
7 No functional change to the code.
8
9 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
10 ---
11 drivers/char/broadcom/vc_mem.c | 177 +++++++++++---------------------
12 include/linux/broadcom/vc_mem.h | 38 +++----
13 2 files changed, 77 insertions(+), 138 deletions(-)
14
15 --- a/drivers/char/broadcom/vc_mem.c
16 +++ b/drivers/char/broadcom/vc_mem.c
17 @@ -1,16 +1,16 @@
18 -/*****************************************************************************
19 -* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
20 -*
21 -* Unless you and Broadcom execute a separate written software license
22 -* agreement governing use of this software, this software is licensed to you
23 -* under the terms of the GNU General Public License version 2, available at
24 -* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
25 -*
26 -* Notwithstanding the above, under no circumstances may you combine this
27 -* software in any way with any other Broadcom software provided under a
28 -* license other than the GPL, without Broadcom's express prior written
29 -* consent.
30 -*****************************************************************************/
31 +/*
32 + * Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
33 + *
34 + * Unless you and Broadcom execute a separate written software license
35 + * agreement governing use of this software, this software is licensed to you
36 + * under the terms of the GNU General Public License version 2, available at
37 + * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
38 + *
39 + * Notwithstanding the above, under no circumstances may you combine this
40 + * software in any way with any other Broadcom software provided under a
41 + * license other than the GPL, without Broadcom's express prior written
42 + * consent.
43 + */
44
45 #include <linux/kernel.h>
46 #include <linux/module.h>
47 @@ -26,11 +26,11 @@
48
49 #define DRIVER_NAME "vc-mem"
50
51 -// Device (/dev) related variables
52 -static dev_t vc_mem_devnum = 0;
53 -static struct class *vc_mem_class = NULL;
54 +/* Device (/dev) related variables */
55 +static dev_t vc_mem_devnum;
56 +static struct class *vc_mem_class;
57 static struct cdev vc_mem_cdev;
58 -static int vc_mem_inited = 0;
59 +static int vc_mem_inited;
60
61 #ifdef CONFIG_DEBUG_FS
62 static struct dentry *vc_mem_debugfs_entry;
63 @@ -50,96 +50,55 @@ static struct dentry *vc_mem_debugfs_ent
64 * bootloader (and/or kernel). When that happens, the values of these variables
65 * would be calculated and assigned in the init function.
66 */
67 -// in the 2835 VC in mapped above ARM, but ARM has full access to VC space
68 -unsigned long mm_vc_mem_phys_addr = 0x00000000;
69 -unsigned int mm_vc_mem_size = 0;
70 -unsigned int mm_vc_mem_base = 0;
71 -
72 +/* In the 2835 VC in mapped above ARM, but ARM has full access to VC space */
73 +unsigned long mm_vc_mem_phys_addr;
74 EXPORT_SYMBOL(mm_vc_mem_phys_addr);
75 +unsigned int mm_vc_mem_size;
76 EXPORT_SYMBOL(mm_vc_mem_size);
77 +unsigned int mm_vc_mem_base;
78 EXPORT_SYMBOL(mm_vc_mem_base);
79
80 -static uint phys_addr = 0;
81 -static uint mem_size = 0;
82 -static uint mem_base = 0;
83 -
84 -
85 -/****************************************************************************
86 -*
87 -* vc_mem_open
88 -*
89 -***************************************************************************/
90 +static uint phys_addr;
91 +static uint mem_size;
92 +static uint mem_base;
93
94 static int
95 vc_mem_open(struct inode *inode, struct file *file)
96 {
97 - (void) inode;
98 - (void) file;
99 + (void)inode;
100
101 pr_debug("%s: called file = 0x%p\n", __func__, file);
102
103 return 0;
104 }
105
106 -/****************************************************************************
107 -*
108 -* vc_mem_release
109 -*
110 -***************************************************************************/
111 -
112 static int
113 vc_mem_release(struct inode *inode, struct file *file)
114 {
115 - (void) inode;
116 - (void) file;
117 + (void)inode;
118
119 pr_debug("%s: called file = 0x%p\n", __func__, file);
120
121 return 0;
122 }
123
124 -/****************************************************************************
125 -*
126 -* vc_mem_get_size
127 -*
128 -***************************************************************************/
129 -
130 static void
131 vc_mem_get_size(void)
132 {
133 }
134
135 -/****************************************************************************
136 -*
137 -* vc_mem_get_base
138 -*
139 -***************************************************************************/
140 -
141 static void
142 vc_mem_get_base(void)
143 {
144 }
145
146 -/****************************************************************************
147 -*
148 -* vc_mem_get_current_size
149 -*
150 -***************************************************************************/
151 -
152 int
153 vc_mem_get_current_size(void)
154 {
155 return mm_vc_mem_size;
156 }
157 -
158 EXPORT_SYMBOL_GPL(vc_mem_get_current_size);
159
160 -/****************************************************************************
161 -*
162 -* vc_mem_ioctl
163 -*
164 -***************************************************************************/
165 -
166 static long
167 vc_mem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
168 {
169 @@ -154,52 +113,52 @@ vc_mem_ioctl(struct file *file, unsigned
170 case VC_MEM_IOC_MEM_PHYS_ADDR:
171 {
172 pr_debug("%s: VC_MEM_IOC_MEM_PHYS_ADDR=0x%p\n",
173 - __func__, (void *) mm_vc_mem_phys_addr);
174 + __func__, (void *)mm_vc_mem_phys_addr);
175
176 - if (copy_to_user((void *) arg, &mm_vc_mem_phys_addr,
177 - sizeof (mm_vc_mem_phys_addr)) != 0) {
178 + if (copy_to_user((void *)arg, &mm_vc_mem_phys_addr,
179 + sizeof(mm_vc_mem_phys_addr))) {
180 rc = -EFAULT;
181 }
182 break;
183 }
184 case VC_MEM_IOC_MEM_SIZE:
185 {
186 - // Get the videocore memory size first
187 + /* Get the videocore memory size first */
188 vc_mem_get_size();
189
190 pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%x\n", __func__,
191 - mm_vc_mem_size);
192 + mm_vc_mem_size);
193
194 - if (copy_to_user((void *) arg, &mm_vc_mem_size,
195 - sizeof (mm_vc_mem_size)) != 0) {
196 + if (copy_to_user((void *)arg, &mm_vc_mem_size,
197 + sizeof(mm_vc_mem_size))) {
198 rc = -EFAULT;
199 }
200 break;
201 }
202 case VC_MEM_IOC_MEM_BASE:
203 {
204 - // Get the videocore memory base
205 + /* Get the videocore memory base */
206 vc_mem_get_base();
207
208 pr_debug("%s: VC_MEM_IOC_MEM_BASE=%x\n", __func__,
209 - mm_vc_mem_base);
210 + mm_vc_mem_base);
211
212 - if (copy_to_user((void *) arg, &mm_vc_mem_base,
213 - sizeof (mm_vc_mem_base)) != 0) {
214 + if (copy_to_user((void *)arg, &mm_vc_mem_base,
215 + sizeof(mm_vc_mem_base))) {
216 rc = -EFAULT;
217 }
218 break;
219 }
220 case VC_MEM_IOC_MEM_LOAD:
221 {
222 - // Get the videocore memory base
223 + /* Get the videocore memory base */
224 vc_mem_get_base();
225
226 pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%x\n", __func__,
227 mm_vc_mem_base);
228
229 - if (copy_to_user((void *) arg, &mm_vc_mem_base,
230 - sizeof (mm_vc_mem_base)) != 0) {
231 + if (copy_to_user((void *)arg, &mm_vc_mem_base,
232 + sizeof(mm_vc_mem_base))) {
233 rc = -EFAULT;
234 }
235 break;
236 @@ -243,12 +202,6 @@ vc_mem_compat_ioctl(struct file *file, u
237 }
238 #endif
239
240 -/****************************************************************************
241 -*
242 -* vc_mem_mmap
243 -*
244 -***************************************************************************/
245 -
246 static int
247 vc_mem_mmap(struct file *filp, struct vm_area_struct *vma)
248 {
249 @@ -257,32 +210,26 @@ vc_mem_mmap(struct file *filp, struct vm
250 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
251
252 pr_debug("%s: vm_start = 0x%08lx vm_end = 0x%08lx vm_pgoff = 0x%08lx\n",
253 - __func__, (long) vma->vm_start, (long) vma->vm_end,
254 - (long) vma->vm_pgoff);
255 + __func__, (long)vma->vm_start, (long)vma->vm_end,
256 + (long)vma->vm_pgoff);
257
258 if (offset + length > mm_vc_mem_size) {
259 pr_err("%s: length %ld is too big\n", __func__, length);
260 return -EINVAL;
261 }
262 - // Do not cache the memory map
263 + /* Do not cache the memory map */
264 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
265
266 rc = remap_pfn_range(vma, vma->vm_start,
267 (mm_vc_mem_phys_addr >> PAGE_SHIFT) +
268 vma->vm_pgoff, length, vma->vm_page_prot);
269 - if (rc != 0) {
270 + if (rc)
271 pr_err("%s: remap_pfn_range failed (rc=%d)\n", __func__, rc);
272 - }
273
274 return rc;
275 }
276
277 -/****************************************************************************
278 -*
279 -* File Operations for the driver.
280 -*
281 -***************************************************************************/
282 -
283 +/* File Operations for the driver. */
284 static const struct file_operations vc_mem_fops = {
285 .owner = THIS_MODULE,
286 .open = vc_mem_open,
287 @@ -316,7 +263,7 @@ static int vc_mem_debugfs_init(
288 vc_mem_debugfs_entry,
289 (u32 *)&mm_vc_mem_phys_addr)) {
290 dev_warn(dev, "%s:could not create vc_mem_phys entry\n",
291 - __func__);
292 + __func__);
293 goto fail;
294 }
295
296 @@ -325,7 +272,7 @@ static int vc_mem_debugfs_init(
297 vc_mem_debugfs_entry,
298 (u32 *)&mm_vc_mem_size)) {
299 dev_warn(dev, "%s:could not create vc_mem_size entry\n",
300 - __func__);
301 + __func__);
302 goto fail;
303 }
304
305 @@ -347,12 +294,7 @@ fail:
306
307 #endif /* CONFIG_DEBUG_FS */
308
309 -
310 -/****************************************************************************
311 -*
312 -* vc_mem_init
313 -*
314 -***************************************************************************/
315 +/* Module load/unload functions */
316
317 static int __init
318 vc_mem_init(void)
319 @@ -369,16 +311,19 @@ vc_mem_init(void)
320 vc_mem_get_size();
321
322 pr_info("vc-mem: phys_addr:0x%08lx mem_base=0x%08x mem_size:0x%08x(%u MiB)\n",
323 - mm_vc_mem_phys_addr, mm_vc_mem_base, mm_vc_mem_size, mm_vc_mem_size / (1024 * 1024));
324 + mm_vc_mem_phys_addr, mm_vc_mem_base, mm_vc_mem_size,
325 + mm_vc_mem_size / (1024 * 1024));
326
327 - if ((rc = alloc_chrdev_region(&vc_mem_devnum, 0, 1, DRIVER_NAME)) < 0) {
328 + rc = alloc_chrdev_region(&vc_mem_devnum, 0, 1, DRIVER_NAME);
329 + if (rc < 0) {
330 pr_err("%s: alloc_chrdev_region failed (rc=%d)\n",
331 __func__, rc);
332 goto out_err;
333 }
334
335 cdev_init(&vc_mem_cdev, &vc_mem_fops);
336 - if ((rc = cdev_add(&vc_mem_cdev, vc_mem_devnum, 1)) != 0) {
337 + rc = cdev_add(&vc_mem_cdev, vc_mem_devnum, 1);
338 + if (rc) {
339 pr_err("%s: cdev_add failed (rc=%d)\n", __func__, rc);
340 goto out_unregister;
341 }
342 @@ -408,26 +353,20 @@ vc_mem_init(void)
343
344 device_destroy(vc_mem_class, vc_mem_devnum);
345
346 - out_class_destroy:
347 +out_class_destroy:
348 class_destroy(vc_mem_class);
349 vc_mem_class = NULL;
350
351 - out_cdev_del:
352 +out_cdev_del:
353 cdev_del(&vc_mem_cdev);
354
355 - out_unregister:
356 +out_unregister:
357 unregister_chrdev_region(vc_mem_devnum, 1);
358
359 - out_err:
360 +out_err:
361 return -1;
362 }
363
364 -/****************************************************************************
365 -*
366 -* vc_mem_exit
367 -*
368 -***************************************************************************/
369 -
370 static void __exit
371 vc_mem_exit(void)
372 {
373 --- a/include/linux/broadcom/vc_mem.h
374 +++ b/include/linux/broadcom/vc_mem.h
375 @@ -1,16 +1,16 @@
376 -/*****************************************************************************
377 -* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
378 -*
379 -* Unless you and Broadcom execute a separate written software license
380 -* agreement governing use of this software, this software is licensed to you
381 -* under the terms of the GNU General Public License version 2, available at
382 -* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
383 -*
384 -* Notwithstanding the above, under no circumstances may you combine this
385 -* software in any way with any other Broadcom software provided under a
386 -* license other than the GPL, without Broadcom's express prior written
387 -* consent.
388 -*****************************************************************************/
389 +/*
390 + * Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
391 + *
392 + * Unless you and Broadcom execute a separate written software license
393 + * agreement governing use of this software, this software is licensed to you
394 + * under the terms of the GNU General Public License version 2, available at
395 + * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
396 + *
397 + * Notwithstanding the above, under no circumstances may you combine this
398 + * software in any way with any other Broadcom software provided under a
399 + * license other than the GPL, without Broadcom's express prior written
400 + * consent.
401 + */
402
403 #ifndef _VC_MEM_H
404 #define _VC_MEM_H
405 @@ -19,17 +19,17 @@
406
407 #define VC_MEM_IOC_MAGIC 'v'
408
409 -#define VC_MEM_IOC_MEM_PHYS_ADDR _IOR( VC_MEM_IOC_MAGIC, 0, unsigned long )
410 -#define VC_MEM_IOC_MEM_SIZE _IOR( VC_MEM_IOC_MAGIC, 1, unsigned int )
411 -#define VC_MEM_IOC_MEM_BASE _IOR( VC_MEM_IOC_MAGIC, 2, unsigned int )
412 -#define VC_MEM_IOC_MEM_LOAD _IOR( VC_MEM_IOC_MAGIC, 3, unsigned int )
413 +#define VC_MEM_IOC_MEM_PHYS_ADDR _IOR(VC_MEM_IOC_MAGIC, 0, unsigned long)
414 +#define VC_MEM_IOC_MEM_SIZE _IOR(VC_MEM_IOC_MAGIC, 1, unsigned int)
415 +#define VC_MEM_IOC_MEM_BASE _IOR(VC_MEM_IOC_MAGIC, 2, unsigned int)
416 +#define VC_MEM_IOC_MEM_LOAD _IOR(VC_MEM_IOC_MAGIC, 3, unsigned int)
417
418 -#if defined( __KERNEL__ )
419 +#ifdef __KERNEL__
420 #define VC_MEM_TO_ARM_ADDR_MASK 0x3FFFFFFF
421
422 extern unsigned long mm_vc_mem_phys_addr;
423 extern unsigned int mm_vc_mem_size;
424 -extern int vc_mem_get_current_size( void );
425 +extern int vc_mem_get_current_size(void);
426 #endif
427
428 #ifdef CONFIG_COMPAT