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 317/806] char: vc_mem: Fix all coding style issues.
6 Cleans up all checkpatch errors in vc_mem.c and vc_mem.h
7 No functional change to the code.
9 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
11 drivers/char/broadcom/vc_mem.c | 177 +++++++++++---------------------
12 include/linux/broadcom/vc_mem.h | 38 +++----
13 2 files changed, 77 insertions(+), 138 deletions(-)
15 --- a/drivers/char/broadcom/vc_mem.c
16 +++ b/drivers/char/broadcom/vc_mem.c
18 -/*****************************************************************************
19 -* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
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").
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
30 -*****************************************************************************/
32 + * Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
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").
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
45 #include <linux/kernel.h>
46 #include <linux/module.h>
49 #define DRIVER_NAME "vc-mem"
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;
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.
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;
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);
80 -static uint phys_addr = 0;
81 -static uint mem_size = 0;
82 -static uint mem_base = 0;
85 -/****************************************************************************
89 -***************************************************************************/
90 +static uint phys_addr;
91 +static uint mem_size;
92 +static uint mem_base;
95 vc_mem_open(struct inode *inode, struct file *file)
101 pr_debug("%s: called file = 0x%p\n", __func__, file);
106 -/****************************************************************************
110 -***************************************************************************/
113 vc_mem_release(struct inode *inode, struct file *file)
119 pr_debug("%s: called file = 0x%p\n", __func__, file);
124 -/****************************************************************************
128 -***************************************************************************/
131 vc_mem_get_size(void)
135 -/****************************************************************************
139 -***************************************************************************/
142 vc_mem_get_base(void)
146 -/****************************************************************************
148 -* vc_mem_get_current_size
150 -***************************************************************************/
153 vc_mem_get_current_size(void)
155 return mm_vc_mem_size;
158 EXPORT_SYMBOL_GPL(vc_mem_get_current_size);
160 -/****************************************************************************
164 -***************************************************************************/
167 vc_mem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
169 @@ -154,52 +113,52 @@ vc_mem_ioctl(struct file *file, unsigned
170 case VC_MEM_IOC_MEM_PHYS_ADDR:
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);
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))) {
184 case VC_MEM_IOC_MEM_SIZE:
186 - // Get the videocore memory size first
187 + /* Get the videocore memory size first */
190 pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%x\n", __func__,
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))) {
202 case VC_MEM_IOC_MEM_BASE:
204 - // Get the videocore memory base
205 + /* Get the videocore memory base */
208 pr_debug("%s: VC_MEM_IOC_MEM_BASE=%x\n", __func__,
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))) {
220 case VC_MEM_IOC_MEM_LOAD:
222 - // Get the videocore memory base
223 + /* Get the videocore memory base */
226 pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%x\n", __func__,
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))) {
236 @@ -243,12 +202,6 @@ vc_mem_compat_ioctl(struct file *file, u
240 -/****************************************************************************
244 -***************************************************************************/
247 vc_mem_mmap(struct file *filp, struct vm_area_struct *vma)
249 @@ -257,32 +210,26 @@ vc_mem_mmap(struct file *filp, struct vm
250 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
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);
258 if (offset + length > mm_vc_mem_size) {
259 pr_err("%s: length %ld is too big\n", __func__, length);
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);
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);
271 pr_err("%s: remap_pfn_range failed (rc=%d)\n", __func__, rc);
277 -/****************************************************************************
279 -* File Operations for the driver.
281 -***************************************************************************/
283 +/* File Operations for the driver. */
284 static const struct file_operations vc_mem_fops = {
285 .owner = THIS_MODULE,
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",
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",
305 @@ -347,12 +294,7 @@ fail:
307 #endif /* CONFIG_DEBUG_FS */
310 -/****************************************************************************
314 -***************************************************************************/
315 +/* Module load/unload functions */
319 @@ -369,16 +311,19 @@ vc_mem_init(void)
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));
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);
330 pr_err("%s: alloc_chrdev_region failed (rc=%d)\n",
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);
339 pr_err("%s: cdev_add failed (rc=%d)\n", __func__, rc);
342 @@ -408,26 +353,20 @@ vc_mem_init(void)
344 device_destroy(vc_mem_class, vc_mem_devnum);
348 class_destroy(vc_mem_class);
353 cdev_del(&vc_mem_cdev);
357 unregister_chrdev_region(vc_mem_devnum, 1);
364 -/****************************************************************************
368 -***************************************************************************/
373 --- a/include/linux/broadcom/vc_mem.h
374 +++ b/include/linux/broadcom/vc_mem.h
376 -/*****************************************************************************
377 -* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
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").
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
388 -*****************************************************************************/
390 + * Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
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").
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
407 #define VC_MEM_IOC_MAGIC 'v'
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)
418 -#if defined( __KERNEL__ )
420 #define VC_MEM_TO_ARM_ADDR_MASK 0x3FFFFFFF
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);