From 9cb18db0701f6b74f0c45c23ad767b3ebebe37f6 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Fri, 29 Dec 2017 19:48:43 +0100 Subject: video: fbdev: atmel_lcdfb: fix display-timings lookup Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children. To make things worse, the parent display node was also prematurely freed. Note that the display and timings node references are never put after a successful dt-initialisation so the nodes would leak on later probe deferrals and on driver unbind. Fixes: b985172b328a ("video: atmel_lcdfb: add device tree suport") Cc: stable # 3.13 Cc: Jean-Christophe PLAGNIOL-VILLARD Cc: Nicolas Ferre Cc: Alexandre Belloni Signed-off-by: Johan Hovold Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/atmel_lcdfb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c index e06358da4b99..3dee267d7c75 100644 --- a/drivers/video/fbdev/atmel_lcdfb.c +++ b/drivers/video/fbdev/atmel_lcdfb.c @@ -1119,7 +1119,7 @@ static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo) goto put_display_node; } - timings_np = of_find_node_by_name(display_np, "display-timings"); + timings_np = of_get_child_by_name(display_np, "display-timings"); if (!timings_np) { dev_err(dev, "failed to find display-timings node\n"); ret = -ENODEV; @@ -1140,6 +1140,12 @@ static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo) fb_add_videomode(&fb_vm, &info->modelist); } + /* + * FIXME: Make sure we are not referencing any fields in display_np + * and timings_np and drop our references to them before returning to + * avoid leaking the nodes on probe deferral and driver unbind. + */ + return 0; put_timings_node: -- cgit v1.2.3 From 530a6397a9af57e654c6d187c99ca50bfcf9f30d Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Fri, 29 Dec 2017 19:48:43 +0100 Subject: fb: intelfb: fix Kconfig symbol info in help text Fix Kconfig symbol typo; it should be FB_INTEL. Signed-off-by: Randy Dunlap Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 2f615b7f1c9f..9c1fcc3d3daa 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -1187,7 +1187,7 @@ config FB_INTEL 830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/965G/965GM chipsets. Say Y if you have and plan to use such a board. - To make FB_INTELFB=Y work you need to say AGP_INTEL=y too. + To make FB_INTEL=Y work you need to say AGP_INTEL=y too. To compile this driver as a module, choose M here: the module will be called intelfb. -- cgit v1.2.3 From ad614419da6db6876fa227e11e69987d4a8500f1 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 29 Dec 2017 19:48:43 +0100 Subject: video: fbdev: remove redundant self assignment of 'height' The assignment of height to itself is redundant and can be removed. Detected with Coccinelle. Signed-off-by: Colin Ian King Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/vga16fb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c index 5f0690c8fc93..2c6a576ed84c 100644 --- a/drivers/video/fbdev/vga16fb.c +++ b/drivers/video/fbdev/vga16fb.c @@ -1055,7 +1055,6 @@ static void vga16fb_copyarea(struct fb_info *info, const struct fb_copyarea *are case FB_TYPE_VGA_PLANES: if (info->fix.type_aux == FB_AUX_VGA_PLANES_VGA4) { width = width/8; - height = height; line_ofs = info->fix.line_length - width; setmode(1); -- cgit v1.2.3 From d961b8a9a6e9b4819d7620ac3921c0add11894f8 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 29 Dec 2017 19:48:43 +0100 Subject: video/fbdev/wm8505fb: Delete an error message for a failed memory allocation in wm8505fb_probe() Omit an extra message for a memory allocation failure in this function (please note that there can be only one wm8505fb device in the system). This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Cc: Tony Prisk Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/wm8505fb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/video/fbdev/wm8505fb.c b/drivers/video/fbdev/wm8505fb.c index 253ffe9baab2..8f0d5379861d 100644 --- a/drivers/video/fbdev/wm8505fb.c +++ b/drivers/video/fbdev/wm8505fb.c @@ -276,10 +276,8 @@ static int wm8505fb_probe(struct platform_device *pdev) fbi = devm_kzalloc(&pdev->dev, sizeof(struct wm8505fb_info) + sizeof(u32) * 16, GFP_KERNEL); - if (!fbi) { - dev_err(&pdev->dev, "Failed to initialize framebuffer device\n"); + if (!fbi) return -ENOMEM; - } strcpy(fbi->fb.fix.id, DRIVER_NAME); -- cgit v1.2.3 From d33a7ee92acad1beba5095310ad7da5fb4d20c6b Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 29 Dec 2017 19:48:44 +0100 Subject: video/fbdev/vt8500lcdfb: Delete an error message for a failed memory allocation in vt8500lcd_probe() Omit an extra message for a memory allocation failure in this function (please note that there can be only one vt8500lcdfb device in the system). This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Cc: Tony Prisk Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/vt8500lcdfb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/video/fbdev/vt8500lcdfb.c b/drivers/video/fbdev/vt8500lcdfb.c index 1a1176bf0906..5c5cd2923041 100644 --- a/drivers/video/fbdev/vt8500lcdfb.c +++ b/drivers/video/fbdev/vt8500lcdfb.c @@ -289,10 +289,8 @@ static int vt8500lcd_probe(struct platform_device *pdev) fbi = devm_kzalloc(&pdev->dev, sizeof(struct vt8500lcd_info) + sizeof(u32) * 16, GFP_KERNEL); - if (!fbi) { - dev_err(&pdev->dev, "Failed to initialize framebuffer device\n"); + if (!fbi) return -ENOMEM; - } strcpy(fbi->fb.fix.id, "VT8500 LCD"); -- cgit v1.2.3 From 74fb251963df4cbb10cc1185297a7c7863ef85e3 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 29 Dec 2017 19:48:44 +0100 Subject: video: udlfb: Improve a size determination in dlfb_alloc_urb_list() Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Cc: Bernie Thompson Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/udlfb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index d44f14242016..ee338ba3d9ab 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -1876,7 +1876,7 @@ static int dlfb_alloc_urb_list(struct dlfb_data *dev, int count, size_t size) INIT_LIST_HEAD(&dev->urbs.list); while (i < count) { - unode = kzalloc(sizeof(struct urb_node), GFP_KERNEL); + unode = kzalloc(sizeof(*unode), GFP_KERNEL); if (!unode) break; unode->dev = dev; -- cgit v1.2.3 From 11ab5a640cc2e4432500c28d62c48f3377a75cad Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 29 Dec 2017 19:48:44 +0100 Subject: video: udlfb: Delete an unnecessary return statement in two functions The script "checkpatch.pl" pointed information out like the following. WARNING: void function return statements are not generally useful Thus remove such a statement in the affected functions. Signed-off-by: Markus Elfring Cc: Bernie Thompson Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/udlfb.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index ee338ba3d9ab..99ce445986b3 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -505,8 +505,6 @@ static void dlfb_compress_hline( *command_buffer_ptr = cmd; *pixel_start_ptr = pixel; *device_address_ptr = dev_addr; - - return; } /* @@ -1777,8 +1775,6 @@ static void dlfb_usb_disconnect(struct usb_interface *interface) kref_put(&dev->kref, dlfb_free); /* consider dlfb_data freed */ - - return; } static struct usb_driver dlfb_driver = { -- cgit v1.2.3 From defddeff61041dbe2d5bd5469ee48912a89b4118 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 29 Dec 2017 19:48:44 +0100 Subject: video: smscufx: Improve a size determination in two functions Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring Cc: Steve Glendinning Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/smscufx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c index 2275e80b5776..8db7085e5d1a 100644 --- a/drivers/video/fbdev/smscufx.c +++ b/drivers/video/fbdev/smscufx.c @@ -1086,8 +1086,7 @@ static int ufx_ops_open(struct fb_info *info, int user) struct fb_deferred_io *fbdefio; - fbdefio = kzalloc(sizeof(struct fb_deferred_io), GFP_KERNEL); - + fbdefio = kzalloc(sizeof(*fbdefio), GFP_KERNEL); if (fbdefio) { fbdefio->delay = UFX_DEFIO_WRITE_DELAY; fbdefio->deferred_io = ufx_dpy_deferred_io; @@ -1875,7 +1874,7 @@ static int ufx_alloc_urb_list(struct ufx_data *dev, int count, size_t size) INIT_LIST_HEAD(&dev->urbs.list); while (i < count) { - unode = kzalloc(sizeof(struct urb_node), GFP_KERNEL); + unode = kzalloc(sizeof(*unode), GFP_KERNEL); if (!unode) break; unode->dev = dev; -- cgit v1.2.3 From 63a4be93937c1a6459f9d67b7afeb4e81fa64d2b Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 4 Jan 2018 16:53:49 +0100 Subject: fbdev: radeon: use ktime_get() for HZ calibration do_gettimeofday() is deprecated and a bit clumsy. This changes radeon_probe_pll_params() over to using ktime_get() with monotonic times. There is no need to check for negative values any more since the monotonic clocksource cannot go backwards, but I'm adding a check for zero-division in case of a bad clocksource. Signed-off-by: Arnd Bergmann Cc: Benjamin Herrenschmidt Cc: Colin Ian King Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/aty/radeon_base.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c index 4d77daeecf99..87608c0b2351 100644 --- a/drivers/video/fbdev/aty/radeon_base.c +++ b/drivers/video/fbdev/aty/radeon_base.c @@ -583,8 +583,8 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) int hTotal, vTotal, num, denom, m, n; unsigned long long hz, vclk; long xtal; - struct timeval start_tv, stop_tv; - long total_secs, total_usecs; + ktime_t start_time, stop_time; + u64 total_usecs; int i; /* Ugh, we cut interrupts, bad bad bad, but we want some precision @@ -600,7 +600,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0) break; - do_gettimeofday(&start_tv); + start_time = ktime_get(); for(i=0; i<1000000; i++) if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0) @@ -610,18 +610,14 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0) break; - do_gettimeofday(&stop_tv); + stop_time = ktime_get(); local_irq_enable(); - total_secs = stop_tv.tv_sec - start_tv.tv_sec; - if (total_secs > 10) + total_usecs = ktime_us_delta(stop_time, start_time); + if (total_usecs >= 10 * USEC_PER_SEC || total_usecs == 0) return -1; - total_usecs = stop_tv.tv_usec - start_tv.tv_usec; - total_usecs += total_secs * 1000000; - if (total_usecs < 0) - total_usecs = -total_usecs; - hz = 1000000/total_usecs; + hz = USEC_PER_SEC/(u32)total_usecs; hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8; vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1); -- cgit v1.2.3 From f7a753547474eb6bcc1fe8dd46d14eaea93bfe2e Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 4 Jan 2018 16:53:49 +0100 Subject: fbdev: pxa3xx: use ktime_get_ts64 for time stamps do_gettimeofday() is deprecated because it is not y2038 safe, so I'm changing the calculation for the diagnostic output over to using 'timespec64'. We really only print time deltas here, so changing it to monotonic time makes this more robust, the correct accessor for this is ktime_get_ts64(). Signed-off-by: Arnd Bergmann Cc: "Gustavo A. R. Silva" Cc: Himanshu Jha Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/pxa3xx-gcu.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/pxa3xx-gcu.c b/drivers/video/fbdev/pxa3xx-gcu.c index 55fbb432c053..0955622a1227 100644 --- a/drivers/video/fbdev/pxa3xx-gcu.c +++ b/drivers/video/fbdev/pxa3xx-gcu.c @@ -104,7 +104,7 @@ struct pxa3xx_gcu_priv { wait_queue_head_t wait_idle; wait_queue_head_t wait_free; spinlock_t spinlock; - struct timeval base_time; + struct timespec64 base_time; struct pxa3xx_gcu_batch *free; struct pxa3xx_gcu_batch *ready; @@ -126,18 +126,20 @@ gc_writel(struct pxa3xx_gcu_priv *priv, unsigned int off, unsigned long val) #define QPRINT(priv, level, msg) \ do { \ - struct timeval tv; \ + struct timespec64 ts; \ struct pxa3xx_gcu_shared *shared = priv->shared; \ u32 base = gc_readl(priv, REG_GCRBBR); \ \ - do_gettimeofday(&tv); \ + ktime_get_ts64(&ts); \ + ts = timespec64_sub(ts, priv->base_time); \ \ - printk(level "%ld.%03ld.%03ld - %-17s: %-21s (%s, " \ + printk(level "%lld.%03ld.%03ld - %-17s: %-21s (%s, " \ "STATUS " \ "0x%02lx, B 0x%08lx [%ld], E %5ld, H %5ld, " \ "T %5ld)\n", \ - tv.tv_sec - priv->base_time.tv_sec, \ - tv.tv_usec / 1000, tv.tv_usec % 1000, \ + (s64)(ts.tv_sec), \ + ts.tv_nsec / NSEC_PER_MSEC, \ + (ts.tv_nsec % NSEC_PER_MSEC) / USEC_PER_MSEC, \ __func__, msg, \ shared->hw_running ? "running" : " idle", \ gc_readl(priv, REG_GCISCR), \ @@ -164,7 +166,7 @@ pxa3xx_gcu_reset(struct pxa3xx_gcu_priv *priv) priv->shared->buffer_phys = priv->shared_phys; priv->shared->magic = PXA3XX_GCU_SHARED_MAGIC; - do_gettimeofday(&priv->base_time); + ktime_get_ts64(&priv->base_time); /* set up the ring buffer pointers */ gc_writel(priv, REG_GCRBLR, 0); -- cgit v1.2.3 From 8babdcfb71e98ca086b5abf804ec2195f434ed2b Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 4 Jan 2018 16:53:49 +0100 Subject: fbdev: au1200fb: delete duplicate header contents This file has been copy-pasted-pasted: ~/linux$ x=drivers/video/fbdev/au1200fb.h; diff -u <(head -n 286 $x; head -n 286 $x) $x ~/linux$ Signed-off-by: Rasmus Villemoes Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/au1200fb.h | 286 ----------------------------------------- 1 file changed, 286 deletions(-) diff --git a/drivers/video/fbdev/au1200fb.h b/drivers/video/fbdev/au1200fb.h index e2672714d8d4..b34fff342a1a 100644 --- a/drivers/video/fbdev/au1200fb.h +++ b/drivers/video/fbdev/au1200fb.h @@ -284,289 +284,3 @@ struct au1200_lcd { /********************************************************************/ #endif /* _AU1200LCD_H */ -/* - * BRIEF MODULE DESCRIPTION - * Hardware definitions for the Au1200 LCD controller - * - * Copyright 2004 AMD - * Author: AMD - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _AU1200LCD_H -#define _AU1200LCD_H - -/********************************************************************/ -#define AU1200_LCD_ADDR 0xB5000000 - -#define uint8 unsigned char -#define uint32 unsigned int - -struct au1200_lcd { - volatile uint32 reserved0; - volatile uint32 screen; - volatile uint32 backcolor; - volatile uint32 horztiming; - volatile uint32 verttiming; - volatile uint32 clkcontrol; - volatile uint32 pwmdiv; - volatile uint32 pwmhi; - volatile uint32 reserved1; - volatile uint32 winenable; - volatile uint32 colorkey; - volatile uint32 colorkeymsk; - struct - { - volatile uint32 cursorctrl; - volatile uint32 cursorpos; - volatile uint32 cursorcolor0; - volatile uint32 cursorcolor1; - volatile uint32 cursorcolor2; - uint32 cursorcolor3; - } hwc; - volatile uint32 intstatus; - volatile uint32 intenable; - volatile uint32 outmask; - volatile uint32 fifoctrl; - uint32 reserved2[(0x0100-0x0058)/4]; - struct - { - volatile uint32 winctrl0; - volatile uint32 winctrl1; - volatile uint32 winctrl2; - volatile uint32 winbuf0; - volatile uint32 winbuf1; - volatile uint32 winbufctrl; - uint32 winreserved0; - uint32 winreserved1; - } window[4]; - - uint32 reserved3[(0x0400-0x0180)/4]; - - volatile uint32 palette[(0x0800-0x0400)/4]; - - volatile uint8 cursorpattern[256]; -}; - -/* lcd_screen */ -#define LCD_SCREEN_SEN (1<<31) -#define LCD_SCREEN_SX (0x07FF<<19) -#define LCD_SCREEN_SY (0x07FF<< 8) -#define LCD_SCREEN_SWP (1<<7) -#define LCD_SCREEN_SWD (1<<6) -#define LCD_SCREEN_PT (7<<0) -#define LCD_SCREEN_PT_TFT (0<<0) -#define LCD_SCREEN_SX_N(WIDTH) ((WIDTH-1)<<19) -#define LCD_SCREEN_SY_N(HEIGHT) ((HEIGHT-1)<<8) -#define LCD_SCREEN_PT_CSTN (1<<0) -#define LCD_SCREEN_PT_CDSTN (2<<0) -#define LCD_SCREEN_PT_M8STN (3<<0) -#define LCD_SCREEN_PT_M4STN (4<<0) - -/* lcd_backcolor */ -#define LCD_BACKCOLOR_SBGR (0xFF<<16) -#define LCD_BACKCOLOR_SBGG (0xFF<<8) -#define LCD_BACKCOLOR_SBGB (0xFF<<0) -#define LCD_BACKCOLOR_SBGR_N(N) ((N)<<16) -#define LCD_BACKCOLOR_SBGG_N(N) ((N)<<8) -#define LCD_BACKCOLOR_SBGB_N(N) ((N)<<0) - -/* lcd_winenable */ -#define LCD_WINENABLE_WEN3 (1<<3) -#define LCD_WINENABLE_WEN2 (1<<2) -#define LCD_WINENABLE_WEN1 (1<<1) -#define LCD_WINENABLE_WEN0 (1<<0) - -/* lcd_colorkey */ -#define LCD_COLORKEY_CKR (0xFF<<16) -#define LCD_COLORKEY_CKG (0xFF<<8) -#define LCD_COLORKEY_CKB (0xFF<<0) -#define LCD_COLORKEY_CKR_N(N) ((N)<<16) -#define LCD_COLORKEY_CKG_N(N) ((N)<<8) -#define LCD_COLORKEY_CKB_N(N) ((N)<<0) - -/* lcd_colorkeymsk */ -#define LCD_COLORKEYMSK_CKMR (0xFF<<16) -#define LCD_COLORKEYMSK_CKMG (0xFF<<8) -#define LCD_COLORKEYMSK_CKMB (0xFF<<0) -#define LCD_COLORKEYMSK_CKMR_N(N) ((N)<<16) -#define LCD_COLORKEYMSK_CKMG_N(N) ((N)<<8) -#define LCD_COLORKEYMSK_CKMB_N(N) ((N)<<0) - -/* lcd windows control 0 */ -#define LCD_WINCTRL0_OX (0x07FF<<21) -#define LCD_WINCTRL0_OY (0x07FF<<10) -#define LCD_WINCTRL0_A (0x00FF<<2) -#define LCD_WINCTRL0_AEN (1<<1) -#define LCD_WINCTRL0_OX_N(N) ((N)<<21) -#define LCD_WINCTRL0_OY_N(N) ((N)<<10) -#define LCD_WINCTRL0_A_N(N) ((N)<<2) - -/* lcd windows control 1 */ -#define LCD_WINCTRL1_PRI (3<<30) -#define LCD_WINCTRL1_PIPE (1<<29) -#define LCD_WINCTRL1_FRM (0xF<<25) -#define LCD_WINCTRL1_CCO (1<<24) -#define LCD_WINCTRL1_PO (3<<22) -#define LCD_WINCTRL1_SZX (0x07FF<<11) -#define LCD_WINCTRL1_SZY (0x07FF<<0) -#define LCD_WINCTRL1_FRM_1BPP (0<<25) -#define LCD_WINCTRL1_FRM_2BPP (1<<25) -#define LCD_WINCTRL1_FRM_4BPP (2<<25) -#define LCD_WINCTRL1_FRM_8BPP (3<<25) -#define LCD_WINCTRL1_FRM_12BPP (4<<25) -#define LCD_WINCTRL1_FRM_16BPP655 (5<<25) -#define LCD_WINCTRL1_FRM_16BPP565 (6<<25) -#define LCD_WINCTRL1_FRM_16BPP556 (7<<25) -#define LCD_WINCTRL1_FRM_16BPPI1555 (8<<25) -#define LCD_WINCTRL1_FRM_16BPPI5551 (9<<25) -#define LCD_WINCTRL1_FRM_16BPPA1555 (10<<25) -#define LCD_WINCTRL1_FRM_16BPPA5551 (11<<25) -#define LCD_WINCTRL1_FRM_24BPP (12<<25) -#define LCD_WINCTRL1_FRM_32BPP (13<<25) -#define LCD_WINCTRL1_PRI_N(N) ((N)<<30) -#define LCD_WINCTRL1_PO_00 (0<<22) -#define LCD_WINCTRL1_PO_01 (1<<22) -#define LCD_WINCTRL1_PO_10 (2<<22) -#define LCD_WINCTRL1_PO_11 (3<<22) -#define LCD_WINCTRL1_SZX_N(N) ((N-1)<<11) -#define LCD_WINCTRL1_SZY_N(N) ((N-1)<<0) - -/* lcd windows control 2 */ -#define LCD_WINCTRL2_CKMODE (3<<24) -#define LCD_WINCTRL2_DBM (1<<23) -#define LCD_WINCTRL2_RAM (3<<21) -#define LCD_WINCTRL2_BX (0x1FFF<<8) -#define LCD_WINCTRL2_SCX (0xF<<4) -#define LCD_WINCTRL2_SCY (0xF<<0) -#define LCD_WINCTRL2_CKMODE_00 (0<<24) -#define LCD_WINCTRL2_CKMODE_01 (1<<24) -#define LCD_WINCTRL2_CKMODE_10 (2<<24) -#define LCD_WINCTRL2_CKMODE_11 (3<<24) -#define LCD_WINCTRL2_RAM_NONE (0<<21) -#define LCD_WINCTRL2_RAM_PALETTE (1<<21) -#define LCD_WINCTRL2_RAM_GAMMA (2<<21) -#define LCD_WINCTRL2_RAM_BUFFER (3<<21) -#define LCD_WINCTRL2_BX_N(N) ((N)<<8) -#define LCD_WINCTRL2_SCX_1 (0<<4) -#define LCD_WINCTRL2_SCX_2 (1<<4) -#define LCD_WINCTRL2_SCX_4 (2<<4) -#define LCD_WINCTRL2_SCY_1 (0<<0) -#define LCD_WINCTRL2_SCY_2 (1<<0) -#define LCD_WINCTRL2_SCY_4 (2<<0) - -/* lcd windows buffer control */ -#define LCD_WINBUFCTRL_DB (1<<1) -#define LCD_WINBUFCTRL_DBN (1<<0) - -/* lcd_intstatus, lcd_intenable */ -#define LCD_INT_IFO (0xF<<14) -#define LCD_INT_IFU (0xF<<10) -#define LCD_INT_OFO (1<<9) -#define LCD_INT_OFU (1<<8) -#define LCD_INT_WAIT (1<<3) -#define LCD_INT_SD (1<<2) -#define LCD_INT_SA (1<<1) -#define LCD_INT_SS (1<<0) - -/* lcd_horztiming */ -#define LCD_HORZTIMING_HND2 (0x1FF<<18) -#define LCD_HORZTIMING_HND1 (0x1FF<<9) -#define LCD_HORZTIMING_HPW (0x1FF<<0) -#define LCD_HORZTIMING_HND2_N(N)(((N)-1)<<18) -#define LCD_HORZTIMING_HND1_N(N)(((N)-1)<<9) -#define LCD_HORZTIMING_HPW_N(N) (((N)-1)<<0) - -/* lcd_verttiming */ -#define LCD_VERTTIMING_VND2 (0x1FF<<18) -#define LCD_VERTTIMING_VND1 (0x1FF<<9) -#define LCD_VERTTIMING_VPW (0x1FF<<0) -#define LCD_VERTTIMING_VND2_N(N)(((N)-1)<<18) -#define LCD_VERTTIMING_VND1_N(N)(((N)-1)<<9) -#define LCD_VERTTIMING_VPW_N(N) (((N)-1)<<0) - -/* lcd_clkcontrol */ -#define LCD_CLKCONTROL_EXT (1<<22) -#define LCD_CLKCONTROL_DELAY (3<<20) -#define LCD_CLKCONTROL_CDD (1<<19) -#define LCD_CLKCONTROL_IB (1<<18) -#define LCD_CLKCONTROL_IC (1<<17) -#define LCD_CLKCONTROL_IH (1<<16) -#define LCD_CLKCONTROL_IV (1<<15) -#define LCD_CLKCONTROL_BF (0x1F<<10) -#define LCD_CLKCONTROL_PCD (0x3FF<<0) -#define LCD_CLKCONTROL_BF_N(N) (((N)-1)<<10) -#define LCD_CLKCONTROL_PCD_N(N) ((N)<<0) - -/* lcd_pwmdiv */ -#define LCD_PWMDIV_EN (1<<31) -#define LCD_PWMDIV_PWMDIV (0x1FFFF<<0) -#define LCD_PWMDIV_PWMDIV_N(N) ((N)<<0) - -/* lcd_pwmhi */ -#define LCD_PWMHI_PWMHI1 (0xFFFF<<16) -#define LCD_PWMHI_PWMHI0 (0xFFFF<<0) -#define LCD_PWMHI_PWMHI1_N(N) ((N)<<16) -#define LCD_PWMHI_PWMHI0_N(N) ((N)<<0) - -/* lcd_hwccon */ -#define LCD_HWCCON_EN (1<<0) - -/* lcd_cursorpos */ -#define LCD_CURSORPOS_HWCXOFF (0x1F<<27) -#define LCD_CURSORPOS_HWCXPOS (0x07FF<<16) -#define LCD_CURSORPOS_HWCYOFF (0x1F<<11) -#define LCD_CURSORPOS_HWCYPOS (0x07FF<<0) -#define LCD_CURSORPOS_HWCXOFF_N(N) ((N)<<27) -#define LCD_CURSORPOS_HWCXPOS_N(N) ((N)<<16) -#define LCD_CURSORPOS_HWCYOFF_N(N) ((N)<<11) -#define LCD_CURSORPOS_HWCYPOS_N(N) ((N)<<0) - -/* lcd_cursorcolor */ -#define LCD_CURSORCOLOR_HWCA (0xFF<<24) -#define LCD_CURSORCOLOR_HWCR (0xFF<<16) -#define LCD_CURSORCOLOR_HWCG (0xFF<<8) -#define LCD_CURSORCOLOR_HWCB (0xFF<<0) -#define LCD_CURSORCOLOR_HWCA_N(N) ((N)<<24) -#define LCD_CURSORCOLOR_HWCR_N(N) ((N)<<16) -#define LCD_CURSORCOLOR_HWCG_N(N) ((N)<<8) -#define LCD_CURSORCOLOR_HWCB_N(N) ((N)<<0) - -/* lcd_fifoctrl */ -#define LCD_FIFOCTRL_F3IF (1<<29) -#define LCD_FIFOCTRL_F3REQ (0x1F<<24) -#define LCD_FIFOCTRL_F2IF (1<<29) -#define LCD_FIFOCTRL_F2REQ (0x1F<<16) -#define LCD_FIFOCTRL_F1IF (1<<29) -#define LCD_FIFOCTRL_F1REQ (0x1F<<8) -#define LCD_FIFOCTRL_F0IF (1<<29) -#define LCD_FIFOCTRL_F0REQ (0x1F<<0) -#define LCD_FIFOCTRL_F3REQ_N(N) ((N-1)<<24) -#define LCD_FIFOCTRL_F2REQ_N(N) ((N-1)<<16) -#define LCD_FIFOCTRL_F1REQ_N(N) ((N-1)<<8) -#define LCD_FIFOCTRL_F0REQ_N(N) ((N-1)<<0) - -/* lcd_outmask */ -#define LCD_OUTMASK_MASK (0x00FFFFFF) - -/********************************************************************/ -#endif /* _AU1200LCD_H */ -- cgit v1.2.3 From 1c72004c890be1af257f705a9eb7976f167f8c81 Mon Sep 17 00:00:00 2001 From: Vasyl Gomonovych Date: Thu, 4 Jan 2018 16:53:49 +0100 Subject: video: fbdev: omap2: Use PTR_ERR_OR_ZERO() Fix ptr_ret.cocci warnings: drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c:676:1-3: WARNING: PTR_ERR_OR_ZERO can be used Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR Generated by: scripts/coccinelle/api/ptr_ret.cocci Signed-off-by: Vasyl Gomonovych Cc: Tomi Valkeinen Cc: Laurent Pinchart Cc: Mark Brown Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c index ec78d61bc551..28de56e21c74 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c @@ -673,10 +673,7 @@ static int hdmi_audio_register(struct device *dev) dev, "omap-hdmi-audio", PLATFORM_DEVID_AUTO, &pdata, sizeof(pdata)); - if (IS_ERR(hdmi.audio_pdev)) - return PTR_ERR(hdmi.audio_pdev); - - return 0; + return PTR_ERR_OR_ZERO(hdmi.audio_pdev); } /* HDMI HW IP initialisation */ -- cgit v1.2.3 From ee334e00479b646649cace181b6488fcc0f90d9b Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Thu, 4 Jan 2018 16:53:49 +0100 Subject: omapfb: dss: Do not duplicate features data As features data are read only, there is no need to allocate their copy on the heap. Suggested-by: Markus Elfring Signed-off-by: Ladislav Michl Tested-by: Adam Ford #omap3630 Cc: Tomi Valkeinen Cc: Arvind Yadav Cc: Markus Elfring Cc: Peter Ujfalusi Cc: Adam Ford [b.zolnierkie: fixed minor CodingStyle errors reported by checkpatch.pl] Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/omap2/omapfb/dss/dispc.c | 39 ++++++--------------- drivers/video/fbdev/omap2/omapfb/dss/dss.c | 45 +++++++------------------ drivers/video/fbdev/omap2/omapfb/dss/hdmi_phy.c | 31 ++++------------- 3 files changed, 29 insertions(+), 86 deletions(-) diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dispc.c b/drivers/video/fbdev/omap2/omapfb/dss/dispc.c index 7a75dfda9845..fb605aefd9b1 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/dispc.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/dispc.c @@ -3976,52 +3976,33 @@ static const struct dispc_features omap54xx_dispc_feats = { .has_writeback = true, }; -static int dispc_init_features(struct platform_device *pdev) +static const struct dispc_features *dispc_get_features(void) { - const struct dispc_features *src; - struct dispc_features *dst; - - dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); - if (!dst) { - dev_err(&pdev->dev, "Failed to allocate DISPC Features\n"); - return -ENOMEM; - } - switch (omapdss_get_version()) { case OMAPDSS_VER_OMAP24xx: - src = &omap24xx_dispc_feats; - break; + return &omap24xx_dispc_feats; case OMAPDSS_VER_OMAP34xx_ES1: - src = &omap34xx_rev1_0_dispc_feats; - break; + return &omap34xx_rev1_0_dispc_feats; case OMAPDSS_VER_OMAP34xx_ES3: case OMAPDSS_VER_OMAP3630: case OMAPDSS_VER_AM35xx: case OMAPDSS_VER_AM43xx: - src = &omap34xx_rev3_0_dispc_feats; - break; + return &omap34xx_rev3_0_dispc_feats; case OMAPDSS_VER_OMAP4430_ES1: case OMAPDSS_VER_OMAP4430_ES2: case OMAPDSS_VER_OMAP4: - src = &omap44xx_dispc_feats; - break; + return &omap44xx_dispc_feats; case OMAPDSS_VER_OMAP5: case OMAPDSS_VER_DRA7xx: - src = &omap54xx_dispc_feats; - break; + return &omap54xx_dispc_feats; default: - return -ENODEV; + return NULL; } - - memcpy(dst, src, sizeof(*dst)); - dispc.feat = dst; - - return 0; } static irqreturn_t dispc_irq_handler(int irq, void *arg) @@ -4078,9 +4059,9 @@ static int dispc_bind(struct device *dev, struct device *master, void *data) spin_lock_init(&dispc.control_lock); - r = dispc_init_features(dispc.pdev); - if (r) - return r; + dispc.feat = dispc_get_features(); + if (!dispc.feat) + return -ENODEV; dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0); if (!dispc_mem) { diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss.c b/drivers/video/fbdev/omap2/omapfb/dss/dss.c index 48c6500c24e1..39fe7247ff98 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/dss.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/dss.c @@ -887,58 +887,37 @@ static const struct dss_features dra7xx_dss_feats = { .num_ports = ARRAY_SIZE(dra7xx_ports), }; -static int dss_init_features(struct platform_device *pdev) +static const struct dss_features *dss_get_features(void) { - const struct dss_features *src; - struct dss_features *dst; - - dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); - if (!dst) { - dev_err(&pdev->dev, "Failed to allocate local DSS Features\n"); - return -ENOMEM; - } - switch (omapdss_get_version()) { case OMAPDSS_VER_OMAP24xx: - src = &omap24xx_dss_feats; - break; + return &omap24xx_dss_feats; case OMAPDSS_VER_OMAP34xx_ES1: case OMAPDSS_VER_OMAP34xx_ES3: case OMAPDSS_VER_AM35xx: - src = &omap34xx_dss_feats; - break; + return &omap34xx_dss_feats; case OMAPDSS_VER_OMAP3630: - src = &omap3630_dss_feats; - break; + return &omap3630_dss_feats; case OMAPDSS_VER_OMAP4430_ES1: case OMAPDSS_VER_OMAP4430_ES2: case OMAPDSS_VER_OMAP4: - src = &omap44xx_dss_feats; - break; + return &omap44xx_dss_feats; case OMAPDSS_VER_OMAP5: - src = &omap54xx_dss_feats; - break; + return &omap54xx_dss_feats; case OMAPDSS_VER_AM43xx: - src = &am43xx_dss_feats; - break; + return &am43xx_dss_feats; case OMAPDSS_VER_DRA7xx: - src = &dra7xx_dss_feats; - break; + return &dra7xx_dss_feats; default: - return -ENODEV; + return NULL; } - - memcpy(dst, src, sizeof(*dst)); - dss.feat = dst; - - return 0; } static void dss_uninit_ports(struct platform_device *pdev); @@ -1104,9 +1083,9 @@ static int dss_bind(struct device *dev) dss.pdev = pdev; - r = dss_init_features(dss.pdev); - if (r) - return r; + dss.feat = dss_get_features(); + if (!dss.feat) + return -ENODEV; dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); if (!dss_mem) { diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi_phy.c b/drivers/video/fbdev/omap2/omapfb/dss/hdmi_phy.c index 9a13c35fd6d8..eee09b4bdcf6 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi_phy.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi_phy.c @@ -189,47 +189,30 @@ static const struct hdmi_phy_features omap54xx_phy_feats = { .max_phy = 186000000, }; -static int hdmi_phy_init_features(struct platform_device *pdev) +static const struct hdmi_phy_features *hdmi_phy_get_features(void) { - struct hdmi_phy_features *dst; - const struct hdmi_phy_features *src; - - dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); - if (!dst) { - dev_err(&pdev->dev, "Failed to allocate HDMI PHY Features\n"); - return -ENOMEM; - } - switch (omapdss_get_version()) { case OMAPDSS_VER_OMAP4430_ES1: case OMAPDSS_VER_OMAP4430_ES2: case OMAPDSS_VER_OMAP4: - src = &omap44xx_phy_feats; - break; + return &omap44xx_phy_feats; case OMAPDSS_VER_OMAP5: case OMAPDSS_VER_DRA7xx: - src = &omap54xx_phy_feats; - break; + return &omap54xx_phy_feats; default: - return -ENODEV; + return NULL; } - - memcpy(dst, src, sizeof(*dst)); - phy_feat = dst; - - return 0; } int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy) { - int r; struct resource *res; - r = hdmi_phy_init_features(pdev); - if (r) - return r; + phy_feat = hdmi_phy_get_features(); + if (!phy_feat) + return -ENODEV; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); if (!res) { -- cgit v1.2.3 From f1b95b71f19562a17bfc34c355efe3a86049f8bb Mon Sep 17 00:00:00 2001 From: Ji Zhang Date: Thu, 4 Jan 2018 16:53:50 +0100 Subject: fbdev: arm64 use __raw I/O memory api Since arm64 also has __raw I/O accessors, add __aarch64__ in fb.h. This is a supplement for commmit 981409b25e2a ("fbdev: arm has __raw I/O accessors, use them in fb.h"). Signed-off-by: Ji Zhang Cc: Matthias Brugger Signed-off-by: Bartlomiej Zolnierkiewicz --- include/linux/fb.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/fb.h b/include/linux/fb.h index bc24e48e396d..cea8a2c39034 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -564,7 +564,10 @@ static inline struct apertures_struct *alloc_apertures(unsigned int max_num) { #define fb_memcpy_fromfb sbus_memcpy_fromio #define fb_memcpy_tofb sbus_memcpy_toio -#elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) || defined(__hppa__) || defined(__sh__) || defined(__powerpc__) || defined(__avr32__) || defined(__bfin__) || defined(__arm__) +#elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) || \ + defined(__hppa__) || defined(__sh__) || defined(__powerpc__) || \ + defined(__avr32__) || defined(__bfin__) || defined(__arm__) || \ + defined(__aarch64__) #define fb_readb __raw_readb #define fb_readw __raw_readw -- cgit v1.2.3 From 7b9faf5df0ac495a1a3d7cdb64921c179f9008ac Mon Sep 17 00:00:00 2001 From: "Pieter \\\"PoroCYon\\\" Sluys" Date: Thu, 4 Jan 2018 16:53:50 +0100 Subject: vfb: fix video mode and line_length being set when loaded Currently, when loading the vfb module, the newly created fbdev has a line_length of 0, and its video mode would be PSEUDOCOLOR regardless of color depth. (The former could be worked around by calling the FBIOPUT_VSCREENINFO ioctl with having the FBACTIVIATE_FORCE flag set.) This patch automatically sets the line_length correctly, and the video mode is derived from the bit depth now as well. Thanks to Geert Uytterhoeven for confirming the bug and helping me with the patch. Output of `fbset -i' before the patch: mode "1366x768-60" # D: 72.432 MHz, H: 47.403 kHz, V: 60.004 Hz geometry 1366 768 1366 768 32 timings 13806 120 10 14 3 32 5 rgba 8/0,8/8,8/16,8/24 endmode Frame buffer device information: Name : Virtual FB Address : 0xffffaa1405d85000 Size : 4196352 Type : PACKED PIXELS Visual : PSEUDOCOLOR XPanStep : 1 YPanStep : 1 YWrapStep : 1 LineLength : 0 <-- note this Accelerator : No After: mode "1366x768-60" # D: 72.432 MHz, H: 47.403 kHz, V: 60.004 Hz geometry 1366 768 1366 768 32 timings 13806 120 10 14 3 32 5 rgba 8/0,8/8,8/16,8/24 endmode Frame buffer device information: Name : Virtual FB Address : 0xffffaa1405d85000 Size : 4196352 Type : PACKED PIXELS Visual : TRUECOLOR XPanStep : 1 YPanStep : 1 YWrapStep : 1 LineLength : 5464 Accelerator : No Signed-off-by: "Pieter \"PoroCYon\" Sluys" Reviewed-by: Geert Uytterhoeven [b.zolnierkie: minor fixups] Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/vfb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c index da653a080394..54127905bfe7 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -239,8 +239,23 @@ static int vfb_check_var(struct fb_var_screeninfo *var, */ static int vfb_set_par(struct fb_info *info) { + switch (info->var.bits_per_pixel) { + case 1: + info->fix.visual = FB_VISUAL_MONO01; + break; + case 8: + info->fix.visual = FB_VISUAL_PSEUDOCOLOR; + break; + case 16: + case 24: + case 32: + info->fix.visual = FB_VISUAL_TRUECOLOR; + break; + } + info->fix.line_length = get_line_length(info->var.xres_virtual, info->var.bits_per_pixel); + return 0; } @@ -450,6 +465,8 @@ static int vfb_probe(struct platform_device *dev) goto err2; platform_set_drvdata(dev, info); + vfb_set_par(info); + fb_info(info, "Virtual frame buffer device, using %ldK of video memory\n", videomemorysize >> 10); return 0; -- cgit v1.2.3 From f950bc7880b31cfede87d99fbc4fd4d2b40914c5 Mon Sep 17 00:00:00 2001 From: Himanshu Jha Date: Thu, 4 Jan 2018 16:53:50 +0100 Subject: fbdev: auo_k190x: Use zeroing memory allocator instead of allocator/memset Use vzalloc for allocating zeroed memory and remove unnecessary memset function. Done using Coccinelle. Generated-by scripts/coccinelle/api/alloc/kzalloc-simple.cocci. 0-day tested with no failures. Suggested-by: Luis R. Rodriguez Signed-off-by: Himanshu Jha [b.zolnierkie: fixed minor issues in the patch description] Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/auo_k190x.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/video/fbdev/auo_k190x.c b/drivers/video/fbdev/auo_k190x.c index 0d06038324e0..b8894013014b 100644 --- a/drivers/video/fbdev/auo_k190x.c +++ b/drivers/video/fbdev/auo_k190x.c @@ -1056,13 +1056,12 @@ int auok190x_common_probe(struct platform_device *pdev, /* videomemory handling */ videomemorysize = roundup((panel->w * panel->h) * 2, PAGE_SIZE); - videomemory = vmalloc(videomemorysize); + videomemory = vzalloc(videomemorysize); if (!videomemory) { ret = -ENOMEM; goto err_irq; } - memset(videomemory, 0, videomemorysize); info->screen_base = (char *)videomemory; info->fix.smem_len = videomemorysize; -- cgit v1.2.3 From acea8d5fd83177c4dfd9316d055e076960121abe Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Mon, 15 Jan 2018 17:04:21 +0100 Subject: video: udlfb: Remove unnecessary local variable 'urb' is not needed and can be removed. Signed-off-by: Ladislav Michl Cc: Bernie Thompson Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/udlfb.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index 99ce445986b3..5f68f8c720ec 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -1919,7 +1919,6 @@ static struct urb *dlfb_get_urb(struct dlfb_data *dev) int ret; struct list_head *entry; struct urb_node *unode; - struct urb *urb = NULL; unsigned long flags; /* Wait for an in-flight buffer to complete and get re-queued */ @@ -1928,7 +1927,7 @@ static struct urb *dlfb_get_urb(struct dlfb_data *dev) atomic_set(&dev->lost_pixels, 1); pr_warn("wait for urb interrupted: %x available: %d\n", ret, dev->urbs.available); - goto error; + return NULL; } spin_lock_irqsave(&dev->urbs.lock, flags); @@ -1941,10 +1940,7 @@ static struct urb *dlfb_get_urb(struct dlfb_data *dev) spin_unlock_irqrestore(&dev->urbs.lock, flags); unode = list_entry(entry, struct urb_node, entry); - urb = unode->urb; - -error: - return urb; + return unode->urb; } static int dlfb_submit_urb(struct dlfb_data *dev, struct urb *urb, size_t len) -- cgit v1.2.3 From 84df64956bf4d71a831a4cac5fca5b1985eba654 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Mon, 15 Jan 2018 17:04:21 +0100 Subject: video: udlfb: Remove redundant gdev variable gdev is not really needed as the same content can be read from udev->dev. Signed-off-by: Ladislav Michl Cc: Bernie Thompson Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/udlfb.c | 4 +--- include/video/udlfb.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index 5f68f8c720ec..d4e15d97a264 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -1605,7 +1605,6 @@ static int dlfb_usb_probe(struct usb_interface *interface, kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */ dev->udev = usbdev; - dev->gdev = &usbdev->dev; /* our generic struct device * */ usb_set_intfdata(interface, dev); pr_info("%s %s - serial #%s\n", @@ -1670,7 +1669,7 @@ static void dlfb_init_framebuffer_work(struct work_struct *work) int i; /* allocates framebuffer driver structure, not framebuffer memory */ - info = framebuffer_alloc(0, dev->gdev); + info = framebuffer_alloc(0, &dev->udev->dev); if (!info) { pr_err("framebuffer_alloc failed\n"); goto error; @@ -1765,7 +1764,6 @@ static void dlfb_usb_disconnect(struct usb_interface *interface) usb_set_intfdata(interface, NULL); dev->udev = NULL; - dev->gdev = NULL; /* if clients still have us open, will be freed on last close */ if (dev->fb_count == 0) diff --git a/include/video/udlfb.h b/include/video/udlfb.h index 1252a7a89bc0..7b4f567dd1fe 100644 --- a/include/video/udlfb.h +++ b/include/video/udlfb.h @@ -35,7 +35,6 @@ struct urb_list { struct dlfb_data { struct usb_device *udev; - struct device *gdev; /* &udev->dev */ struct fb_info *info; struct urb_list urbs; struct kref kref; -- cgit v1.2.3 From de4b74bda8e87a4ed45ebc2c26cc3e2eaae38429 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Mon, 15 Jan 2018 17:04:22 +0100 Subject: video: udlfb: Remove noisy warnings These warnings comes from times of driver development and do not carry any usefull debugging information. Signed-off-by: Ladislav Michl Cc: Bernie Thompson Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/udlfb.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index d4e15d97a264..4a6644432970 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -921,11 +921,7 @@ static void dlfb_free(struct kref *kref) struct dlfb_data *dev = container_of(kref, struct dlfb_data, kref); vfree(dev->backing_buffer); - kfree(dev->edid); - - pr_warn("freeing dlfb_data %p\n", dev); - kfree(dev); } @@ -942,8 +938,6 @@ static void dlfb_free_framebuffer(struct dlfb_data *dev) struct fb_info *info = dev->info; if (info) { - int node = info->node; - unregister_framebuffer(info); if (info->cmap.len != 0) @@ -958,8 +952,6 @@ static void dlfb_free_framebuffer(struct dlfb_data *dev) /* Assume info structure is freed after this point */ framebuffer_release(info); - - pr_warn("fb_info for /dev/fb%d has been freed\n", node); } /* ref taken in probe() as part of registering framebfufer */ @@ -1060,8 +1052,6 @@ static int dlfb_ops_set_par(struct fb_info *info) u16 *pix_framebuffer; int i; - pr_notice("set_par mode %dx%d\n", info->var.xres, info->var.yres); - result = dlfb_set_video_mode(dev, &info->var); if ((result == 0) && (dev->fb_count == 0)) { @@ -1164,8 +1154,6 @@ static int dlfb_realloc_framebuffer(struct dlfb_data *dev, struct fb_info *info) unsigned char *new_fb; unsigned char *new_back = NULL; - pr_warn("Reallocating framebuffer. Addresses will change!\n"); - new_len = info->fix.line_length * info->var.yres; if (PAGE_ALIGN(new_len) > old_len) { @@ -1415,9 +1403,6 @@ static ssize_t edid_show( if (off + count > dev->edid_size) count = dev->edid_size - off; - pr_info("sysfs edid copy %p to %p, %d bytes\n", - dev->edid, buf, (int) count); - memcpy(buf, dev->edid, count); return count; @@ -1443,7 +1428,6 @@ static ssize_t edid_store( if (!dev->edid || memcmp(src, dev->edid, src_size)) return -EINVAL; - pr_info("sysfs written EDID is new default\n"); dlfb_ops_set_par(fb_info); return src_size; } @@ -1827,8 +1811,6 @@ static void dlfb_free_urb_list(struct dlfb_data *dev) int ret; unsigned long flags; - pr_notice("Freeing all render urbs\n"); - /* keep waiting and freeing, until we've got 'em all */ while (count--) { @@ -1907,8 +1889,6 @@ static int dlfb_alloc_urb_list(struct dlfb_data *dev, int count, size_t size) dev->urbs.count = i; dev->urbs.available = i; - pr_notice("allocated %d %d byte urbs\n", i, (int) size); - return i; } -- cgit v1.2.3 From 7ea46206d1706bffa1b4785fe47a530de4c57597 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Mon, 15 Jan 2018 17:04:22 +0100 Subject: video: udlfb: Do not name private data 'dev' Variable 'dev' is usually used for 'struct device'. Therefore rename driver private data to dlfb to avoid confusion once driver will be using dev_*() logging functions. Signed-off-by: Ladislav Michl Cc: Bernie Thompson Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/udlfb.c | 414 ++++++++++++++++++++++---------------------- include/video/udlfb.h | 2 +- 2 files changed, 208 insertions(+), 208 deletions(-) diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index 4a6644432970..47e31668f316 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -76,10 +76,10 @@ static int pixel_limit; /* Optionally force a pixel resolution limit */ /* dlfb keeps a list of urbs for efficient bulk transfers */ static void dlfb_urb_completion(struct urb *urb); -static struct urb *dlfb_get_urb(struct dlfb_data *dev); -static int dlfb_submit_urb(struct dlfb_data *dev, struct urb * urb, size_t len); -static int dlfb_alloc_urb_list(struct dlfb_data *dev, int count, size_t size); -static void dlfb_free_urb_list(struct dlfb_data *dev); +static struct urb *dlfb_get_urb(struct dlfb_data *dlfb); +static int dlfb_submit_urb(struct dlfb_data *dlfb, struct urb * urb, size_t len); +static int dlfb_alloc_urb_list(struct dlfb_data *dlfb, int count, size_t size); +static void dlfb_free_urb_list(struct dlfb_data *dlfb); /* * All DisplayLink bulk operations start with 0xAF, followed by specific code @@ -274,7 +274,7 @@ static char *dlfb_set_vid_cmds(char *wrptr, struct fb_var_screeninfo *var) * and then generates the appropriate command sequence that then drives the * display controller. */ -static int dlfb_set_video_mode(struct dlfb_data *dev, +static int dlfb_set_video_mode(struct dlfb_data *dlfb, struct fb_var_screeninfo *var) { char *buf; @@ -283,10 +283,10 @@ static int dlfb_set_video_mode(struct dlfb_data *dev, int writesize; struct urb *urb; - if (!atomic_read(&dev->usb_active)) + if (!atomic_read(&dlfb->usb_active)) return -EPERM; - urb = dlfb_get_urb(dev); + urb = dlfb_get_urb(dlfb); if (!urb) return -ENOMEM; @@ -302,7 +302,7 @@ static int dlfb_set_video_mode(struct dlfb_data *dev, /* set base for 16bpp segment to 0 */ wrptr = dlfb_set_base16bpp(wrptr, 0); /* set base for 8bpp segment to end of fb */ - wrptr = dlfb_set_base8bpp(wrptr, dev->info->fix.smem_len); + wrptr = dlfb_set_base8bpp(wrptr, dlfb->info->fix.smem_len); wrptr = dlfb_set_vid_cmds(wrptr, var); wrptr = dlfb_blanking(wrptr, FB_BLANK_UNBLANK); @@ -310,9 +310,9 @@ static int dlfb_set_video_mode(struct dlfb_data *dev, writesize = wrptr - buf; - retval = dlfb_submit_urb(dev, urb, writesize); + retval = dlfb_submit_urb(dlfb, urb, writesize); - dev->blank_mode = FB_BLANK_UNBLANK; + dlfb->blank_mode = FB_BLANK_UNBLANK; return retval; } @@ -513,13 +513,13 @@ static void dlfb_compress_hline( * (that we can only write to, slowly, and can never read), and (optionally) * our shadow copy that tracks what's been sent to that hardware buffer. */ -static int dlfb_render_hline(struct dlfb_data *dev, struct urb **urb_ptr, +static int dlfb_render_hline(struct dlfb_data *dlfb, struct urb **urb_ptr, const char *front, char **urb_buf_ptr, u32 byte_offset, u32 byte_width, int *ident_ptr, int *sent_ptr) { const u8 *line_start, *line_end, *next_pixel; - u32 dev_addr = dev->base16 + byte_offset; + u32 dev_addr = dlfb->base16 + byte_offset; struct urb *urb = *urb_ptr; u8 *cmd = *urb_buf_ptr; u8 *cmd_end = (u8 *) urb->transfer_buffer + urb->transfer_buffer_length; @@ -528,9 +528,9 @@ static int dlfb_render_hline(struct dlfb_data *dev, struct urb **urb_ptr, next_pixel = line_start; line_end = next_pixel + byte_width; - if (dev->backing_buffer) { + if (dlfb->backing_buffer) { int offset; - const u8 *back_start = (u8 *) (dev->backing_buffer + const u8 *back_start = (u8 *) (dlfb->backing_buffer + byte_offset); *ident_ptr += dlfb_trim_hline(back_start, &next_pixel, @@ -554,10 +554,10 @@ static int dlfb_render_hline(struct dlfb_data *dev, struct urb **urb_ptr, if (cmd >= cmd_end) { int len = cmd - (u8 *) urb->transfer_buffer; - if (dlfb_submit_urb(dev, urb, len)) + if (dlfb_submit_urb(dlfb, urb, len)) return 1; /* lost pixels is set */ *sent_ptr += len; - urb = dlfb_get_urb(dev); + urb = dlfb_get_urb(dlfb); if (!urb) return 1; /* lost_pixels is set */ *urb_ptr = urb; @@ -571,7 +571,7 @@ static int dlfb_render_hline(struct dlfb_data *dev, struct urb **urb_ptr, return 0; } -static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y, +static int dlfb_handle_damage(struct dlfb_data *dlfb, int x, int y, int width, int height, char *data) { int i, ret; @@ -589,24 +589,24 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y, x = aligned_x; if ((width <= 0) || - (x + width > dev->info->var.xres) || - (y + height > dev->info->var.yres)) + (x + width > dlfb->info->var.xres) || + (y + height > dlfb->info->var.yres)) return -EINVAL; - if (!atomic_read(&dev->usb_active)) + if (!atomic_read(&dlfb->usb_active)) return 0; - urb = dlfb_get_urb(dev); + urb = dlfb_get_urb(dlfb); if (!urb) return 0; cmd = urb->transfer_buffer; for (i = y; i < y + height ; i++) { - const int line_offset = dev->info->fix.line_length * i; + const int line_offset = dlfb->info->fix.line_length * i; const int byte_offset = line_offset + (x * BPP); - if (dlfb_render_hline(dev, &urb, - (char *) dev->info->fix.smem_start, + if (dlfb_render_hline(dlfb, &urb, + (char *) dlfb->info->fix.smem_start, &cmd, byte_offset, width * BPP, &bytes_identical, &bytes_sent)) goto error; @@ -615,19 +615,19 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y, if (cmd > (char *) urb->transfer_buffer) { /* Send partial buffer remaining before exiting */ int len = cmd - (char *) urb->transfer_buffer; - ret = dlfb_submit_urb(dev, urb, len); + ret = dlfb_submit_urb(dlfb, urb, len); bytes_sent += len; } else dlfb_urb_completion(urb); error: - atomic_add(bytes_sent, &dev->bytes_sent); - atomic_add(bytes_identical, &dev->bytes_identical); - atomic_add(width*height*2, &dev->bytes_rendered); + atomic_add(bytes_sent, &dlfb->bytes_sent); + atomic_add(bytes_identical, &dlfb->bytes_identical); + atomic_add(width*height*2, &dlfb->bytes_rendered); end_cycles = get_cycles(); atomic_add(((unsigned int) ((end_cycles - start_cycles) >> 10)), /* Kcycles */ - &dev->cpu_kcycles_used); + &dlfb->cpu_kcycles_used); return 0; } @@ -642,7 +642,7 @@ static ssize_t dlfb_ops_write(struct fb_info *info, const char __user *buf, size_t count, loff_t *ppos) { ssize_t result; - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; u32 offset = (u32) *ppos; result = fb_sys_write(info, buf, count, ppos); @@ -652,7 +652,7 @@ static ssize_t dlfb_ops_write(struct fb_info *info, const char __user *buf, int lines = min((u32)((result / info->fix.line_length) + 1), (u32)info->var.yres); - dlfb_handle_damage(dev, 0, start, info->var.xres, + dlfb_handle_damage(dlfb, 0, start, info->var.xres, lines, info->screen_base); } @@ -664,33 +664,33 @@ static void dlfb_ops_copyarea(struct fb_info *info, const struct fb_copyarea *area) { - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; sys_copyarea(info, area); - dlfb_handle_damage(dev, area->dx, area->dy, + dlfb_handle_damage(dlfb, area->dx, area->dy, area->width, area->height, info->screen_base); } static void dlfb_ops_imageblit(struct fb_info *info, const struct fb_image *image) { - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; sys_imageblit(info, image); - dlfb_handle_damage(dev, image->dx, image->dy, + dlfb_handle_damage(dlfb, image->dx, image->dy, image->width, image->height, info->screen_base); } static void dlfb_ops_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; sys_fillrect(info, rect); - dlfb_handle_damage(dev, rect->dx, rect->dy, rect->width, + dlfb_handle_damage(dlfb, rect->dx, rect->dy, rect->width, rect->height, info->screen_base); } @@ -705,7 +705,7 @@ static void dlfb_dpy_deferred_io(struct fb_info *info, { struct page *cur; struct fb_deferred_io *fbdefio = info->fbdefio; - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; struct urb *urb; char *cmd; cycles_t start_cycles, end_cycles; @@ -716,12 +716,12 @@ static void dlfb_dpy_deferred_io(struct fb_info *info, if (!fb_defio) return; - if (!atomic_read(&dev->usb_active)) + if (!atomic_read(&dlfb->usb_active)) return; start_cycles = get_cycles(); - urb = dlfb_get_urb(dev); + urb = dlfb_get_urb(dlfb); if (!urb) return; @@ -730,7 +730,7 @@ static void dlfb_dpy_deferred_io(struct fb_info *info, /* walk the written page list and render each to device */ list_for_each_entry(cur, &fbdefio->pagelist, lru) { - if (dlfb_render_hline(dev, &urb, (char *) info->fix.smem_start, + if (dlfb_render_hline(dlfb, &urb, (char *) info->fix.smem_start, &cmd, cur->index << PAGE_SHIFT, PAGE_SIZE, &bytes_identical, &bytes_sent)) goto error; @@ -740,22 +740,22 @@ static void dlfb_dpy_deferred_io(struct fb_info *info, if (cmd > (char *) urb->transfer_buffer) { /* Send partial buffer remaining before exiting */ int len = cmd - (char *) urb->transfer_buffer; - dlfb_submit_urb(dev, urb, len); + dlfb_submit_urb(dlfb, urb, len); bytes_sent += len; } else dlfb_urb_completion(urb); error: - atomic_add(bytes_sent, &dev->bytes_sent); - atomic_add(bytes_identical, &dev->bytes_identical); - atomic_add(bytes_rendered, &dev->bytes_rendered); + atomic_add(bytes_sent, &dlfb->bytes_sent); + atomic_add(bytes_identical, &dlfb->bytes_identical); + atomic_add(bytes_rendered, &dlfb->bytes_rendered); end_cycles = get_cycles(); atomic_add(((unsigned int) ((end_cycles - start_cycles) >> 10)), /* Kcycles */ - &dev->cpu_kcycles_used); + &dlfb->cpu_kcycles_used); } -static int dlfb_get_edid(struct dlfb_data *dev, char *edid, int len) +static int dlfb_get_edid(struct dlfb_data *dlfb, char *edid, int len) { int i; int ret; @@ -766,8 +766,8 @@ static int dlfb_get_edid(struct dlfb_data *dev, char *edid, int len) return 0; for (i = 0; i < len; i++) { - ret = usb_control_msg(dev->udev, - usb_rcvctrlpipe(dev->udev, 0), 0x02, + ret = usb_control_msg(dlfb->udev, + usb_rcvctrlpipe(dlfb->udev, 0), 0x02, (0x80 | (0x02 << 5)), i << 8, 0xA1, rbuf, 2, USB_CTRL_GET_TIMEOUT); if (ret < 2) { @@ -787,15 +787,15 @@ static int dlfb_ops_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) { - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; - if (!atomic_read(&dev->usb_active)) + if (!atomic_read(&dlfb->usb_active)) return 0; /* TODO: Update X server to get this from sysfs instead */ if (cmd == DLFB_IOCTL_RETURN_EDID) { void __user *edid = (void __user *)arg; - if (copy_to_user(edid, dev->edid, dev->edid_size)) + if (copy_to_user(edid, dlfb->edid, dlfb->edid_size)) return -EFAULT; return 0; } @@ -830,7 +830,7 @@ static int dlfb_ops_ioctl(struct fb_info *info, unsigned int cmd, if (area.y > info->var.yres) area.y = info->var.yres; - dlfb_handle_damage(dev, area.x, area.y, area.w, area.h, + dlfb_handle_damage(dlfb, area.x, area.y, area.w, area.h, info->screen_base); } @@ -871,7 +871,7 @@ dlfb_ops_setcolreg(unsigned regno, unsigned red, unsigned green, */ static int dlfb_ops_open(struct fb_info *info, int user) { - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; /* * fbcon aggressively connects to first framebuffer it finds, @@ -882,12 +882,12 @@ static int dlfb_ops_open(struct fb_info *info, int user) return -EBUSY; /* If the USB device is gone, we don't accept new opens */ - if (dev->virtualized) + if (dlfb->virtualized) return -ENODEV; - dev->fb_count++; + dlfb->fb_count++; - kref_get(&dev->kref); + kref_get(&dlfb->kref); if (fb_defio && (info->fbdefio == NULL)) { /* enable defio at last moment if not disabled by client */ @@ -906,7 +906,7 @@ static int dlfb_ops_open(struct fb_info *info, int user) } pr_notice("open /dev/fb%d user=%d fb_info=%p count=%d\n", - info->node, user, info, dev->fb_count); + info->node, user, info, dlfb->fb_count); return 0; } @@ -918,11 +918,11 @@ static int dlfb_ops_open(struct fb_info *info, int user) */ static void dlfb_free(struct kref *kref) { - struct dlfb_data *dev = container_of(kref, struct dlfb_data, kref); + struct dlfb_data *dlfb = container_of(kref, struct dlfb_data, kref); - vfree(dev->backing_buffer); - kfree(dev->edid); - kfree(dev); + vfree(dlfb->backing_buffer); + kfree(dlfb->edid); + kfree(dlfb); } static void dlfb_release_urb_work(struct work_struct *work) @@ -930,12 +930,12 @@ static void dlfb_release_urb_work(struct work_struct *work) struct urb_node *unode = container_of(work, struct urb_node, release_urb_work.work); - up(&unode->dev->urbs.limit_sem); + up(&unode->dlfb->urbs.limit_sem); } -static void dlfb_free_framebuffer(struct dlfb_data *dev) +static void dlfb_free_framebuffer(struct dlfb_data *dlfb) { - struct fb_info *info = dev->info; + struct fb_info *info = dlfb->info; if (info) { unregister_framebuffer(info); @@ -948,36 +948,36 @@ static void dlfb_free_framebuffer(struct dlfb_data *dev) fb_destroy_modelist(&info->modelist); - dev->info = NULL; + dlfb->info = NULL; /* Assume info structure is freed after this point */ framebuffer_release(info); } /* ref taken in probe() as part of registering framebfufer */ - kref_put(&dev->kref, dlfb_free); + kref_put(&dlfb->kref, dlfb_free); } static void dlfb_free_framebuffer_work(struct work_struct *work) { - struct dlfb_data *dev = container_of(work, struct dlfb_data, + struct dlfb_data *dlfb = container_of(work, struct dlfb_data, free_framebuffer_work.work); - dlfb_free_framebuffer(dev); + dlfb_free_framebuffer(dlfb); } /* * Assumes caller is holding info->lock mutex (for open and release at least) */ static int dlfb_ops_release(struct fb_info *info, int user) { - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; - dev->fb_count--; + dlfb->fb_count--; /* We can't free fb_info here - fbmem will touch it when we return */ - if (dev->virtualized && (dev->fb_count == 0)) - schedule_delayed_work(&dev->free_framebuffer_work, HZ); + if (dlfb->virtualized && (dlfb->fb_count == 0)) + schedule_delayed_work(&dlfb->free_framebuffer_work, HZ); - if ((dev->fb_count == 0) && (info->fbdefio)) { + if ((dlfb->fb_count == 0) && (info->fbdefio)) { fb_deferred_io_cleanup(info); kfree(info->fbdefio); info->fbdefio = NULL; @@ -985,9 +985,9 @@ static int dlfb_ops_release(struct fb_info *info, int user) } pr_warn("released /dev/fb%d user=%d count=%d\n", - info->node, user, dev->fb_count); + info->node, user, dlfb->fb_count); - kref_put(&dev->kref, dlfb_free); + kref_put(&dlfb->kref, dlfb_free); return 0; } @@ -999,9 +999,9 @@ static int dlfb_ops_release(struct fb_info *info, int user) static int dlfb_is_valid_mode(struct fb_videomode *mode, struct fb_info *info) { - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; - if (mode->xres * mode->yres > dev->sku_pixel_limit) { + if (mode->xres * mode->yres > dlfb->sku_pixel_limit) { pr_warn("%dx%d beyond chip capabilities\n", mode->xres, mode->yres); return 0; @@ -1047,14 +1047,14 @@ static int dlfb_ops_check_var(struct fb_var_screeninfo *var, static int dlfb_ops_set_par(struct fb_info *info) { - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; int result; u16 *pix_framebuffer; int i; - result = dlfb_set_video_mode(dev, &info->var); + result = dlfb_set_video_mode(dlfb, &info->var); - if ((result == 0) && (dev->fb_count == 0)) { + if ((result == 0) && (dlfb->fb_count == 0)) { /* paint greenscreen */ @@ -1062,7 +1062,7 @@ static int dlfb_ops_set_par(struct fb_info *info) for (i = 0; i < info->fix.smem_len / 2; i++) pix_framebuffer[i] = 0x37e6; - dlfb_handle_damage(dev, 0, 0, info->var.xres, info->var.yres, + dlfb_handle_damage(dlfb, 0, 0, info->var.xres, info->var.yres, info->screen_base); } @@ -1089,21 +1089,21 @@ static char *dlfb_dummy_render(char *buf) */ static int dlfb_ops_blank(int blank_mode, struct fb_info *info) { - struct dlfb_data *dev = info->par; + struct dlfb_data *dlfb = info->par; char *bufptr; struct urb *urb; pr_debug("/dev/fb%d FB_BLANK mode %d --> %d\n", - info->node, dev->blank_mode, blank_mode); + info->node, dlfb->blank_mode, blank_mode); - if ((dev->blank_mode == FB_BLANK_POWERDOWN) && + if ((dlfb->blank_mode == FB_BLANK_POWERDOWN) && (blank_mode != FB_BLANK_POWERDOWN)) { /* returning from powerdown requires a fresh modeset */ - dlfb_set_video_mode(dev, &info->var); + dlfb_set_video_mode(dlfb, &info->var); } - urb = dlfb_get_urb(dev); + urb = dlfb_get_urb(dlfb); if (!urb) return 0; @@ -1115,10 +1115,10 @@ static int dlfb_ops_blank(int blank_mode, struct fb_info *info) /* seems like a render op is needed to have blank change take effect */ bufptr = dlfb_dummy_render(bufptr); - dlfb_submit_urb(dev, urb, bufptr - + dlfb_submit_urb(dlfb, urb, bufptr - (char *) urb->transfer_buffer); - dev->blank_mode = blank_mode; + dlfb->blank_mode = blank_mode; return 0; } @@ -1145,7 +1145,7 @@ static struct fb_ops dlfb_ops = { * Assumes &info->lock held by caller * Assumes no active clients have framebuffer open */ -static int dlfb_realloc_framebuffer(struct dlfb_data *dev, struct fb_info *info) +static int dlfb_realloc_framebuffer(struct dlfb_data *dlfb, struct fb_info *info) { int retval = -ENOMEM; int old_len = info->fix.smem_len; @@ -1187,8 +1187,8 @@ static int dlfb_realloc_framebuffer(struct dlfb_data *dev, struct fb_info *info) if (!new_back) pr_info("No shadow/backing buffer allocated\n"); else { - vfree(dev->backing_buffer); - dev->backing_buffer = new_back; + vfree(dlfb->backing_buffer); + dlfb->backing_buffer = new_back; } } @@ -1212,7 +1212,7 @@ error: * monspecs is NULL, and fb_var_screeninfo is set to safe VESA mode * Returns 0 if successful */ -static int dlfb_setup_modes(struct dlfb_data *dev, +static int dlfb_setup_modes(struct dlfb_data *dlfb, struct fb_info *info, char *default_edid, size_t default_edid_size) { @@ -1241,14 +1241,14 @@ static int dlfb_setup_modes(struct dlfb_data *dev, */ while (tries--) { - i = dlfb_get_edid(dev, edid, EDID_LENGTH); + i = dlfb_get_edid(dlfb, edid, EDID_LENGTH); if (i >= EDID_LENGTH) fb_edid_to_monspecs(edid, &info->monspecs); if (info->monspecs.modedb_len > 0) { - dev->edid = edid; - dev->edid_size = i; + dlfb->edid = edid; + dlfb->edid_size = i; break; } } @@ -1258,8 +1258,8 @@ static int dlfb_setup_modes(struct dlfb_data *dev, pr_err("Unable to get valid EDID from device/display\n"); - if (dev->edid) { - fb_edid_to_monspecs(dev->edid, &info->monspecs); + if (dlfb->edid) { + fb_edid_to_monspecs(dlfb->edid, &info->monspecs); if (info->monspecs.modedb_len > 0) pr_err("Using previously queried EDID\n"); } @@ -1271,8 +1271,8 @@ static int dlfb_setup_modes(struct dlfb_data *dev, fb_edid_to_monspecs(default_edid, &info->monspecs); if (info->monspecs.modedb_len > 0) { memcpy(edid, default_edid, default_edid_size); - dev->edid = edid; - dev->edid_size = default_edid_size; + dlfb->edid = edid; + dlfb->edid_size = default_edid_size; pr_err("Using default/backup EDID\n"); } } @@ -1327,7 +1327,7 @@ static int dlfb_setup_modes(struct dlfb_data *dev, } /* If we have good mode and no active clients*/ - if ((default_vmode != NULL) && (dev->fb_count == 0)) { + if ((default_vmode != NULL) && (dlfb->fb_count == 0)) { fb_videomode_to_var(&info->var, default_vmode); dlfb_var_color_format(&info->var); @@ -1339,13 +1339,13 @@ static int dlfb_setup_modes(struct dlfb_data *dev, info->fix.line_length = info->var.xres * (info->var.bits_per_pixel / 8); - result = dlfb_realloc_framebuffer(dev, info); + result = dlfb_realloc_framebuffer(dlfb, info); } else result = -EINVAL; error: - if (edid && (dev->edid != edid)) + if (edid && (dlfb->edid != edid)) kfree(edid); if (info->dev) @@ -1357,33 +1357,33 @@ error: static ssize_t metrics_bytes_rendered_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev); - struct dlfb_data *dev = fb_info->par; + struct dlfb_data *dlfb = fb_info->par; return snprintf(buf, PAGE_SIZE, "%u\n", - atomic_read(&dev->bytes_rendered)); + atomic_read(&dlfb->bytes_rendered)); } static ssize_t metrics_bytes_identical_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev); - struct dlfb_data *dev = fb_info->par; + struct dlfb_data *dlfb = fb_info->par; return snprintf(buf, PAGE_SIZE, "%u\n", - atomic_read(&dev->bytes_identical)); + atomic_read(&dlfb->bytes_identical)); } static ssize_t metrics_bytes_sent_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev); - struct dlfb_data *dev = fb_info->par; + struct dlfb_data *dlfb = fb_info->par; return snprintf(buf, PAGE_SIZE, "%u\n", - atomic_read(&dev->bytes_sent)); + atomic_read(&dlfb->bytes_sent)); } static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev); - struct dlfb_data *dev = fb_info->par; + struct dlfb_data *dlfb = fb_info->par; return snprintf(buf, PAGE_SIZE, "%u\n", - atomic_read(&dev->cpu_kcycles_used)); + atomic_read(&dlfb->cpu_kcycles_used)); } static ssize_t edid_show( @@ -1392,18 +1392,18 @@ static ssize_t edid_show( char *buf, loff_t off, size_t count) { struct device *fbdev = container_of(kobj, struct device, kobj); struct fb_info *fb_info = dev_get_drvdata(fbdev); - struct dlfb_data *dev = fb_info->par; + struct dlfb_data *dlfb = fb_info->par; - if (dev->edid == NULL) + if (dlfb->edid == NULL) return 0; - if ((off >= dev->edid_size) || (count > dev->edid_size)) + if ((off >= dlfb->edid_size) || (count > dlfb->edid_size)) return 0; - if (off + count > dev->edid_size) - count = dev->edid_size - off; + if (off + count > dlfb->edid_size) + count = dlfb->edid_size - off; - memcpy(buf, dev->edid, count); + memcpy(buf, dlfb->edid, count); return count; } @@ -1414,18 +1414,18 @@ static ssize_t edid_store( char *src, loff_t src_off, size_t src_size) { struct device *fbdev = container_of(kobj, struct device, kobj); struct fb_info *fb_info = dev_get_drvdata(fbdev); - struct dlfb_data *dev = fb_info->par; + struct dlfb_data *dlfb = fb_info->par; int ret; /* We only support write of entire EDID at once, no offset*/ if ((src_size != EDID_LENGTH) || (src_off != 0)) return -EINVAL; - ret = dlfb_setup_modes(dev, fb_info, src, src_size); + ret = dlfb_setup_modes(dlfb, fb_info, src, src_size); if (ret) return ret; - if (!dev->edid || memcmp(src, dev->edid, src_size)) + if (!dlfb->edid || memcmp(src, dlfb->edid, src_size)) return -EINVAL; dlfb_ops_set_par(fb_info); @@ -1437,12 +1437,12 @@ static ssize_t metrics_reset_store(struct device *fbdev, const char *buf, size_t count) { struct fb_info *fb_info = dev_get_drvdata(fbdev); - struct dlfb_data *dev = fb_info->par; + struct dlfb_data *dlfb = fb_info->par; - atomic_set(&dev->bytes_rendered, 0); - atomic_set(&dev->bytes_identical, 0); - atomic_set(&dev->bytes_sent, 0); - atomic_set(&dev->cpu_kcycles_used, 0); + atomic_set(&dlfb->bytes_rendered, 0); + atomic_set(&dlfb->bytes_identical, 0); + atomic_set(&dlfb->bytes_sent, 0); + atomic_set(&dlfb->cpu_kcycles_used, 0); return count; } @@ -1466,7 +1466,7 @@ static struct device_attribute fb_device_attrs[] = { /* * This is necessary before we can communicate with the display controller. */ -static int dlfb_select_std_channel(struct dlfb_data *dev) +static int dlfb_select_std_channel(struct dlfb_data *dlfb) { int ret; void *buf; @@ -1481,7 +1481,7 @@ static int dlfb_select_std_channel(struct dlfb_data *dev) if (!buf) return -ENOMEM; - ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), + ret = usb_control_msg(dlfb->udev, usb_sndctrlpipe(dlfb->udev, 0), NR_USB_REQUEST_CHANNEL, (USB_DIR_OUT | USB_TYPE_VENDOR), 0, 0, buf, sizeof(set_def_chn), USB_CTRL_SET_TIMEOUT); @@ -1491,7 +1491,7 @@ static int dlfb_select_std_channel(struct dlfb_data *dev) return ret; } -static int dlfb_parse_vendor_descriptor(struct dlfb_data *dev, +static int dlfb_parse_vendor_descriptor(struct dlfb_data *dlfb, struct usb_interface *interface) { char *desc; @@ -1544,7 +1544,7 @@ static int dlfb_parse_vendor_descriptor(struct dlfb_data *dev, max_area = le32_to_cpu(*((u32 *)desc)); pr_warn("DL chip limited to %d pixel modes\n", max_area); - dev->sku_pixel_limit = max_area; + dlfb->sku_pixel_limit = max_area; break; } default: @@ -1573,37 +1573,37 @@ static int dlfb_usb_probe(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_device *usbdev; - struct dlfb_data *dev; + struct dlfb_data *dlfb; int retval = -ENOMEM; /* usb initialization */ usbdev = interface_to_usbdev(interface); - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (dev == NULL) { + dlfb = kzalloc(sizeof(*dlfb), GFP_KERNEL); + if (dlfb == NULL) { dev_err(&interface->dev, "dlfb_usb_probe: failed alloc of dev struct\n"); goto error; } - kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */ + kref_init(&dlfb->kref); /* matching kref_put in usb .disconnect fn */ - dev->udev = usbdev; - usb_set_intfdata(interface, dev); + dlfb->udev = usbdev; + usb_set_intfdata(interface, dlfb); pr_info("%s %s - serial #%s\n", usbdev->manufacturer, usbdev->product, usbdev->serial); pr_info("vid_%04x&pid_%04x&rev_%04x driver's dlfb_data struct at %p\n", le16_to_cpu(usbdev->descriptor.idVendor), le16_to_cpu(usbdev->descriptor.idProduct), - le16_to_cpu(usbdev->descriptor.bcdDevice), dev); + le16_to_cpu(usbdev->descriptor.bcdDevice), dlfb); pr_info("console enable=%d\n", console); pr_info("fb_defio enable=%d\n", fb_defio); pr_info("shadow enable=%d\n", shadow); - dev->sku_pixel_limit = 2048 * 1152; /* default to maximum */ + dlfb->sku_pixel_limit = 2048 * 1152; /* default to maximum */ - if (!dlfb_parse_vendor_descriptor(dev, interface)) { + if (!dlfb_parse_vendor_descriptor(dlfb, interface)) { pr_err("firmware not recognized. Assume incompatible device\n"); goto error; } @@ -1611,32 +1611,32 @@ static int dlfb_usb_probe(struct usb_interface *interface, if (pixel_limit) { pr_warn("DL chip limit of %d overridden" " by module param to %d\n", - dev->sku_pixel_limit, pixel_limit); - dev->sku_pixel_limit = pixel_limit; + dlfb->sku_pixel_limit, pixel_limit); + dlfb->sku_pixel_limit = pixel_limit; } - if (!dlfb_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) { + if (!dlfb_alloc_urb_list(dlfb, WRITES_IN_FLIGHT, MAX_TRANSFER)) { retval = -ENOMEM; pr_err("dlfb_alloc_urb_list failed\n"); goto error; } - kref_get(&dev->kref); /* matching kref_put in free_framebuffer_work */ + kref_get(&dlfb->kref); /* matching kref_put in free_framebuffer_work */ - /* We don't register a new USB class. Our client interface is fbdev */ + /* We don't register a new USB class. Our client interface is dlfbev */ /* Workitem keep things fast & simple during USB enumeration */ - INIT_DELAYED_WORK(&dev->init_framebuffer_work, + INIT_DELAYED_WORK(&dlfb->init_framebuffer_work, dlfb_init_framebuffer_work); - schedule_delayed_work(&dev->init_framebuffer_work, 0); + schedule_delayed_work(&dlfb->init_framebuffer_work, 0); return 0; error: - if (dev) { + if (dlfb) { - kref_put(&dev->kref, dlfb_free); /* last ref from kref_init */ + kref_put(&dlfb->kref, dlfb_free); /* last ref from kref_init */ /* dev has been deallocated. Do not dereference */ } @@ -1646,22 +1646,22 @@ error: static void dlfb_init_framebuffer_work(struct work_struct *work) { - struct dlfb_data *dev = container_of(work, struct dlfb_data, + struct dlfb_data *dlfb = container_of(work, struct dlfb_data, init_framebuffer_work.work); struct fb_info *info; int retval; int i; /* allocates framebuffer driver structure, not framebuffer memory */ - info = framebuffer_alloc(0, &dev->udev->dev); + info = framebuffer_alloc(0, &dlfb->udev->dev); if (!info) { pr_err("framebuffer_alloc failed\n"); goto error; } - dev->info = info; - info->par = dev; - info->pseudo_palette = dev->pseudo_palette; + dlfb->info = info; + info->par = dlfb; + info->pseudo_palette = dlfb->pseudo_palette; info->fbops = &dlfb_ops; retval = fb_alloc_cmap(&info->cmap, 256, 0); @@ -1670,12 +1670,12 @@ static void dlfb_init_framebuffer_work(struct work_struct *work) goto error; } - INIT_DELAYED_WORK(&dev->free_framebuffer_work, + INIT_DELAYED_WORK(&dlfb->free_framebuffer_work, dlfb_free_framebuffer_work); INIT_LIST_HEAD(&info->modelist); - retval = dlfb_setup_modes(dev, info, NULL, 0); + retval = dlfb_setup_modes(dlfb, info, NULL, 0); if (retval != 0) { pr_err("unable to find common mode for display and adapter\n"); goto error; @@ -1683,8 +1683,8 @@ static void dlfb_init_framebuffer_work(struct work_struct *work) /* ready to begin using device */ - atomic_set(&dev->usb_active, 1); - dlfb_select_std_channel(dev); + atomic_set(&dlfb->usb_active, 1); + dlfb_select_std_channel(dlfb); dlfb_ops_check_var(&info->var, info); dlfb_ops_set_par(info); @@ -1710,33 +1710,33 @@ static void dlfb_init_framebuffer_work(struct work_struct *work) pr_info("DisplayLink USB device /dev/fb%d attached. %dx%d resolution." " Using %dK framebuffer memory\n", info->node, info->var.xres, info->var.yres, - ((dev->backing_buffer) ? + ((dlfb->backing_buffer) ? info->fix.smem_len * 2 : info->fix.smem_len) >> 10); return; error: - dlfb_free_framebuffer(dev); + dlfb_free_framebuffer(dlfb); } static void dlfb_usb_disconnect(struct usb_interface *interface) { - struct dlfb_data *dev; + struct dlfb_data *dlfb; struct fb_info *info; int i; - dev = usb_get_intfdata(interface); - info = dev->info; + dlfb = usb_get_intfdata(interface); + info = dlfb->info; pr_info("USB disconnect starting\n"); /* we virtualize until all fb clients release. Then we free */ - dev->virtualized = true; + dlfb->virtualized = true; /* When non-active we'll update virtual framebuffer, but no new urbs */ - atomic_set(&dev->usb_active, 0); + atomic_set(&dlfb->usb_active, 0); /* this function will wait for all in-flight urbs to complete */ - dlfb_free_urb_list(dev); + dlfb_free_urb_list(dlfb); if (info) { /* remove udlfb's sysfs interfaces */ @@ -1747,14 +1747,14 @@ static void dlfb_usb_disconnect(struct usb_interface *interface) } usb_set_intfdata(interface, NULL); - dev->udev = NULL; + dlfb->udev = NULL; /* if clients still have us open, will be freed on last close */ - if (dev->fb_count == 0) - schedule_delayed_work(&dev->free_framebuffer_work, 0); + if (dlfb->fb_count == 0) + schedule_delayed_work(&dlfb->free_framebuffer_work, 0); /* release reference taken by kref_init in probe() */ - kref_put(&dev->kref, dlfb_free); + kref_put(&dlfb->kref, dlfb_free); /* consider dlfb_data freed */ } @@ -1771,7 +1771,7 @@ module_usb_driver(dlfb_driver); static void dlfb_urb_completion(struct urb *urb) { struct urb_node *unode = urb->context; - struct dlfb_data *dev = unode->dev; + struct dlfb_data *dlfb = unode->dlfb; unsigned long flags; /* sync/async unlink faults aren't errors */ @@ -1781,16 +1781,16 @@ static void dlfb_urb_completion(struct urb *urb) urb->status == -ESHUTDOWN)) { pr_err("%s - nonzero write bulk status received: %d\n", __func__, urb->status); - atomic_set(&dev->lost_pixels, 1); + atomic_set(&dlfb->lost_pixels, 1); } } - urb->transfer_buffer_length = dev->urbs.size; /* reset to actual */ + urb->transfer_buffer_length = dlfb->urbs.size; /* reset to actual */ - spin_lock_irqsave(&dev->urbs.lock, flags); - list_add_tail(&unode->entry, &dev->urbs.list); - dev->urbs.available++; - spin_unlock_irqrestore(&dev->urbs.lock, flags); + spin_lock_irqsave(&dlfb->urbs.lock, flags); + list_add_tail(&unode->entry, &dlfb->urbs.list); + dlfb->urbs.available++; + spin_unlock_irqrestore(&dlfb->urbs.lock, flags); /* * When using fb_defio, we deadlock if up() is called @@ -1799,12 +1799,12 @@ static void dlfb_urb_completion(struct urb *urb) if (fb_defio) schedule_delayed_work(&unode->release_urb_work, 0); else - up(&dev->urbs.limit_sem); + up(&dlfb->urbs.limit_sem); } -static void dlfb_free_urb_list(struct dlfb_data *dev) +static void dlfb_free_urb_list(struct dlfb_data *dlfb) { - int count = dev->urbs.count; + int count = dlfb->urbs.count; struct list_head *node; struct urb_node *unode; struct urb *urb; @@ -1815,47 +1815,47 @@ static void dlfb_free_urb_list(struct dlfb_data *dev) while (count--) { /* Getting interrupted means a leak, but ok at disconnect */ - ret = down_interruptible(&dev->urbs.limit_sem); + ret = down_interruptible(&dlfb->urbs.limit_sem); if (ret) break; - spin_lock_irqsave(&dev->urbs.lock, flags); + spin_lock_irqsave(&dlfb->urbs.lock, flags); - node = dev->urbs.list.next; /* have reserved one with sem */ + node = dlfb->urbs.list.next; /* have reserved one with sem */ list_del_init(node); - spin_unlock_irqrestore(&dev->urbs.lock, flags); + spin_unlock_irqrestore(&dlfb->urbs.lock, flags); unode = list_entry(node, struct urb_node, entry); urb = unode->urb; /* Free each separately allocated piece */ - usb_free_coherent(urb->dev, dev->urbs.size, + usb_free_coherent(urb->dev, dlfb->urbs.size, urb->transfer_buffer, urb->transfer_dma); usb_free_urb(urb); kfree(node); } - dev->urbs.count = 0; + dlfb->urbs.count = 0; } -static int dlfb_alloc_urb_list(struct dlfb_data *dev, int count, size_t size) +static int dlfb_alloc_urb_list(struct dlfb_data *dlfb, int count, size_t size) { int i = 0; struct urb *urb; struct urb_node *unode; char *buf; - spin_lock_init(&dev->urbs.lock); + spin_lock_init(&dlfb->urbs.lock); - dev->urbs.size = size; - INIT_LIST_HEAD(&dev->urbs.list); + dlfb->urbs.size = size; + INIT_LIST_HEAD(&dlfb->urbs.list); while (i < count) { unode = kzalloc(sizeof(*unode), GFP_KERNEL); if (!unode) break; - unode->dev = dev; + unode->dlfb = dlfb; INIT_DELAYED_WORK(&unode->release_urb_work, dlfb_release_urb_work); @@ -1867,7 +1867,7 @@ static int dlfb_alloc_urb_list(struct dlfb_data *dev, int count, size_t size) } unode->urb = urb; - buf = usb_alloc_coherent(dev->udev, MAX_TRANSFER, GFP_KERNEL, + buf = usb_alloc_coherent(dlfb->udev, MAX_TRANSFER, GFP_KERNEL, &urb->transfer_dma); if (!buf) { kfree(unode); @@ -1876,23 +1876,23 @@ static int dlfb_alloc_urb_list(struct dlfb_data *dev, int count, size_t size) } /* urb->transfer_buffer_length set to actual before submit */ - usb_fill_bulk_urb(urb, dev->udev, usb_sndbulkpipe(dev->udev, 1), + usb_fill_bulk_urb(urb, dlfb->udev, usb_sndbulkpipe(dlfb->udev, 1), buf, size, dlfb_urb_completion, unode); urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - list_add_tail(&unode->entry, &dev->urbs.list); + list_add_tail(&unode->entry, &dlfb->urbs.list); i++; } - sema_init(&dev->urbs.limit_sem, i); - dev->urbs.count = i; - dev->urbs.available = i; + sema_init(&dlfb->urbs.limit_sem, i); + dlfb->urbs.count = i; + dlfb->urbs.available = i; return i; } -static struct urb *dlfb_get_urb(struct dlfb_data *dev) +static struct urb *dlfb_get_urb(struct dlfb_data *dlfb) { int ret; struct list_head *entry; @@ -1900,38 +1900,38 @@ static struct urb *dlfb_get_urb(struct dlfb_data *dev) unsigned long flags; /* Wait for an in-flight buffer to complete and get re-queued */ - ret = down_timeout(&dev->urbs.limit_sem, GET_URB_TIMEOUT); + ret = down_timeout(&dlfb->urbs.limit_sem, GET_URB_TIMEOUT); if (ret) { - atomic_set(&dev->lost_pixels, 1); + atomic_set(&dlfb->lost_pixels, 1); pr_warn("wait for urb interrupted: %x available: %d\n", - ret, dev->urbs.available); + ret, dlfb->urbs.available); return NULL; } - spin_lock_irqsave(&dev->urbs.lock, flags); + spin_lock_irqsave(&dlfb->urbs.lock, flags); - BUG_ON(list_empty(&dev->urbs.list)); /* reserved one with limit_sem */ - entry = dev->urbs.list.next; + BUG_ON(list_empty(&dlfb->urbs.list)); /* reserved one with limit_sem */ + entry = dlfb->urbs.list.next; list_del_init(entry); - dev->urbs.available--; + dlfb->urbs.available--; - spin_unlock_irqrestore(&dev->urbs.lock, flags); + spin_unlock_irqrestore(&dlfb->urbs.lock, flags); unode = list_entry(entry, struct urb_node, entry); return unode->urb; } -static int dlfb_submit_urb(struct dlfb_data *dev, struct urb *urb, size_t len) +static int dlfb_submit_urb(struct dlfb_data *dlfb, struct urb *urb, size_t len) { int ret; - BUG_ON(len > dev->urbs.size); + BUG_ON(len > dlfb->urbs.size); urb->transfer_buffer_length = len; /* set to actual payload len */ ret = usb_submit_urb(urb, GFP_KERNEL); if (ret) { dlfb_urb_completion(urb); /* because no one else will */ - atomic_set(&dev->lost_pixels, 1); + atomic_set(&dlfb->lost_pixels, 1); pr_err("usb_submit_urb error %x\n", ret); } return ret; diff --git a/include/video/udlfb.h b/include/video/udlfb.h index 7b4f567dd1fe..0cabe6b09095 100644 --- a/include/video/udlfb.h +++ b/include/video/udlfb.h @@ -19,7 +19,7 @@ struct dloarea { struct urb_node { struct list_head entry; - struct dlfb_data *dev; + struct dlfb_data *dlfb; struct delayed_work release_urb_work; struct urb *urb; }; -- cgit v1.2.3 From 91ae3396ed48940b8f87c01260d9af734c67a5fd Mon Sep 17 00:00:00 2001 From: Michael Trimarchi Date: Mon, 15 Jan 2018 17:04:22 +0100 Subject: fbdev: mxsfb: use framebuffer_alloc in the correct way framebuffer_alloc allocated the fb_info struct plus the extra par and set fb_info->par pointer equal to this extra par. We can refer the mxcfb_info from fb_info->par Signed-off-by: Michael Trimarchi Reviewed-by: Stefan Agner Tested-by: Stefan Agner Cc: Shawn Guo Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/mxsfb.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c index 79b1dc7f042b..246bea3a7d9b 100644 --- a/drivers/video/fbdev/mxsfb.c +++ b/drivers/video/fbdev/mxsfb.c @@ -169,7 +169,6 @@ struct mxsfb_devdata { }; struct mxsfb_info { - struct fb_info fb_info; struct platform_device *pdev; struct clk *clk; struct clk *clk_axi; @@ -208,8 +207,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = { }, }; -#define to_imxfb_host(x) (container_of(x, struct mxsfb_info, fb_info)) - /* mask and shift depends on architecture */ static inline u32 set_hsync_pulse_width(struct mxsfb_info *host, unsigned val) { @@ -269,7 +266,7 @@ static inline unsigned chan_to_field(unsigned chan, struct fb_bitfield *bf) static int mxsfb_check_var(struct fb_var_screeninfo *var, struct fb_info *fb_info) { - struct mxsfb_info *host = to_imxfb_host(fb_info); + struct mxsfb_info *host = fb_info->par; const struct fb_bitfield *rgb = NULL; if (var->xres < MIN_XRES) @@ -330,7 +327,7 @@ static inline void mxsfb_disable_axi_clk(struct mxsfb_info *host) static void mxsfb_enable_controller(struct fb_info *fb_info) { - struct mxsfb_info *host = to_imxfb_host(fb_info); + struct mxsfb_info *host = fb_info->par; u32 reg; int ret; @@ -367,7 +364,7 @@ static void mxsfb_enable_controller(struct fb_info *fb_info) static void mxsfb_disable_controller(struct fb_info *fb_info) { - struct mxsfb_info *host = to_imxfb_host(fb_info); + struct mxsfb_info *host = fb_info->par; unsigned loop; u32 reg; int ret; @@ -409,7 +406,7 @@ static void mxsfb_disable_controller(struct fb_info *fb_info) static int mxsfb_set_par(struct fb_info *fb_info) { - struct mxsfb_info *host = to_imxfb_host(fb_info); + struct mxsfb_info *host = fb_info->par; u32 ctrl, vdctrl0, vdctrl4; int line_size, fb_size; int reenable = 0; @@ -569,7 +566,7 @@ static int mxsfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, static int mxsfb_blank(int blank, struct fb_info *fb_info) { - struct mxsfb_info *host = to_imxfb_host(fb_info); + struct mxsfb_info *host = fb_info->par; switch (blank) { case FB_BLANK_POWERDOWN: @@ -591,7 +588,7 @@ static int mxsfb_blank(int blank, struct fb_info *fb_info) static int mxsfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fb_info) { - struct mxsfb_info *host = to_imxfb_host(fb_info); + struct mxsfb_info *host = fb_info->par; unsigned offset; if (var->xoffset != 0) @@ -622,10 +619,10 @@ static struct fb_ops mxsfb_ops = { .fb_imageblit = cfb_imageblit, }; -static int mxsfb_restore_mode(struct mxsfb_info *host, +static int mxsfb_restore_mode(struct fb_info *fb_info, struct fb_videomode *vmode) { - struct fb_info *fb_info = &host->fb_info; + struct mxsfb_info *host = fb_info->par; unsigned line_count; unsigned period; unsigned long pa, fbsize; @@ -726,10 +723,10 @@ err: return ret; } -static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host, +static int mxsfb_init_fbinfo_dt(struct fb_info *fb_info, struct fb_videomode *vmode) { - struct fb_info *fb_info = &host->fb_info; + struct mxsfb_info *host = fb_info->par; struct fb_var_screeninfo *var = &fb_info->var; struct device *dev = &host->pdev->dev; struct device_node *np = host->pdev->dev.of_node; @@ -805,12 +802,12 @@ put_display_node: return ret; } -static int mxsfb_init_fbinfo(struct mxsfb_info *host, +static int mxsfb_init_fbinfo(struct fb_info *fb_info, struct fb_videomode *vmode) { int ret; + struct mxsfb_info *host = fb_info->par; struct device *dev = &host->pdev->dev; - struct fb_info *fb_info = &host->fb_info; struct fb_var_screeninfo *var = &fb_info->var; dma_addr_t fb_phys; void *fb_virt; @@ -824,7 +821,7 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host, fb_info->fix.visual = FB_VISUAL_TRUECOLOR, fb_info->fix.accel = FB_ACCEL_NONE; - ret = mxsfb_init_fbinfo_dt(host, vmode); + ret = mxsfb_init_fbinfo_dt(fb_info, vmode); if (ret) return ret; @@ -843,16 +840,16 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host, fb_info->screen_base = fb_virt; fb_info->screen_size = fb_info->fix.smem_len = fb_size; - if (mxsfb_restore_mode(host, vmode)) + if (mxsfb_restore_mode(fb_info, vmode)) memset(fb_virt, 0, fb_size); return 0; } -static void mxsfb_free_videomem(struct mxsfb_info *host) +static void mxsfb_free_videomem(struct fb_info *fb_info) { + struct mxsfb_info *host = fb_info->par; struct device *dev = &host->pdev->dev; - struct fb_info *fb_info = &host->fb_info; dma_free_wc(dev, fb_info->screen_size, fb_info->screen_base, fb_info->fix.smem_start); @@ -902,7 +899,7 @@ static int mxsfb_probe(struct platform_device *pdev) if (mode == NULL) return -ENOMEM; - host = to_imxfb_host(fb_info); + host = fb_info->par; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); host->base = devm_ioremap_resource(&pdev->dev, res); @@ -941,7 +938,7 @@ static int mxsfb_probe(struct platform_device *pdev) goto fb_release; } - ret = mxsfb_init_fbinfo(host, mode); + ret = mxsfb_init_fbinfo(fb_info, mode); if (ret != 0) goto fb_release; @@ -982,13 +979,13 @@ fb_release: static int mxsfb_remove(struct platform_device *pdev) { struct fb_info *fb_info = platform_get_drvdata(pdev); - struct mxsfb_info *host = to_imxfb_host(fb_info); + struct mxsfb_info *host = fb_info->par; if (host->enabled) mxsfb_disable_controller(fb_info); unregister_framebuffer(fb_info); - mxsfb_free_videomem(host); + mxsfb_free_videomem(fb_info); framebuffer_release(fb_info); @@ -998,7 +995,7 @@ static int mxsfb_remove(struct platform_device *pdev) static void mxsfb_shutdown(struct platform_device *pdev) { struct fb_info *fb_info = platform_get_drvdata(pdev); - struct mxsfb_info *host = to_imxfb_host(fb_info); + struct mxsfb_info *host = fb_info->par; mxsfb_enable_axi_clk(host); -- cgit v1.2.3 From 724ba8b30b044aa0d94b1cd374fc15806cdd6f18 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Mon, 15 Jan 2018 17:04:22 +0100 Subject: console/dummy: leave .con_font_get set to NULL When this method is set, the caller expects struct console_font fields to be properly initialized when it returns. Leave it unset otherwise nonsensical (leaked kernel stack) values are returned to user space. Signed-off-by: Nicolas Pitre Cc: stable@vger.kernel.org Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/console/dummycon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index 9269d5685239..b90ef96e43d6 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -67,7 +67,6 @@ const struct consw dummy_con = { .con_switch = DUMMY, .con_blank = DUMMY, .con_font_set = DUMMY, - .con_font_get = DUMMY, .con_font_default = DUMMY, .con_font_copy = DUMMY, }; -- cgit v1.2.3 From c1530ac5a3ce93a1f02adabc4508b5fbf862dfe2 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 15 Jan 2018 17:04:22 +0100 Subject: video: fbdev/mmp: add MODULE_LICENSE Kbuild complains about the lack of a license tag in this driver: WARNING: modpost: missing MODULE_LICENSE() in drivers/video/fbdev/mmp/mmp_disp.o This adds the license, author and description tags. Signed-off-by: Arnd Bergmann Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/video/fbdev/mmp/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/video/fbdev/mmp/core.c b/drivers/video/fbdev/mmp/core.c index a0f496049db7..3a6bb6561ba0 100644 --- a/drivers/video/fbdev/mmp/core.c +++ b/drivers/video/fbdev/mmp/core.c @@ -23,6 +23,7 @@ #include #include #include +#include #include