brcm2708: add linux 4.19 support
[oweals/openwrt.git] / target / linux / brcm2708 / patches-4.19 / 950-0337-video-bcm2708_fb-Clean-up-coding-style-issues.patch
1 From 9236c0f31f2052bbcd6386367ace3ebfad57da3d Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 25 Jan 2019 17:32:54 +0000
4 Subject: [PATCH 337/703] video: bcm2708_fb: Clean up coding style issues
5
6 Now checkpatch clean except for 2 long lines, missing
7 SPDX header, and no DT documentation.
8
9 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
10 ---
11  drivers/video/fbdev/bcm2708_fb.c | 96 ++++++++++++++------------------
12  1 file changed, 42 insertions(+), 54 deletions(-)
13
14 --- a/drivers/video/fbdev/bcm2708_fb.c
15 +++ b/drivers/video/fbdev/bcm2708_fb.c
16 @@ -41,7 +41,7 @@
17  #define MODULE_NAME "bcm2708_fb"
18  
19  #ifdef BCM2708_FB_DEBUG
20 -#define print_debug(fmt, ...) pr_debug("%s:%s:%d: "fmt, \
21 +#define print_debug(fmt, ...) pr_debug("%s:%s:%d: " fmt, \
22                         MODULE_NAME, __func__, __LINE__, ##__VA_ARGS__)
23  #else
24  #define print_debug(fmt, ...)
25 @@ -57,7 +57,7 @@ static int fbheight = 480;    /* module par
26  static int fbdepth = 32;       /* module parameter */
27  static int fbswap;             /* module parameter */
28  
29 -static u32 dma_busy_wait_threshold = 1<<15;
30 +static u32 dma_busy_wait_threshold = 1 << 15;
31  module_param(dma_busy_wait_threshold, int, 0644);
32  MODULE_PARM_DESC(dma_busy_wait_threshold, "Busy-wait for DMA completion below this area");
33  
34 @@ -132,8 +132,8 @@ static int bcm2708_fb_debugfs_init(struc
35         fb->stats.regset.nregs = ARRAY_SIZE(stats_registers);
36         fb->stats.regset.base = &fb->stats;
37  
38 -       if (!debugfs_create_regset32(
39 -               "stats", 0444, fb->debugfs_dir, &fb->stats.regset)) {
40 +       if (!debugfs_create_regset32("stats", 0444, fb->debugfs_dir,
41 +                                    &fb->stats.regset)) {
42                 pr_warn("%s: could not create statistics registers\n",
43                         __func__);
44                 goto fail;
45 @@ -223,25 +223,22 @@ static int bcm2708_fb_check_var(struct f
46  {
47         /* info input, var output */
48         print_debug("%s(%p) %dx%d (%dx%d), %d, %d\n",
49 -               __func__,
50 -               info,
51 -               info->var.xres, info->var.yres, info->var.xres_virtual,
52 -               info->var.yres_virtual, (int)info->screen_size,
53 -               info->var.bits_per_pixel);
54 -       print_debug("%s(%p) %dx%d (%dx%d), %d\n", __func__, var,
55 -               var->xres, var->yres, var->xres_virtual, var->yres_virtual,
56 -               var->bits_per_pixel);
57 +                   __func__, info, info->var.xres, info->var.yres,
58 +                   info->var.xres_virtual, info->var.yres_virtual,
59 +                   (int)info->screen_size, info->var.bits_per_pixel);
60 +       print_debug("%s(%p) %dx%d (%dx%d), %d\n", __func__, var, var->xres,
61 +                   var->yres, var->xres_virtual, var->yres_virtual,
62 +                   var->bits_per_pixel);
63  
64         if (!var->bits_per_pixel)
65                 var->bits_per_pixel = 16;
66  
67         if (bcm2708_fb_set_bitfields(var) != 0) {
68                 pr_err("%s: invalid bits_per_pixel %d\n", __func__,
69 -                    var->bits_per_pixel);
70 +                      var->bits_per_pixel);
71                 return -EINVAL;
72         }
73  
74 -
75         if (var->xres_virtual < var->xres)
76                 var->xres_virtual = var->xres;
77         /* use highest possible virtual resolution */
78 @@ -249,7 +246,7 @@ static int bcm2708_fb_check_var(struct f
79                 var->yres_virtual = 480;
80  
81                 pr_err("%s: virtual resolution set to maximum of %dx%d\n",
82 -                    __func__, var->xres_virtual, var->yres_virtual);
83 +                      __func__, var->xres_virtual, var->yres_virtual);
84         }
85         if (var->yres_virtual < var->yres)
86                 var->yres_virtual = var->yres;
87 @@ -294,9 +291,9 @@ static int bcm2708_fb_set_par(struct fb_
88         int ret;
89  
90         print_debug("%s(%p) %dx%d (%dx%d), %d, %d\n", __func__, info,
91 -               info->var.xres, info->var.yres, info->var.xres_virtual,
92 -               info->var.yres_virtual, (int)info->screen_size,
93 -               info->var.bits_per_pixel);
94 +                   info->var.xres, info->var.yres, info->var.xres_virtual,
95 +                   info->var.yres_virtual, (int)info->screen_size,
96 +                   info->var.bits_per_pixel);
97  
98         ret = rpi_firmware_property_list(fb->fw, &fbinfo, sizeof(fbinfo));
99         if (ret) {
100 @@ -328,12 +325,10 @@ static int bcm2708_fb_set_par(struct fb_
101                 return -ENOMEM;
102         }
103  
104 -       print_debug(
105 -         "%s: start = %p,%p width=%d, height=%d, bpp=%d, pitch=%d size=%d\n",
106 -         __func__,
107 -         (void *)fb->fb.screen_base, (void *)fb->fb_bus_address,
108 -         fbinfo.xres, fbinfo.yres, fbinfo.bpp,
109 -         fbinfo.pitch, (int)fb->fb.screen_size);
110 +       print_debug("%s: start = %p,%p width=%d, height=%d, bpp=%d, pitch=%d size=%d\n",
111 +                   __func__, (void *)fb->fb.screen_base,
112 +                   (void *)fb->fb_bus_address, fbinfo.xres, fbinfo.yres,
113 +                   fbinfo.bpp, fbinfo.pitch, (int)fb->fb.screen_size);
114  
115         return 0;
116  }
117 @@ -345,7 +340,6 @@ static inline u32 convert_bitfield(int v
118         return (val >> (16 - bf->length) & mask) << bf->offset;
119  }
120  
121 -
122  static int bcm2708_fb_setcolreg(unsigned int regno, unsigned int red,
123                                 unsigned int green, unsigned int blue,
124                                 unsigned int transp, struct fb_info *info)
125 @@ -379,11 +373,11 @@ static int bcm2708_fb_setcolreg(unsigned
126                         packet->offset = 0;
127                         packet->length = regno + 1;
128                         memcpy(packet->cmap, fb->gpu_cmap,
129 -                               sizeof(packet->cmap));
130 +                              sizeof(packet->cmap));
131                         ret = rpi_firmware_property(fb->fw,
132 -                                       RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE,
133 -                                       packet,
134 -                                       (2 + packet->length) * sizeof(u32));
135 +                                                   RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE,
136 +                                                   packet,
137 +                                                   (2 + packet->length) * sizeof(u32));
138                         if (ret || packet->offset)
139                                 dev_err(info->device,
140                                         "Failed to set palette (%d,%u)\n",
141 @@ -392,9 +386,9 @@ static int bcm2708_fb_setcolreg(unsigned
142                 }
143         } else if (regno < 16) {
144                 fb->cmap[regno] = convert_bitfield(transp, &fb->fb.var.transp) |
145 -               convert_bitfield(blue, &fb->fb.var.blue) |
146 -               convert_bitfield(green, &fb->fb.var.green) |
147 -               convert_bitfield(red, &fb->fb.var.red);
148 +                                 convert_bitfield(blue, &fb->fb.var.blue) |
149 +                                 convert_bitfield(green, &fb->fb.var.green) |
150 +                                 convert_bitfield(red, &fb->fb.var.red);
151         }
152         return regno > 255;
153  }
154 @@ -437,8 +431,8 @@ static int bcm2708_fb_pan_display(struct
155         info->var.yoffset = var->yoffset;
156         result = bcm2708_fb_set_par(info);
157         if (result != 0)
158 -               pr_err("%s(%d,%d) returns=%d\n", __func__,
159 -                       var->xoffset, var->yoffset, result);
160 +               pr_err("%s(%d,%d) returns=%d\n", __func__, var->xoffset,
161 +                      var->yoffset, result);
162         return result;
163  }
164  
165 @@ -468,9 +462,8 @@ static void dma_memcpy(struct bcm2708_fb
166                 cb->info |= BCM2708_DMA_INT_EN;
167                 bcm_dma_start(fb->dma_chan_base, fb->cb_handle);
168                 while (bcm_dma_is_busy(dma_chan)) {
169 -                       wait_event_interruptible(
170 -                               fb->dma_waitq,
171 -                               !bcm_dma_is_busy(dma_chan));
172 +                       wait_event_interruptible(fb->dma_waitq,
173 +                                                !bcm_dma_is_busy(dma_chan));
174                 }
175                 fb->stats.dma_irqs++;
176         }
177 @@ -478,9 +471,9 @@ static void dma_memcpy(struct bcm2708_fb
178  }
179  
180  /* address with no aliases */
181 -#define INTALIAS_NORMAL(x) ((x)&~0xc0000000)
182 +#define INTALIAS_NORMAL(x) ((x) & ~0xc0000000)
183  /* cache coherent but non-allocating in L1 and L2 */
184 -#define INTALIAS_L1L2_NONALLOCATING(x) (((x)&~0xc0000000)|0x80000000)
185 +#define INTALIAS_L1L2_NONALLOCATING(x) (((x) & ~0xc0000000) | 0x80000000)
186  
187  static long vc_mem_copy(struct bcm2708_fb *fb, struct fb_dmacopy *ioparam)
188  {
189 @@ -498,15 +491,15 @@ static long vc_mem_copy(struct bcm2708_f
190  
191         if (!fb->gpu.base || !fb->gpu.length) {
192                 pr_err("[%s]: Unable to determine gpu memory (%x,%x)\n",
193 -                       __func__, fb->gpu.base, fb->gpu.length);
194 +                      __func__, fb->gpu.base, fb->gpu.length);
195                 return -EFAULT;
196         }
197  
198         if (INTALIAS_NORMAL(ioparam->src) < fb->gpu.base ||
199             INTALIAS_NORMAL(ioparam->src) >= fb->gpu.base + fb->gpu.length) {
200                 pr_err("[%s]: Invalid memory access %x (%x-%x)", __func__,
201 -                       INTALIAS_NORMAL(ioparam->src), fb->gpu.base,
202 -                       fb->gpu.base + fb->gpu.length);
203 +                      INTALIAS_NORMAL(ioparam->src), fb->gpu.base,
204 +                      fb->gpu.base + fb->gpu.length);
205                 return -EFAULT;
206         }
207  
208 @@ -528,8 +521,7 @@ static long vc_mem_copy(struct bcm2708_f
209                 dma_memcpy(fb, bus_addr,
210                            INTALIAS_L1L2_NONALLOCATING((dma_addr_t)p), size);
211                 if (copy_to_user(q, buf, s) != 0) {
212 -                       pr_err("[%s]: failed to copy-to-user\n",
213 -                                       __func__);
214 +                       pr_err("[%s]: failed to copy-to-user\n", __func__);
215                         rc = -EFAULT;
216                         goto out;
217                 }
218 @@ -755,7 +747,6 @@ static void bcm2708_fb_copyarea(struct f
219         /* end of dma control blocks chain */
220         cb->next = 0;
221  
222 -
223         if (pixels < dma_busy_wait_threshold) {
224                 bcm_dma_start(fb->dma_chan_base, fb->cb_handle);
225                 bcm_dma_wait_idle(fb->dma_chan_base);
226 @@ -765,9 +756,8 @@ static void bcm2708_fb_copyarea(struct f
227                 cb->info |= BCM2708_DMA_INT_EN;
228                 bcm_dma_start(fb->dma_chan_base, fb->cb_handle);
229                 while (bcm_dma_is_busy(dma_chan)) {
230 -                       wait_event_interruptible(
231 -                               fb->dma_waitq,
232 -                               !bcm_dma_is_busy(dma_chan));
233 +                       wait_event_interruptible(fb->dma_waitq,
234 +                                                !bcm_dma_is_busy(dma_chan));
235                 }
236                 fb->stats.dma_irqs++;
237         }
238 @@ -863,7 +853,7 @@ static int bcm2708_fb_register(struct bc
239                 return ret;
240  
241         print_debug("BCM2708FB: registering framebuffer (%dx%d@%d) (%d)\n",
242 -               fbwidth, fbheight, fbdepth, fbswap);
243 +                   fbwidth, fbheight, fbdepth, fbswap);
244  
245         ret = register_framebuffer(&fb->fb);
246         print_debug("BCM2708FB: register framebuffer (%d)\n", ret);
247 @@ -893,7 +883,7 @@ static int bcm2708_fb_probe(struct platf
248         if (!fw)
249                 return -EPROBE_DEFER;
250  
251 -       fb = kzalloc(sizeof(struct bcm2708_fb), GFP_KERNEL);
252 +       fb = kzalloc(sizeof(*fb), GFP_KERNEL);
253         if (!fb) {
254                 ret = -ENOMEM;
255                 goto free_region;
256 @@ -927,7 +917,6 @@ static int bcm2708_fb_probe(struct platf
257                 goto free_dma_chan;
258         }
259  
260 -
261         pr_info("BCM2708FB: allocated DMA channel %d\n", fb->dma_chan);
262  
263         fb->dev = dev;
264 @@ -936,9 +925,8 @@ static int bcm2708_fb_probe(struct platf
265         /* failure here isn't fatal, but we'll fail in vc_mem_copy if
266          * fb->gpu is not valid
267          */
268 -       rpi_firmware_property(fb->fw,
269 -                                   RPI_FIRMWARE_GET_VC_MEMORY,
270 -                                   &fb->gpu, sizeof(fb->gpu));
271 +       rpi_firmware_property(fb->fw, RPI_FIRMWARE_GET_VC_MEMORY, &fb->gpu,
272 +                             sizeof(fb->gpu));
273  
274         ret = bcm2708_fb_register(fb);
275         if (ret == 0) {