From 6080a89357cc46f3450839a84af75c3d18f57772 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 15 Jan 2015 13:47:19 +0200 Subject: fbdev: fix cea_modes array size CEA defines 64 modes, indexed from 1 to 64. modedb has cea_modes arrays, which contains 64 entries. However, the code uses the CEA indices directly, i.e. the first mode is at cea_modes[1]. This means the array is one too short. This does not cause references to uninitialized memory as the code in fbmon only allows indexes up to 63, and the cea_modes does not contain an entry for the mode 64 so it could not be used in any case. However, the code contains a check 'if (idx > ARRAY_SIZE(cea_modes)', and while that check is a no-op as at that point idx cannot be >= 63, it upsets static checkers. Fix this by increasing the cea_array size to be 65, and change the code to allow mode 64. Signed-off-by: Tomi Valkeinen Reported-by: Dan Carpenter --- drivers/video/fbdev/core/fbmon.c | 4 ++-- drivers/video/fbdev/core/modedb.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c index d787533d9c8b..47c3191ec313 100644 --- a/drivers/video/fbdev/core/fbmon.c +++ b/drivers/video/fbdev/core/fbmon.c @@ -1072,9 +1072,9 @@ void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs) for (i = specs->modedb_len + num; i < specs->modedb_len + num + svd_n; i++) { int idx = svd[i - specs->modedb_len - num]; - if (!idx || idx > 63) { + if (!idx || idx >= ARRAY_SIZE(cea_modes)) { pr_warning("Reserved SVD code %d\n", idx); - } else if (idx > ARRAY_SIZE(cea_modes) || !cea_modes[idx].xres) { + } else if (!cea_modes[idx].xres) { pr_warning("Unimplemented SVD code %d\n", idx); } else { memcpy(&m[i], cea_modes + idx, sizeof(m[i])); diff --git a/drivers/video/fbdev/core/modedb.c b/drivers/video/fbdev/core/modedb.c index 7d07cf824b64..2510fa728d77 100644 --- a/drivers/video/fbdev/core/modedb.c +++ b/drivers/video/fbdev/core/modedb.c @@ -289,7 +289,7 @@ static const struct fb_videomode modedb[] = { }; #ifdef CONFIG_FB_MODE_HELPERS -const struct fb_videomode cea_modes[64] = { +const struct fb_videomode cea_modes[65] = { /* #1: 640x480p@59.94/60Hz */ [1] = { NULL, 60, 640, 480, 39722, 48, 16, 33, 10, 96, 2, 0, -- cgit v1.2.3-55-g7522 From 71540cfbe9d401f4848abc0e6b56a541307a47dd Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 2 Aug 2015 11:09:53 +0200 Subject: fbdev: Allow compile test of GPIO consumers if !GPIOLIB The GPIO subsystem provides dummy GPIO consumer functions if GPIOLIB is not enabled. Hence drivers that depend on GPIOLIB, but use GPIO consumer functionality only, can still be compiled if GPIOLIB is not enabled. Relax the dependency on GPIOLIB if COMPILE_TEST is enabled, where appropriate. Signed-off-by: Geert Uytterhoeven Acked-by: Linus Walleij Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index f888561568d9..11ac660ac0bc 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -2464,7 +2464,7 @@ config FB_SSD1307 tristate "Solomon SSD1307 framebuffer support" depends on FB && I2C depends on OF - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST select FB_SYS_FOPS select FB_SYS_FILLRECT select FB_SYS_COPYAREA -- cgit v1.2.3-55-g7522 From f63cb8d7aa31e7a8f98cec36557b265951e9aba7 Mon Sep 17 00:00:00 2001 From: Alexey Klimov Date: Mon, 8 Jun 2015 02:02:47 +0300 Subject: fbdev: udlfb: remove unneeded initialization in few places Small minor cleanup. This patch removes unneeded initializations of variables in few places in different functions and one empty line. Signed-off-by: Alexey Klimov Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/udlfb.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index ff2b8731a2dc..e9c2f7ba3c8e 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -279,7 +279,7 @@ static int dlfb_set_video_mode(struct dlfb_data *dev, { char *buf; char *wrptr; - int retval = 0; + int retval; int writesize; struct urb *urb; @@ -1505,8 +1505,7 @@ static int dlfb_parse_vendor_descriptor(struct dlfb_data *dev, char *desc; char *buf; char *desc_end; - - int total_len = 0; + int total_len; buf = kzalloc(MAX_VENDOR_DESCRIPTOR_SIZE, GFP_KERNEL); if (!buf) @@ -1582,7 +1581,7 @@ static int dlfb_usb_probe(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_device *usbdev; - struct dlfb_data *dev = NULL; + struct dlfb_data *dev; int retval = -ENOMEM; /* usb initialization */ @@ -1665,7 +1664,6 @@ static void dlfb_init_framebuffer_work(struct work_struct *work) /* allocates framebuffer driver structure, not framebuffer memory */ info = framebuffer_alloc(0, dev->gdev); if (!info) { - retval = -ENOMEM; pr_err("framebuffer_alloc failed\n"); goto error; } @@ -1912,7 +1910,7 @@ static int dlfb_alloc_urb_list(struct dlfb_data *dev, int count, size_t size) static struct urb *dlfb_get_urb(struct dlfb_data *dev) { - int ret = 0; + int ret; struct list_head *entry; struct urb_node *unode; struct urb *urb = NULL; -- cgit v1.2.3-55-g7522 From 48fd8ecf29e3c1199432e173858f5ca4bc529738 Mon Sep 17 00:00:00 2001 From: Nicolai Stange Date: Wed, 17 Jun 2015 21:40:33 +0200 Subject: framebuffer: disable vgacon on microblaze arch Fix an allmodconfig link failer on microblaze: drivers/built-in.o: In function `vgacon_save_screen': drivers/video/console/.tmp_vgacon.o:(.text+0x8fc10): undefined reference to `screen_info' Disable vgacon on microblaze because the symbol struct screen_info screen_info; is not defined for the microblaze arch. Signed-off-by: Nicolai Stange Signed-off-by: Tomi Valkeinen --- drivers/video/console/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/video') diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index ba97efc3bf70..e0dc0fee4ea6 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig @@ -9,7 +9,7 @@ config VGA_CONSOLE depends on !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && \ !SUPERH && !BLACKFIN && !AVR32 && !MN10300 && !CRIS && \ (!ARM || ARCH_FOOTBRIDGE || ARCH_INTEGRATOR || ARCH_NETWINDER) && \ - !ARM64 + !ARM64 && !MICROBLAZE default y help Saying Y here will allow you to use Linux in text mode through a -- cgit v1.2.3-55-g7522 From c0a3229313d6931a77e0c1e1c22e398c0312bf6f Mon Sep 17 00:00:00 2001 From: Marcin Chojnacki Date: Thu, 18 Jun 2015 15:01:52 +0200 Subject: fbdev: remove unnecessary memset in vfb In vfb_probe memory is allocated using rvmalloc which automatically sets the allocated memory to zero. This patch removes the second unnecessary memset in vfb_probe. Signed-off-by: Marcin Chojnacki Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/vfb.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c index 70a897b1e458..b9c2f81fb6b9 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -51,7 +51,14 @@ static void *rvmalloc(unsigned long size) if (!mem) return NULL; - memset(mem, 0, size); /* Clear the ram out, no junk to the user */ + /* + * VFB must clear memory to prevent kernel info + * leakage into userspace + * VGA-based drivers MUST NOT clear memory if + * they want to be able to take over vgacon + */ + + memset(mem, 0, size); adr = (unsigned long) mem; while (size > 0) { SetPageReserved(vmalloc_to_page((void *)adr)); @@ -490,14 +497,6 @@ static int vfb_probe(struct platform_device *dev) if (!(videomemory = rvmalloc(videomemorysize))) return retval; - /* - * VFB must clear memory to prevent kernel info - * leakage into userspace - * VGA-based drivers MUST NOT clear memory if - * they want to be able to take over vgacon - */ - memset(videomemory, 0, videomemorysize); - info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev); if (!info) goto err; -- cgit v1.2.3-55-g7522 From 2e8bcf4d40d8ec720372df5c591f0151f8ffe946 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 10 Jul 2015 15:37:29 +0900 Subject: video: fbdev: Drop owner assignment from i2c_driver i2c_driver does not need to set an owner because i2c_register_driver() will set it. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/ssd1307fb.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 3e153c06131a..b6edd28b267f 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -719,7 +719,6 @@ static struct i2c_driver ssd1307fb_driver = { .driver = { .name = "ssd1307fb", .of_match_table = ssd1307fb_of_match, - .owner = THIS_MODULE, }, }; -- cgit v1.2.3-55-g7522 From c4a2f5beb7fe3cf4e33ed79040d699fd6c17083f Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 10 Jul 2015 15:37:30 +0900 Subject: video: fbdev: Drop owner assignment from platform_driver platform_driver does not need to set an owner because platform_driver_register() will set it. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/omap2/displays-new/encoder-opa362.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c b/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c index a14d993f719d..8c246c213e06 100644 --- a/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c +++ b/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c @@ -266,7 +266,6 @@ static struct platform_driver opa362_driver = { .remove = __exit_p(opa362_remove), .driver = { .name = "amplifier-opa362", - .owner = THIS_MODULE, .of_match_table = opa362_of_match, .suppress_bind_attrs = true, }, -- cgit v1.2.3-55-g7522 From cb73b40e59f0f62099bfb8a836697a74dc151395 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 20 Aug 2015 13:46:10 +0300 Subject: video: fbdev: atmel: fix warning for const return value A const on a return value is meaningless and generates a warning on some versions of gcc: drivers/video/fbdev/atmel_lcdfb.c:1003: warning: type qualifiers ignored on function return type The function in question is only used inside the .c file, so the author of the code most likely means "static" instead of "const". Change the const to static. Reported-by: Fengguang Wu Cc: Nicolas Ferre Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/atmel_lcdfb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c index abadc490fa1f..016cae1425a4 100644 --- a/drivers/video/fbdev/atmel_lcdfb.c +++ b/drivers/video/fbdev/atmel_lcdfb.c @@ -999,7 +999,7 @@ static const char *atmel_lcdfb_wiring_modes[] = { [ATMEL_LCDC_WIRING_RGB] = "RGB", }; -const int atmel_lcdfb_get_of_wiring_modes(struct device_node *np) +static int atmel_lcdfb_get_of_wiring_modes(struct device_node *np) { const char *mode; int err, i; -- cgit v1.2.3-55-g7522 From b06ece93cf96b430587e77e01053b2b8f99cb750 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Tue, 7 Jul 2015 22:00:47 +0900 Subject: video: fbdev: s3c-fb: Constify platform_device_id The platform_device_id is not modified by the driver and core uses it as const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/s3c-fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/s3c-fb.c b/drivers/video/fbdev/s3c-fb.c index 7e3a05fc47aa..f72dd12456f9 100644 --- a/drivers/video/fbdev/s3c-fb.c +++ b/drivers/video/fbdev/s3c-fb.c @@ -1938,7 +1938,7 @@ static struct s3c_fb_driverdata s3c_fb_data_s3c2443 = { }, }; -static struct platform_device_id s3c_fb_driver_ids[] = { +static const struct platform_device_id s3c_fb_driver_ids[] = { { .name = "s3c-fb", .driver_data = (unsigned long)&s3c_fb_data_64xx, -- cgit v1.2.3-55-g7522 From b4df20474ff76b4dbab7d991de271820383995b8 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 24 Aug 2015 22:54:21 +0300 Subject: fbdev: fix snprintf() limit in show_bl_curve() The limit should be "PAGE_SIZE - len" instead of PAGE_SIZE. Also let's use scnprintf() because snprintf() returns the number of bytes which would have been printed if there were space and scnprintf() returns the number of bytes actually printed. I don't think we are ever going to actually hit this limit in real life. Signed-off-by: Dan Carpenter Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/core/fbsysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c index 60c3f0a16341..15755ce1d26c 100644 --- a/drivers/video/fbdev/core/fbsysfs.c +++ b/drivers/video/fbdev/core/fbsysfs.c @@ -485,7 +485,7 @@ static ssize_t show_bl_curve(struct device *device, mutex_lock(&fb_info->bl_curve_mutex); for (i = 0; i < FB_BACKLIGHT_LEVELS; i += 8) - len += snprintf(&buf[len], PAGE_SIZE, "%8ph\n", + len += scnprintf(&buf[len], PAGE_SIZE - len, "%8ph\n", fb_info->bl_curve + i); mutex_unlock(&fb_info->bl_curve_mutex); -- cgit v1.2.3-55-g7522 From c4e6774de19f4638bb887a47a58ee21d6809360b Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 23 Aug 2015 02:11:15 +0200 Subject: fbdev: ssd1307fb: fix error return code Propagate error code on failure. Also changed %ld to %d in dev_err to use ret variable rather than putting two calls to PTR_ERR. A simplified version of the semantic match that finds the first problem is as follows: (http://coccinelle.lip6.fr/) // @@ identifier ret; expression e1,e2; @@ ( if (\(ret < 0\|ret != 0\)) { ... return ret; } | ret = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // Signed-off-by: Julia Lawall Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/ssd1307fb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index b6edd28b267f..93f4c902d0f9 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -656,8 +656,9 @@ static int ssd1307fb_probe(struct i2c_client *client, bl = backlight_device_register(bl_name, &client->dev, par, &ssd1307fb_bl_ops, NULL); if (IS_ERR(bl)) { - dev_err(&client->dev, "unable to register backlight device: %ld\n", - PTR_ERR(bl)); + ret = PTR_ERR(bl); + dev_err(&client->dev, "unable to register backlight device: %d\n", + ret); goto bl_init_error; } -- cgit v1.2.3-55-g7522 From 7b554088d56e9df3ee5dff8989b44903965bad95 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Tue, 18 Aug 2015 08:58:40 +0530 Subject: video: fbdev: pxa168fb: Use devm_clk_get This patch introduces the use of managed resource function devm_clk_get instead of clk_get and removes corresponding calls to clk_put in the probe and remove functions. To be compatible with the change various gotos are replaced with direct returns, and unneeded label failed_put_clk is dropped. Signed-off-by: Vaishali Thakkar Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/pxa168fb.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/pxa168fb.c b/drivers/video/fbdev/pxa168fb.c index e209b039f553..efb57c059997 100644 --- a/drivers/video/fbdev/pxa168fb.c +++ b/drivers/video/fbdev/pxa168fb.c @@ -615,7 +615,7 @@ static int pxa168fb_probe(struct platform_device *pdev) return -EINVAL; } - clk = clk_get(&pdev->dev, "LCDCLK"); + clk = devm_clk_get(&pdev->dev, "LCDCLK"); if (IS_ERR(clk)) { dev_err(&pdev->dev, "unable to get LCDCLK"); return PTR_ERR(clk); @@ -624,21 +624,18 @@ static int pxa168fb_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "no IO memory defined\n"); - ret = -ENOENT; - goto failed_put_clk; + return -ENOENT; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "no IRQ defined\n"); - ret = -ENOENT; - goto failed_put_clk; + return -ENOENT; } info = framebuffer_alloc(sizeof(struct pxa168fb_info), &pdev->dev); if (info == NULL) { - ret = -ENOMEM; - goto failed_put_clk; + return -ENOMEM; } /* Initialize private data */ @@ -776,8 +773,6 @@ failed_free_fbmem: info->screen_base, fbi->fb_start_dma); failed_free_info: kfree(info); -failed_put_clk: - clk_put(clk); dev_err(&pdev->dev, "frame buffer device init failed with %d\n", ret); return ret; @@ -813,7 +808,6 @@ static int pxa168fb_remove(struct platform_device *pdev) info->screen_base, info->fix.smem_start); clk_disable(fbi->clk); - clk_put(fbi->clk); framebuffer_release(info); -- cgit v1.2.3-55-g7522 From 57817e619a215588739f3f644986c78b586b541b Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Mon, 10 Aug 2015 16:31:54 +0200 Subject: video: fbdev: atmel_lcdfb: remove useless include Definitions from linux/platform_data/atmel.h are not used, remove the include. Signed-off-by: Alexandre Belloni Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/atmel_lcdfb.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/video') diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c index 016cae1425a4..19eb42b57d87 100644 --- a/drivers/video/fbdev/atmel_lcdfb.c +++ b/drivers/video/fbdev/atmel_lcdfb.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3-55-g7522