From 0cd129de3ee7be794ed1136fc0ea60f0e696d10e Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sun, 9 Jan 2022 22:37:19 +0000 Subject: [PATCH 01/59] video: fbdev: aty128fb: make some arrays static const Don't populate some read-only arrays on the stack but instead make them static const. Also makes the object code a little smaller. Re-format one of the declarations. Add spaces between commas and make PostDivSet unsigned int to fixup checkpatch warnings. Signed-off-by: Colin Ian King Signed-off-by: Helge Deller --- drivers/video/fbdev/aty/aty128fb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c index e6a48689c29493..6ff16d3132e5f1 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -952,7 +952,7 @@ static void aty128_timings(struct aty128fb_par *par) u32 x_mpll_ref_fb_div; u32 xclk_cntl; u32 Nx, M; - unsigned PostDivSet[] = { 0, 1, 2, 4, 8, 3, 6, 12 }; + static const unsigned int PostDivSet[] = { 0, 1, 2, 4, 8, 3, 6, 12 }; #endif if (!par->constants.ref_clk) @@ -1321,8 +1321,10 @@ static void aty128_set_pll(struct aty128_pll *pll, { u32 div3; - unsigned char post_conv[] = /* register values for post dividers */ - { 2, 0, 1, 4, 2, 2, 6, 2, 3, 2, 2, 2, 7 }; + /* register values for post dividers */ + static const unsigned char post_conv[] = { + 2, 0, 1, 4, 2, 2, 6, 2, 3, 2, 2, 2, 7 + }; /* select PPLL_DIV_3 */ aty_st_le32(CLOCK_CNTL_INDEX, aty_ld_le32(CLOCK_CNTL_INDEX) | (3 << 8)); @@ -1360,7 +1362,7 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll, const struct aty128fb_par *par) { const struct aty128_constants c = par->constants; - unsigned char post_dividers[] = {1,2,4,8,3,6,12}; + static const unsigned char post_dividers[] = { 1, 2, 4, 8, 3, 6, 12 }; u32 output_freq; u32 vclk; /* in .01 MHz */ int i = 0; From 9d54c5d47406588f7bae9b72bd9f922b33434327 Mon Sep 17 00:00:00 2001 From: Jiasheng Jiang Date: Mon, 20 Dec 2021 16:11:32 +0800 Subject: [PATCH 02/59] video: fbdev: imxfb: Check for null res pointer The return value of platform_get_resource() needs to be checked. To avoid use of error pointer in case that there is no suitable resource. Signed-off-by: Jiasheng Jiang Signed-off-by: Helge Deller --- drivers/video/fbdev/imxfb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c index ad598257ab3867..68288756ffff37 100644 --- a/drivers/video/fbdev/imxfb.c +++ b/drivers/video/fbdev/imxfb.c @@ -1083,6 +1083,8 @@ static int imxfb_remove(struct platform_device *pdev) struct resource *res; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; imxfb_disable_controller(fbi); From adc122011125682932ef279d717153670feedde4 Mon Sep 17 00:00:00 2001 From: Xu Wang Date: Thu, 13 Jan 2022 08:48:06 +0000 Subject: [PATCH 03/59] backlight: lm3630a_bl: Remove redundant 'flush_workqueue()' calls 'destroy_workqueue()' already drains the queue before destroying it, so there is no need to flush it explicitly. Remove the redundant 'flush_workqueue()' calls. Signed-off-by: Xu Wang Reviewed-by: Daniel Thompson Signed-off-by: Helge Deller --- drivers/video/backlight/lm3630a_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index e8b185bb6f5ee1..1d17c439430ef7 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -594,7 +594,6 @@ static int lm3630a_remove(struct i2c_client *client) if (pchip->irq) { free_irq(pchip->irq, pchip); - flush_workqueue(pchip->irqthread); destroy_workqueue(pchip->irqthread); } return 0; From 1ce48d67dc20d215aa55af244eb0773361e025ab Mon Sep 17 00:00:00 2001 From: Xu Wang Date: Thu, 13 Jan 2022 07:39:28 +0000 Subject: [PATCH 04/59] video: fbdev: omapfb: Remove redundant 'flush_workqueue()' calls 'destroy_workqueue()' already drains the queue before destroying it, so there is no need to flush it explicitly. Remove the redundant 'flush_workqueue()' calls. Signed-off-by: Xu Wang Signed-off-by: Helge Deller --- drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c index a3decc7fadde3b..afa688e754b959 100644 --- a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c +++ b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c @@ -1854,7 +1854,6 @@ static void omapfb_free_resources(struct omapfb2_device *fbdev) } if (fbdev->auto_update_wq != NULL) { - flush_workqueue(fbdev->auto_update_wq); destroy_workqueue(fbdev->auto_update_wq); fbdev->auto_update_wq = NULL; } From 19d10a8333dcaaa824df27dbb35654359fb9d972 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 6 Jan 2022 10:49:06 +0100 Subject: [PATCH 05/59] video: fbdev: omapfb: use default_groups in kobj_type There are currently 2 ways to create a set of sysfs files for a kobj_type, through the default_attrs field, and the default_groups field. Move the omapfb sysfs code to use default_groups field which has been the preferred way since aa30f47cf666 ("kobject: Add support for default attribute groups to kobj_type") so that we can soon get rid of the obsolete default_attrs field. Cc: linux-omap@vger.kernel.org Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Helge Deller --- drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c | 3 ++- drivers/video/fbdev/omap2/omapfb/dss/manager-sysfs.c | 3 ++- drivers/video/fbdev/omap2/omapfb/dss/overlay-sysfs.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c index 8f355d1caf8648..bc5a44c2a144ab 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c @@ -265,6 +265,7 @@ static struct attribute *display_sysfs_attrs[] = { &display_attr_wss.attr, NULL }; +ATTRIBUTE_GROUPS(display_sysfs); static ssize_t display_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -303,7 +304,7 @@ static const struct sysfs_ops display_sysfs_ops = { static struct kobj_type display_ktype = { .sysfs_ops = &display_sysfs_ops, - .default_attrs = display_sysfs_attrs, + .default_groups = display_sysfs_groups, }; int display_init_sysfs(struct platform_device *pdev) diff --git a/drivers/video/fbdev/omap2/omapfb/dss/manager-sysfs.c b/drivers/video/fbdev/omap2/omapfb/dss/manager-sysfs.c index 3ffb1fe4a38a6e..ba21c4a2633dd0 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/manager-sysfs.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/manager-sysfs.c @@ -457,6 +457,7 @@ static struct attribute *manager_sysfs_attrs[] = { &manager_attr_cpr_coef.attr, NULL }; +ATTRIBUTE_GROUPS(manager_sysfs); static ssize_t manager_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -495,7 +496,7 @@ static const struct sysfs_ops manager_sysfs_ops = { static struct kobj_type manager_ktype = { .sysfs_ops = &manager_sysfs_ops, - .default_attrs = manager_sysfs_attrs, + .default_groups = manager_sysfs_groups, }; int dss_manager_kobj_init(struct omap_overlay_manager *mgr, diff --git a/drivers/video/fbdev/omap2/omapfb/dss/overlay-sysfs.c b/drivers/video/fbdev/omap2/omapfb/dss/overlay-sysfs.c index 421dcb7564adcd..601c0beb6de969 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/overlay-sysfs.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/overlay-sysfs.c @@ -390,6 +390,7 @@ static struct attribute *overlay_sysfs_attrs[] = { &overlay_attr_zorder.attr, NULL }; +ATTRIBUTE_GROUPS(overlay_sysfs); static ssize_t overlay_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -428,7 +429,7 @@ static const struct sysfs_ops overlay_sysfs_ops = { static struct kobj_type overlay_ktype = { .sysfs_ops = &overlay_sysfs_ops, - .default_attrs = overlay_sysfs_attrs, + .default_groups = overlay_sysfs_groups, }; int dss_overlay_kobj_init(struct omap_overlay *ovl, From 97db79f705055624bb30c147b2d695ca7b6d710e Mon Sep 17 00:00:00 2001 From: Minghao Chi Date: Tue, 4 Jan 2022 10:43:36 +0000 Subject: [PATCH 06/59] video: fbdev: mach64_ct: remove redundant res variable Return value from aty_ld_8() directly instead of taking this in another redundant variable. Reported-by: Zeal Robot Signed-off-by: Minghao Chi Signed-off-by: CGEL ZTE Signed-off-by: Helge Deller --- drivers/video/fbdev/aty/mach64_ct.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/video/fbdev/aty/mach64_ct.c b/drivers/video/fbdev/aty/mach64_ct.c index 011b07e44e0dfe..e967536af16608 100644 --- a/drivers/video/fbdev/aty/mach64_ct.c +++ b/drivers/video/fbdev/aty/mach64_ct.c @@ -22,13 +22,11 @@ static u32 aty_pll_to_var_ct(const struct fb_info *info, const union aty_pll *pl u8 aty_ld_pll_ct(int offset, const struct atyfb_par *par) { - u8 res; /* write addr byte */ aty_st_8(CLOCK_CNTL_ADDR, (offset << 2) & PLL_ADDR, par); /* read the register value */ - res = aty_ld_8(CLOCK_CNTL_DATA, par); - return res; + return aty_ld_8(CLOCK_CNTL_DATA, par); } static void aty_st_pll_ct(int offset, u8 val, const struct atyfb_par *par) From fe4059c3c4c25cad2bb61aa86efb8dd2d56f621d Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Wed, 29 Dec 2021 18:03:56 +0100 Subject: [PATCH 07/59] backlight: qcom-wled: Add PM6150L compatible PM6150L contains WLED of version 5. Add support ofr it to the driver. Signed-off-by: Luca Weiss Reviewed-by: Daniel Thompson Signed-off-by: Helge Deller --- drivers/video/backlight/qcom-wled.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c index 306bcc6ccb927f..527210e8579593 100644 --- a/drivers/video/backlight/qcom-wled.c +++ b/drivers/video/backlight/qcom-wled.c @@ -1734,6 +1734,7 @@ static const struct of_device_id wled_match_table[] = { { .compatible = "qcom,pmi8994-wled", .data = (void *)4 }, { .compatible = "qcom,pmi8998-wled", .data = (void *)4 }, { .compatible = "qcom,pm660l-wled", .data = (void *)4 }, + { .compatible = "qcom,pm6150l-wled", .data = (void *)5 }, { .compatible = "qcom,pm8150l-wled", .data = (void *)5 }, {} }; From dd2909066402006a4256f5a2942fbeed1b73df86 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 21 Dec 2021 00:42:46 +0000 Subject: [PATCH 08/59] video: fbdev: mb862xx: remove redundant assignment to pointer ptr The pointer ptr is being assigned a value that is never read. The pointer is being re-assigned later in a loop. The assignment is redundant and can be removed. Signed-off-by: Colin Ian King Reviewed-by: Geert Uytterhoeven Signed-off-by: Helge Deller --- drivers/video/fbdev/mb862xx/mb862xxfb_accel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c index d40b806461ca5c..61aed7fc0b8d50 100644 --- a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c +++ b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c @@ -132,7 +132,7 @@ static void mb86290fb_imageblit8(u32 *cmd, u16 step, u16 dx, u16 dy, cmd[2] = (height << 16) | width; i = 0; - line = ptr = image->data; + line = image->data; bytes = image->width; while (i < height) { From 62d89a7d49afe46e6b9bbe9e23b004ad848dbde4 Mon Sep 17 00:00:00 2001 From: "Z. Liu" Date: Sun, 19 Dec 2021 02:00:35 +0800 Subject: [PATCH 09/59] video: fbdev: matroxfb: set maxvram of vbG200eW to the same as vbG200 to avoid black screen Start from commit 11be60bd66d54 "matroxfb: add Matrox MGA-G200eW board support", when maxvram is 0x800000, monitor become black w/ error message said: "The current input timing is not supported by the monitor display. Please change your input timing to 1920x1080@60Hz ...". Fixes: 11be60bd66d5 ("matroxfb: add Matrox MGA-G200eW board support") Signed-off-by: Z. Liu Signed-off-by: Helge Deller --- drivers/video/fbdev/matrox/matroxfb_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c index 5c82611e93d995..236521b19daf77 100644 --- a/drivers/video/fbdev/matrox/matroxfb_base.c +++ b/drivers/video/fbdev/matrox/matroxfb_base.c @@ -1377,7 +1377,7 @@ static struct video_board vbG200 = { .lowlevel = &matrox_G100 }; static struct video_board vbG200eW = { - .maxvram = 0x800000, + .maxvram = 0x100000, .maxdisplayable = 0x800000, .accelID = FB_ACCEL_MATROX_MGAG200, .lowlevel = &matrox_G100 From 963e65dbfd352c764be3dcd1683ad205be31b08c Mon Sep 17 00:00:00 2001 From: Yang Guang Date: Sat, 18 Dec 2021 09:56:59 +0800 Subject: [PATCH 10/59] video: fbdev: sis: use swap() to make code cleaner Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid opencoding it. Reported-by: Zeal Robot Signed-off-by: David Yang Signed-off-by: Yang Guang Signed-off-by: Helge Deller --- drivers/video/fbdev/sis/sis_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/sis/sis_main.c b/drivers/video/fbdev/sis/sis_main.c index 266a5582f94d3f..742f62986b80b9 100644 --- a/drivers/video/fbdev/sis/sis_main.c +++ b/drivers/video/fbdev/sis/sis_main.c @@ -213,7 +213,7 @@ static void sisfb_search_mode(char *name, bool quiet) /* This does some fuzzy mode naming detection */ if(sscanf(strbuf1, "%u %u %u %u", &xres, &yres, &depth, &rate) == 4) { if((rate <= 32) || (depth > 32)) { - j = rate; rate = depth; depth = j; + swap(rate, depth); } sprintf(strbuf, "%ux%ux%u", xres, yres, depth); nameptr = strbuf; From 136851694889a532ab17004d4c5f4e55304dc330 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Mon, 13 Dec 2021 09:26:10 +0100 Subject: [PATCH 11/59] dt-bindings: simple-framebuffer: allow standalone compatible Qualcomm platforms use "simple-framebuffer" without a more specific compatible. Allow that in the binding doc. Signed-off-by: Luca Weiss Acked-by: Rob Herring Signed-off-by: Helge Deller --- .../bindings/display/simple-framebuffer.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/display/simple-framebuffer.yaml b/Documentation/devicetree/bindings/display/simple-framebuffer.yaml index 44a29d813f14a5..27ba4323d22135 100644 --- a/Documentation/devicetree/bindings/display/simple-framebuffer.yaml +++ b/Documentation/devicetree/bindings/display/simple-framebuffer.yaml @@ -52,11 +52,13 @@ description: |+ properties: compatible: - items: - - enum: - - apple,simple-framebuffer - - allwinner,simple-framebuffer - - amlogic,simple-framebuffer + oneOf: + - items: + - enum: + - apple,simple-framebuffer + - allwinner,simple-framebuffer + - amlogic,simple-framebuffer + - const: simple-framebuffer - const: simple-framebuffer reg: From 4378aaeef31bfac5eae5a1364f3e27c6314566dd Mon Sep 17 00:00:00 2001 From: Chunyang Zhong Date: Fri, 10 Dec 2021 18:28:16 +0800 Subject: [PATCH 12/59] video: fbdev: ocfb: add const to of_device_id struct of_device_id should normally be const. Signed-off-by: Chunyang Zhong Signed-off-by: Helge Deller --- drivers/video/fbdev/ocfb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/ocfb.c b/drivers/video/fbdev/ocfb.c index bfa4ed42114864..da7e1457e58f21 100644 --- a/drivers/video/fbdev/ocfb.c +++ b/drivers/video/fbdev/ocfb.c @@ -387,7 +387,7 @@ static int ocfb_remove(struct platform_device *pdev) return 0; } -static struct of_device_id ocfb_match[] = { +static const struct of_device_id ocfb_match[] = { { .compatible = "opencores,ocfb", }, {}, }; From 567e44fb51b4f909ae58038a7301352eecea8426 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Thu, 9 Dec 2021 17:01:13 +0800 Subject: [PATCH 13/59] video: fbdev: controlfb: Fix COMPILE_TEST build If PPC_BOOK3S, PPC_PMAC and PPC32 is n, COMPILE_TEST build fails: drivers/video/fbdev/controlfb.c:70:0: error: "pgprot_cached_wthru" redefined [-Werror] #define pgprot_cached_wthru(prot) (prot) In file included from ./arch/powerpc/include/asm/pgtable.h:20:0, from ./include/linux/pgtable.h:6, from ./include/linux/mm.h:33, from drivers/video/fbdev/controlfb.c:37: ./arch/powerpc/include/asm/nohash/pgtable.h:243:0: note: this is the location of the previous definition #define pgprot_cached_wthru(prot) (__pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) | \ Fixes: a07a63b0e24d ("video: fbdev: controlfb: add COMPILE_TEST support") Signed-off-by: YueHaibing Signed-off-by: Helge Deller --- drivers/video/fbdev/controlfb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c index 509311471d515a..bd59e7b11ed530 100644 --- a/drivers/video/fbdev/controlfb.c +++ b/drivers/video/fbdev/controlfb.c @@ -67,7 +67,9 @@ #define out_8(addr, val) (void)(val) #define in_le32(addr) 0 #define out_le32(addr, val) (void)(val) +#ifndef pgprot_cached_wthru #define pgprot_cached_wthru(prot) (prot) +#endif #else static void invalid_vram_cache(void __force *addr) { From 1791f487f877a9e83d81c8677bd3e7b259e7cb27 Mon Sep 17 00:00:00 2001 From: Wang Hai Date: Thu, 14 Oct 2021 21:22:31 +0800 Subject: [PATCH 14/59] video: fbdev: smscufx: Fix null-ptr-deref in ufx_usb_probe() I got a null-ptr-deref report: BUG: kernel NULL pointer dereference, address: 0000000000000000 ... RIP: 0010:fb_destroy_modelist+0x38/0x100 ... Call Trace: ufx_usb_probe.cold+0x2b5/0xac1 [smscufx] usb_probe_interface+0x1aa/0x3c0 [usbcore] really_probe+0x167/0x460 ... ret_from_fork+0x1f/0x30 If fb_alloc_cmap() fails in ufx_usb_probe(), fb_destroy_modelist() will be called to destroy modelist in the error handling path. But modelist has not been initialized yet, so it will result in null-ptr-deref. Initialize modelist before calling fb_alloc_cmap() to fix this bug. Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters") Reported-by: Hulk Robot Signed-off-by: Wang Hai Acked-by: Thomas Zimmermann Signed-off-by: Helge Deller --- drivers/video/fbdev/smscufx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c index bfac3ee4a64228..28768c272b73d3 100644 --- a/drivers/video/fbdev/smscufx.c +++ b/drivers/video/fbdev/smscufx.c @@ -1656,6 +1656,7 @@ static int ufx_usb_probe(struct usb_interface *interface, info->par = dev; info->pseudo_palette = dev->pseudo_palette; info->fbops = &ufx_ops; + INIT_LIST_HEAD(&info->modelist); retval = fb_alloc_cmap(&info->cmap, 256, 0); if (retval < 0) { @@ -1666,8 +1667,6 @@ static int ufx_usb_probe(struct usb_interface *interface, INIT_DELAYED_WORK(&dev->free_framebuffer_work, ufx_free_framebuffer_work); - INIT_LIST_HEAD(&info->modelist); - retval = ufx_reg_read(dev, 0x3000, &id_rev); check_warn_goto_error(retval, "error %d reading 0x3000 register from device", retval); dev_dbg(dev->gdev, "ID_REV register value 0x%08x", id_rev); From 3bfa3f1b611928c34a236e5cf9531051cb3a5276 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 16 Sep 2021 19:04:59 +0200 Subject: [PATCH 15/59] video: fbdev: s3c-fb: drop unneeded MODULE_ALIAS The MODULE_DEVICE_TABLE already creates proper alias for platform driver. Having another MODULE_ALIAS causes the alias to be duplicated. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Helge Deller --- drivers/video/fbdev/s3c-fb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/fbdev/s3c-fb.c b/drivers/video/fbdev/s3c-fb.c index 3b134e1bbc384b..1d88dcd3e26beb 100644 --- a/drivers/video/fbdev/s3c-fb.c +++ b/drivers/video/fbdev/s3c-fb.c @@ -1810,4 +1810,3 @@ module_platform_driver(s3c_fb_driver); MODULE_AUTHOR("Ben Dooks "); MODULE_DESCRIPTION("Samsung S3C SoC Framebuffer driver"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:s3c-fb"); From 1e3c3e6193d45afd5879da5a82b2c92997b0ebe9 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 24 Sep 2021 23:22:22 +0100 Subject: [PATCH 16/59] video: fbdev: via: Fix spelling mistake "bellow" -> "below" There is a spelling mistake in a debug message. Fix it. Signed-off-by: Colin Ian King Signed-off-by: Helge Deller --- drivers/video/fbdev/via/lcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/via/lcd.c b/drivers/video/fbdev/via/lcd.c index 088b962076b51e..beec5c8d4d083d 100644 --- a/drivers/video/fbdev/via/lcd.c +++ b/drivers/video/fbdev/via/lcd.c @@ -543,7 +543,7 @@ void viafb_lcd_set_mode(const struct fb_var_screeninfo *var, u16 cxres, /* Get panel table Pointer */ panel_crt_table = viafb_get_best_mode(panel_hres, panel_vres, 60); viafb_fill_var_timing_info(&panel_var, panel_crt_table); - DEBUG_MSG(KERN_INFO "bellow viafb_lcd_set_mode!!\n"); + DEBUG_MSG(KERN_INFO "below viafb_lcd_set_mode!!\n"); if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) viafb_init_lvds_vt1636(plvds_setting_info, plvds_chip_info); clock = PICOS2KHZ(panel_crt_table->pixclock) * 1000; From 37a1a2e6eeeb101285cd34e12e48a881524701aa Mon Sep 17 00:00:00 2001 From: Tim Gardner Date: Mon, 27 Sep 2021 09:45:02 -0600 Subject: [PATCH 17/59] video: fbdev: nvidiafb: Use strscpy() to prevent buffer overflow Coverity complains of a possible buffer overflow. However, given the 'static' scope of nvidia_setup_i2c_bus() it looks like that can't happen after examiniing the call sites. CID 19036 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW) 1. fixed_size_dest: You might overrun the 48-character fixed-size string chan->adapter.name by copying name without checking the length. 2. parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function. 89 strcpy(chan->adapter.name, name); Fix this warning by using strscpy() which will silence the warning and prevent any future buffer overflows should the names used to identify the channel become much longer. Cc: Antonino Daplas Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Tim Gardner Signed-off-by: Helge Deller --- drivers/video/fbdev/nvidia/nv_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/nvidia/nv_i2c.c b/drivers/video/fbdev/nvidia/nv_i2c.c index d7994a1732459d..0b48965a6420c2 100644 --- a/drivers/video/fbdev/nvidia/nv_i2c.c +++ b/drivers/video/fbdev/nvidia/nv_i2c.c @@ -86,7 +86,7 @@ static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name, { int rc; - strcpy(chan->adapter.name, name); + strscpy(chan->adapter.name, name, sizeof(chan->adapter.name)); chan->adapter.owner = THIS_MODULE; chan->adapter.class = i2c_class; chan->adapter.algo_data = &chan->algo; From 3e17314c22eaec164d2b01b7c41466054df64cb3 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 20 Sep 2021 14:17:19 +0200 Subject: [PATCH 18/59] agp: define proper stubs for empty helpers The empty unmap_page_from_agp() macro causes a warning when building with 'make W=1' on a couple of architectures: drivers/char/agp/generic.c: In function 'agp_generic_destroy_page': drivers/char/agp/generic.c:1265:28: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body] 1265 | unmap_page_from_agp(page); Change the definitions to a 'do { } while (0)' construct to make these more reliable. Signed-off-by: Arnd Bergmann Acked-by: Helge Deller # parisc Signed-off-by: Helge Deller --- arch/parisc/include/asm/agp.h | 4 ++-- arch/powerpc/include/asm/agp.h | 4 ++-- arch/sparc/include/asm/agp.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/parisc/include/asm/agp.h b/arch/parisc/include/asm/agp.h index cb04470e63d0c7..14ae54cfd36880 100644 --- a/arch/parisc/include/asm/agp.h +++ b/arch/parisc/include/asm/agp.h @@ -8,8 +8,8 @@ * */ -#define map_page_into_agp(page) /* nothing */ -#define unmap_page_from_agp(page) /* nothing */ +#define map_page_into_agp(page) do { } while (0) +#define unmap_page_from_agp(page) do { } while (0) #define flush_agp_cache() mb() /* GATT allocation. Returns/accepts GATT kernel virtual address. */ diff --git a/arch/powerpc/include/asm/agp.h b/arch/powerpc/include/asm/agp.h index b29b1186f81938..6b6485c988dd8f 100644 --- a/arch/powerpc/include/asm/agp.h +++ b/arch/powerpc/include/asm/agp.h @@ -5,8 +5,8 @@ #include -#define map_page_into_agp(page) -#define unmap_page_from_agp(page) +#define map_page_into_agp(page) do {} while (0) +#define unmap_page_from_agp(page) do {} while (0) #define flush_agp_cache() mb() /* GATT allocation. Returns/accepts GATT kernel virtual address. */ diff --git a/arch/sparc/include/asm/agp.h b/arch/sparc/include/asm/agp.h index efe0d6a12e5a8b..2d0ff84cee3fd1 100644 --- a/arch/sparc/include/asm/agp.h +++ b/arch/sparc/include/asm/agp.h @@ -4,9 +4,9 @@ /* dummy for now */ -#define map_page_into_agp(page) -#define unmap_page_from_agp(page) -#define flush_agp_cache() mb() +#define map_page_into_agp(page) do { } while (0) +#define unmap_page_from_agp(page) do { } while (0) +#define flush_agp_cache() mb() /* GATT allocation. Returns/accepts GATT kernel virtual address. */ #define alloc_gatt_pages(order) \ From 212efde8818e3e7deb57f2e71201449a9c392f36 Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Thu, 12 Aug 2021 22:03:32 +0800 Subject: [PATCH 19/59] video: fbdev: au1200fb: Make use of dma_mmap_coherent() replace dma_mmap_attrs() with dma_mmap_coherent() kindly. BTW, fix indentation. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- drivers/video/fbdev/au1200fb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c index c00e01a1736857..81c31545442877 100644 --- a/drivers/video/fbdev/au1200fb.c +++ b/drivers/video/fbdev/au1200fb.c @@ -1233,8 +1233,8 @@ static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) { struct au1200fb_device *fbdev = info->par; - return dma_mmap_attrs(fbdev->dev, vma, fbdev->fb_mem, fbdev->fb_phys, - fbdev->fb_len, 0); + return dma_mmap_coherent(fbdev->dev, vma, + fbdev->fb_mem, fbdev->fb_phys, fbdev->fb_len); } static void set_global(u_int cmd, struct au1200_lcd_global_regs_t *pdata) From 8738ddcac644964ae128ccd3d80d48773c8d528e Mon Sep 17 00:00:00 2001 From: Evgeny Novikov Date: Wed, 11 Aug 2021 19:58:26 +0300 Subject: [PATCH 20/59] video: fbdev: w100fb: Reset global state w100fb_probe() did not reset the global state to its initial state. This can result in invocation of iounmap() even when there was not the appropriate successful call of ioremap(). For instance, this may be the case if first probe fails after two successful ioremap() while second probe fails when first ioremap() fails. The similar issue is with w100fb_remove(). The patch fixes both bugs. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Co-developed-by: Kirill Shilimanov Signed-off-by: Kirill Shilimanov Signed-off-by: Helge Deller --- drivers/video/fbdev/w100fb.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c index d96ab28f8ce4ae..4e641a780726e7 100644 --- a/drivers/video/fbdev/w100fb.c +++ b/drivers/video/fbdev/w100fb.c @@ -770,12 +770,18 @@ static int w100fb_probe(struct platform_device *pdev) fb_dealloc_cmap(&info->cmap); kfree(info->pseudo_palette); } - if (remapped_fbuf != NULL) + if (remapped_fbuf != NULL) { iounmap(remapped_fbuf); - if (remapped_regs != NULL) + remapped_fbuf = NULL; + } + if (remapped_regs != NULL) { iounmap(remapped_regs); - if (remapped_base != NULL) + remapped_regs = NULL; + } + if (remapped_base != NULL) { iounmap(remapped_base); + remapped_base = NULL; + } if (info) framebuffer_release(info); return err; @@ -795,8 +801,11 @@ static int w100fb_remove(struct platform_device *pdev) fb_dealloc_cmap(&info->cmap); iounmap(remapped_base); + remapped_base = NULL; iounmap(remapped_regs); + remapped_regs = NULL; iounmap(remapped_fbuf); + remapped_fbuf = NULL; framebuffer_release(info); From 9c5718ab30966feebc1428398b9022a820cfadf7 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 10 Sep 2021 17:58:44 +0100 Subject: [PATCH 21/59] video: fbdev: atyfb: Remove assigned but never used variable statements There are a couple of statements where local variables are being assigned values that are never read because the function returns immediately after the assignment. Clean up the code by removing them. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Signed-off-by: Helge Deller --- drivers/video/fbdev/aty/mach64_gx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/video/fbdev/aty/mach64_gx.c b/drivers/video/fbdev/aty/mach64_gx.c index 9c37e28fb78b5a..d06d248300807f 100644 --- a/drivers/video/fbdev/aty/mach64_gx.c +++ b/drivers/video/fbdev/aty/mach64_gx.c @@ -352,10 +352,8 @@ static int aty_var_to_pll_18818(const struct fb_info *info, u32 vclk_per, post_divider = 1; if (MHz100 > MAX_FREQ_2595) { - MHz100 = MAX_FREQ_2595; return -EINVAL; } else if (MHz100 < ABS_MIN_FREQ_2595) { - program_bits = 0; /* MHz100 = 257 */ return -EINVAL; } else { while (MHz100 < MIN_FREQ_2595) { From 25a968fbca7ab8b6d50cfed46825cad301c7f898 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 30 Dec 2021 15:52:01 +0000 Subject: [PATCH 22/59] video: fbdev: asiliantfb: remove redundant assignment to variable Ftarget Variable Ftarget is being initialized with a value that is never read, it is being re-assigned a different value a little later on. The assignment is redundant and can be removed. Signed-off-by: Colin Ian King Signed-off-by: Helge Deller --- drivers/video/fbdev/asiliantfb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/asiliantfb.c b/drivers/video/fbdev/asiliantfb.c index 84c56f525889fb..f8ef62542f7f59 100644 --- a/drivers/video/fbdev/asiliantfb.c +++ b/drivers/video/fbdev/asiliantfb.c @@ -110,7 +110,7 @@ static const struct fb_ops asiliantfb_ops = { static void asiliant_calc_dclk2(u32 *ppixclock, u8 *dclk2_m, u8 *dclk2_n, u8 *dclk2_div) { unsigned pixclock = *ppixclock; - unsigned Ftarget = 1000000 * (1000000 / pixclock); + unsigned Ftarget; unsigned n; unsigned best_error = 0xffffffff; unsigned best_m = 0xffffffff, From 1d09b2a18d4bfd0654fc30b4a3b2adf82d37bde6 Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Fri, 17 Sep 2021 12:24:10 +0800 Subject: [PATCH 23/59] video: fbdev: omapfb: panel-lgphilips-lb035q02: Make use of the helper function dev_err_probe() When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- .../fbdev/omap2/omapfb/displays/panel-lgphilips-lb035q02.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-lgphilips-lb035q02.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-lgphilips-lb035q02.c index 1bec7a4422e805..6befd22dbd5c41 100644 --- a/drivers/video/fbdev/omap2/omapfb/displays/panel-lgphilips-lb035q02.c +++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-lgphilips-lb035q02.c @@ -244,10 +244,9 @@ static int lb035q02_probe_of(struct spi_device *spi) struct gpio_desc *gpio; gpio = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW); - if (IS_ERR(gpio)) { - dev_err(&spi->dev, "failed to parse enable gpio\n"); - return PTR_ERR(gpio); - } + if (IS_ERR(gpio)) + return dev_err_probe(&spi->dev, PTR_ERR(gpio), + "failed to parse enable gpio\n"); ddata->enable_gpio = gpio; From 9d773f103b8953614e4ac28d3974719695580dcf Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Fri, 17 Sep 2021 12:24:11 +0800 Subject: [PATCH 24/59] video: fbdev: omapfb: lcd_ams_delta: Make use of the helper function dev_err_probe() When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- drivers/video/fbdev/omap/lcd_ams_delta.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/video/fbdev/omap/lcd_ams_delta.c b/drivers/video/fbdev/omap/lcd_ams_delta.c index 8e54aae544a0e9..bbf871f9d8623b 100644 --- a/drivers/video/fbdev/omap/lcd_ams_delta.c +++ b/drivers/video/fbdev/omap/lcd_ams_delta.c @@ -131,18 +131,14 @@ static int ams_delta_panel_probe(struct platform_device *pdev) int ret; gpiod_vblen = devm_gpiod_get(&pdev->dev, "vblen", GPIOD_OUT_LOW); - if (IS_ERR(gpiod_vblen)) { - ret = PTR_ERR(gpiod_vblen); - dev_err(&pdev->dev, "VBLEN GPIO request failed (%d)\n", ret); - return ret; - } + if (IS_ERR(gpiod_vblen)) + return dev_err_probe(&pdev->dev, PTR_ERR(gpiod_vblen), + "VBLEN GPIO request failed\n"); gpiod_ndisp = devm_gpiod_get(&pdev->dev, "ndisp", GPIOD_OUT_LOW); - if (IS_ERR(gpiod_ndisp)) { - ret = PTR_ERR(gpiod_ndisp); - dev_err(&pdev->dev, "NDISP GPIO request failed (%d)\n", ret); - return ret; - } + if (IS_ERR(gpiod_ndisp)) + return dev_err_probe(&pdev->dev, PTR_ERR(gpiod_ndisp), + "NDISP GPIO request failed\n"); #ifdef CONFIG_LCD_CLASS_DEVICE lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL, From 7ebf85c5b104b6e7d43dd9c729109e806fcdb657 Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Fri, 17 Sep 2021 12:24:12 +0800 Subject: [PATCH 25/59] video: fbdev: omapfb: panel-sharp-ls037v7dw01: Make use of the helper function dev_err_probe() When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- .../fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c index 602324c5c9f9c6..f1072c319de8ab 100644 --- a/drivers/video/fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c +++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c @@ -211,10 +211,9 @@ static int sharp_ls_probe_of(struct platform_device *pdev) int r; ddata->vcc = devm_regulator_get(&pdev->dev, "envdd"); - if (IS_ERR(ddata->vcc)) { - dev_err(&pdev->dev, "failed to get regulator\n"); - return PTR_ERR(ddata->vcc); - } + if (IS_ERR(ddata->vcc)) + return dev_err_probe(&pdev->dev, PTR_ERR(ddata->vcc), + "failed to get regulator\n"); /* lcd INI */ r = sharp_ls_get_gpio_of(&pdev->dev, 0, 0, "enable", &ddata->ini_gpio); From 0d3dbeb8142a92bb571c74b4e78f326b742fea64 Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Fri, 17 Sep 2021 12:24:13 +0800 Subject: [PATCH 26/59] video: fbdev: omapfb: panel-tpo-td043mtea1: Make use of the helper function dev_err_probe() When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- .../video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c index afac1d9445aa27..3db0232c31ab6f 100644 --- a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c +++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c @@ -517,8 +517,7 @@ static int tpo_td043_probe(struct spi_device *spi) ddata->vcc_reg = devm_regulator_get(&spi->dev, "vcc"); if (IS_ERR(ddata->vcc_reg)) { - dev_err(&spi->dev, "failed to get LCD VCC regulator\n"); - r = PTR_ERR(ddata->vcc_reg); + r = dev_err_probe(&spi->dev, r, "failed to get LCD VCC regulator\n"); goto err_regulator; } From 394e80c8c68df4684ac43cb09e315f126db7534f Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Fri, 17 Sep 2021 12:22:07 +0800 Subject: [PATCH 27/59] video: fbdev: da8xx-fb: Make use of the helper function dev_err_probe() When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- drivers/video/fbdev/da8xx-fb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c index 005ac3c17aa1f0..ae76a2111c7741 100644 --- a/drivers/video/fbdev/da8xx-fb.c +++ b/drivers/video/fbdev/da8xx-fb.c @@ -1354,10 +1354,9 @@ static int fb_probe(struct platform_device *device) return PTR_ERR(da8xx_fb_reg_base); tmp_lcdc_clk = devm_clk_get(&device->dev, "fck"); - if (IS_ERR(tmp_lcdc_clk)) { - dev_err(&device->dev, "Can not get device clock\n"); - return PTR_ERR(tmp_lcdc_clk); - } + if (IS_ERR(tmp_lcdc_clk)) + return dev_err_probe(&device->dev, PTR_ERR(tmp_lcdc_clk), + "Can not get device clock\n"); pm_runtime_enable(&device->dev); pm_runtime_get_sync(&device->dev); From 24e9c50d7adf438cdfa7367636ee87b88e93dc3c Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Fri, 17 Sep 2021 12:22:08 +0800 Subject: [PATCH 28/59] video: fbdev: pxa168fb: Make use of the helper function dev_err_probe() When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- drivers/video/fbdev/pxa168fb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/pxa168fb.c b/drivers/video/fbdev/pxa168fb.c index 47e6a1d0d2293e..35cf806a92199e 100644 --- a/drivers/video/fbdev/pxa168fb.c +++ b/drivers/video/fbdev/pxa168fb.c @@ -606,10 +606,9 @@ static int pxa168fb_probe(struct platform_device *pdev) } clk = devm_clk_get(&pdev->dev, "LCDCLK"); - if (IS_ERR(clk)) { - dev_err(&pdev->dev, "unable to get LCDCLK"); - return PTR_ERR(clk); - } + if (IS_ERR(clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(clk), + "unable to get LCDCLK"); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { From 626e021dab759df83ff575998e679276717f0a11 Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Fri, 17 Sep 2021 12:22:09 +0800 Subject: [PATCH 29/59] video: fbdev: pxa3xx-gcu: Make use of the helper function dev_err_probe() When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- drivers/video/fbdev/pxa3xx-gcu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/pxa3xx-gcu.c b/drivers/video/fbdev/pxa3xx-gcu.c index 4279e13a3b58dc..9239ecd3416935 100644 --- a/drivers/video/fbdev/pxa3xx-gcu.c +++ b/drivers/video/fbdev/pxa3xx-gcu.c @@ -606,10 +606,8 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev) /* enable the clock */ priv->clk = devm_clk_get(dev, NULL); - if (IS_ERR(priv->clk)) { - dev_err(dev, "failed to get clock\n"); - return PTR_ERR(priv->clk); - } + if (IS_ERR(priv->clk)) + return dev_err_probe(dev, PTR_ERR(priv->clk), "failed to get clock\n"); /* request the IRQ */ irq = platform_get_irq(pdev, 0); From a644da2ec57ac40a7f0763c099122bf189043c0b Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Fri, 17 Sep 2021 12:22:10 +0800 Subject: [PATCH 30/59] video: fbdev: ssd1307fb: Make use of the helper function dev_err_probe() When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- drivers/video/fbdev/ssd1307fb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 1e2f71c2f8a8bc..c6d5df31111d57 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -658,9 +658,8 @@ static int ssd1307fb_probe(struct i2c_client *client) par->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(par->reset)) { - dev_err(dev, "failed to get reset gpio: %ld\n", - PTR_ERR(par->reset)); - ret = PTR_ERR(par->reset); + ret = dev_err_probe(dev, PTR_ERR(par->reset), + "failed to get reset gpio\n"); goto fb_alloc_error; } @@ -670,7 +669,7 @@ static int ssd1307fb_probe(struct i2c_client *client) if (ret == -ENODEV) { par->vbat_reg = NULL; } else { - dev_err(dev, "failed to get VBAT regulator: %d\n", ret); + dev_err_probe(dev, ret, "failed to get VBAT regulator\n"); goto fb_alloc_error; } } From b1d8c84abb38564171694564a325734893493894 Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Fri, 17 Sep 2021 12:22:11 +0800 Subject: [PATCH 31/59] video: fbdev: s3c-fb: Make use of the helper function dev_err_probe() When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- drivers/video/fbdev/s3c-fb.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/s3c-fb.c b/drivers/video/fbdev/s3c-fb.c index 1d88dcd3e26beb..55889fe7121008 100644 --- a/drivers/video/fbdev/s3c-fb.c +++ b/drivers/video/fbdev/s3c-fb.c @@ -1392,18 +1392,17 @@ static int s3c_fb_probe(struct platform_device *pdev) spin_lock_init(&sfb->slock); sfb->bus_clk = devm_clk_get(dev, "lcd"); - if (IS_ERR(sfb->bus_clk)) { - dev_err(dev, "failed to get bus clock\n"); - return PTR_ERR(sfb->bus_clk); - } + if (IS_ERR(sfb->bus_clk)) + return dev_err_probe(dev, PTR_ERR(sfb->bus_clk), + "failed to get bus clock\n"); clk_prepare_enable(sfb->bus_clk); if (!sfb->variant.has_clksel) { sfb->lcd_clk = devm_clk_get(dev, "sclk_fimd"); if (IS_ERR(sfb->lcd_clk)) { - dev_err(dev, "failed to get lcd clock\n"); - ret = PTR_ERR(sfb->lcd_clk); + ret = dev_err_probe(dev, PTR_ERR(sfb->lcd_clk), + "failed to get lcd clock\n"); goto err_bus_clk; } From 81b63420564da2e4912733a966e87d6022ff313a Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Fri, 17 Sep 2021 12:22:12 +0800 Subject: [PATCH 32/59] video: fbdev: mmp: Make use of the helper function dev_err_probe() When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing Signed-off-by: Helge Deller --- drivers/video/fbdev/mmp/hw/mmp_ctrl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c index 061a105afb8655..a9df8ee7981020 100644 --- a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c +++ b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c @@ -514,7 +514,8 @@ static int mmphw_probe(struct platform_device *pdev) /* get clock */ ctrl->clk = devm_clk_get(ctrl->dev, mi->clk_name); if (IS_ERR(ctrl->clk)) { - dev_err(ctrl->dev, "unable to get clk %s\n", mi->clk_name); + dev_err_probe(ctrl->dev, ret, + "unable to get clk %s\n", mi->clk_name); ret = -ENOENT; goto failed; } From 5c6f402bdcf9e7239c6bc7087eda71ac99b31379 Mon Sep 17 00:00:00 2001 From: George Kennedy Date: Wed, 27 Oct 2021 15:30:13 -0500 Subject: [PATCH 33/59] video: fbdev: cirrusfb: check pixclock to avoid divide by zero Do a sanity check on pixclock value to avoid divide by zero. If the pixclock value is zero, the cirrusfb driver will round up pixclock to get the derived frequency as close to maxclock as possible. Syzkaller reported a divide error in cirrusfb_check_pixclock. divide error: 0000 [#1] SMP KASAN PTI CPU: 0 PID: 14938 Comm: cirrusfb_test Not tainted 5.15.0-rc6 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2 RIP: 0010:cirrusfb_check_var+0x6f1/0x1260 Call Trace: fb_set_var+0x398/0xf90 do_fb_ioctl+0x4b8/0x6f0 fb_ioctl+0xeb/0x130 __x64_sys_ioctl+0x19d/0x220 do_syscall_64+0x3a/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae Signed-off-by: George Kennedy Reviewed-by: Geert Uytterhoeven Signed-off-by: Helge Deller --- drivers/video/fbdev/cirrusfb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c index 93802abbbc72a5..3d47c347b89705 100644 --- a/drivers/video/fbdev/cirrusfb.c +++ b/drivers/video/fbdev/cirrusfb.c @@ -469,7 +469,7 @@ static int cirrusfb_check_mclk(struct fb_info *info, long freq) return 0; } -static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var, +static int cirrusfb_check_pixclock(struct fb_var_screeninfo *var, struct fb_info *info) { long freq; @@ -478,9 +478,7 @@ static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var, unsigned maxclockidx = var->bits_per_pixel >> 3; /* convert from ps to kHz */ - freq = PICOS2KHZ(var->pixclock); - - dev_dbg(info->device, "desired pixclock: %ld kHz\n", freq); + freq = PICOS2KHZ(var->pixclock ? : 1); maxclock = cirrusfb_board_info[cinfo->btype].maxclock[maxclockidx]; cinfo->multiplexing = 0; @@ -488,11 +486,13 @@ static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var, /* If the frequency is greater than we can support, we might be able * to use multiplexing for the video mode */ if (freq > maxclock) { - dev_err(info->device, - "Frequency greater than maxclock (%ld kHz)\n", - maxclock); - return -EINVAL; + var->pixclock = KHZ2PICOS(maxclock); + + while ((freq = PICOS2KHZ(var->pixclock)) > maxclock) + var->pixclock++; } + dev_dbg(info->device, "desired pixclock: %ld kHz\n", freq); + /* * Additional constraint: 8bpp uses DAC clock doubling to allow maximum * pixel clock From 0a786596954a81c293d0419151e7729a1d91a183 Mon Sep 17 00:00:00 2001 From: Changcheng Deng Date: Thu, 28 Oct 2021 11:08:47 +0000 Subject: [PATCH 34/59] video: fbmem: use swap() to make code cleaner in fb_rotate_logo() Use swap() in order to make code cleaner. Issue found by coccinelle. Reported-by: Zeal Robot Signed-off-by: Changcheng Deng Signed-off-by: Helge Deller --- drivers/video/fbdev/core/fbmem.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 0fa7ede94fa61a..2966da13d04865 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -396,18 +396,14 @@ static void fb_rotate_logo(struct fb_info *info, u8 *dst, } else if (rotate == FB_ROTATE_CW) { fb_rotate_logo_cw(image->data, dst, image->width, image->height); - tmp = image->width; - image->width = image->height; - image->height = tmp; + swap(image->width, image->height); tmp = image->dy; image->dy = image->dx; image->dx = info->var.xres - image->width - tmp; } else if (rotate == FB_ROTATE_CCW) { fb_rotate_logo_ccw(image->data, dst, image->width, image->height); - tmp = image->width; - image->width = image->height; - image->height = tmp; + swap(image->width, image->height); tmp = image->dx; image->dx = image->dy; image->dy = info->var.yres - image->height - tmp; From 24565bc4115961db7ee64fcc7ad2a7437c0d0a49 Mon Sep 17 00:00:00 2001 From: Yang Guang Date: Tue, 30 Nov 2021 08:06:03 +0800 Subject: [PATCH 35/59] video: fbdev: omapfb: acx565akm: replace snprintf with sysfs_emit coccinelle report: ./drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c: 479:9-17: WARNING: use scnprintf or sprintf Use sysfs_emit instead of scnprintf or sprintf makes more sense. Reported-by: Zeal Robot Signed-off-by: Yang Guang Signed-off-by: Helge Deller --- .../video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c index 8d8b5ff7d43c8e..3696eb09b69b46 100644 --- a/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c +++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c @@ -476,7 +476,7 @@ static ssize_t show_cabc_available_modes(struct device *dev, int i; if (!ddata->has_cabc) - return snprintf(buf, PAGE_SIZE, "%s\n", cabc_modes[0]); + return sysfs_emit(buf, "%s\n", cabc_modes[0]); for (i = 0, len = 0; len < PAGE_SIZE && i < ARRAY_SIZE(cabc_modes); i++) From 0f8a1cae923670b1cabb9a8f416271344159bd50 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 8 Dec 2021 10:27:36 +0300 Subject: [PATCH 36/59] video: fbdev: savagefb: make a variable local The "edid" struct member is only used during probe() and it's freed right away. There is no point in storing a freed pointer for the whole life of the driver. Signed-off-by: Dan Carpenter Signed-off-by: Helge Deller --- drivers/video/fbdev/savage/savagefb.h | 1 - drivers/video/fbdev/savage/savagefb_driver.c | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/savage/savagefb.h b/drivers/video/fbdev/savage/savagefb.h index 3314d5b6b43ba6..b6b8cc208293cc 100644 --- a/drivers/video/fbdev/savage/savagefb.h +++ b/drivers/video/fbdev/savage/savagefb.h @@ -195,7 +195,6 @@ struct savagefb_par { struct savage_reg initial; struct vgastate vgastate; struct mutex open_lock; - unsigned char *edid; u32 pseudo_palette[16]; u32 open_count; int paletteEnabled; diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index 0ac750cc5ea136..8114c921ceb8ba 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -2170,6 +2170,7 @@ static int savagefb_probe(struct pci_dev *dev, const struct pci_device_id *id) struct fb_info *info; struct savagefb_par *par; u_int h_sync, v_sync; + unsigned char __maybe_unused *edid; int err, lpitch; int video_len; @@ -2212,9 +2213,9 @@ static int savagefb_probe(struct pci_dev *dev, const struct pci_device_id *id) INIT_LIST_HEAD(&info->modelist); #if defined(CONFIG_FB_SAVAGE_I2C) savagefb_create_i2c_busses(info); - savagefb_probe_i2c_connector(info, &par->edid); - fb_edid_to_monspecs(par->edid, &info->monspecs); - kfree(par->edid); + savagefb_probe_i2c_connector(info, &edid); + fb_edid_to_monspecs(edid, &info->monspecs); + kfree(edid); fb_videomode_to_modelist(info->monspecs.modedb, info->monspecs.modedb_len, &info->modelist); From fee5c1e4b789e41719af9fee0e2dd397cd31988f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 3 Dec 2021 12:58:08 +0300 Subject: [PATCH 37/59] video: fbdev: atmel_lcdfb: fix an error code in atmel_lcdfb_probe() If "sinfo->config" is not found, then return -ENODEV. Don't return success. Fixes: b985172b328a ("video: atmel_lcdfb: add device tree suport") Signed-off-by: Dan Carpenter Acked-by: Nicolas Ferre Signed-off-by: Helge Deller --- drivers/video/fbdev/atmel_lcdfb.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c index 355b6120dc4f0d..1fc8de4ecbebf9 100644 --- a/drivers/video/fbdev/atmel_lcdfb.c +++ b/drivers/video/fbdev/atmel_lcdfb.c @@ -1062,15 +1062,16 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev) INIT_LIST_HEAD(&info->modelist); - if (pdev->dev.of_node) { - ret = atmel_lcdfb_of_init(sinfo); - if (ret) - goto free_info; - } else { + if (!pdev->dev.of_node) { dev_err(dev, "cannot get default configuration\n"); goto free_info; } + ret = atmel_lcdfb_of_init(sinfo); + if (ret) + goto free_info; + + ret = -ENODEV; if (!sinfo->config) goto free_info; From 6a3827ea4e2bccf89aa74654afbaf627e3dc64c9 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 25 Sep 2021 23:54:36 +0100 Subject: [PATCH 38/59] video: fbdev: pxa168fb: Initialize pointers with NULL and not plain integer 0 Pointers info and fbi are being initialized with plain integer zeros. Fix this by initializing them with NULLs. Signed-off-by: Colin Ian King Signed-off-by: Helge Deller --- drivers/video/fbdev/pxa168fb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/pxa168fb.c b/drivers/video/fbdev/pxa168fb.c index 35cf806a92199e..c25739f6934d93 100644 --- a/drivers/video/fbdev/pxa168fb.c +++ b/drivers/video/fbdev/pxa168fb.c @@ -593,8 +593,8 @@ static void pxa168fb_init_mode(struct fb_info *info, static int pxa168fb_probe(struct platform_device *pdev) { struct pxa168fb_mach_info *mi; - struct fb_info *info = 0; - struct pxa168fb_info *fbi = 0; + struct fb_info *info = NULL; + struct pxa168fb_info *fbi = NULL; struct resource *res; struct clk *clk; int irq, ret; From 78482af095abd9f4f29f1aa3fe575d25c6ae3028 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 16 Sep 2021 16:29:19 +0300 Subject: [PATCH 39/59] video: fbdev: fbcvt.c: fix printing in fb_cvt_print_name() This code has two bugs: 1) "cnt" is 255 but the size of the buffer is 256 so the last byte is not used. 2) If we try to print more than 255 characters then "cnt" will be negative and that will trigger a WARN() in snprintf(). The fix for this is to use scnprintf() instead of snprintf(). We can re-write this code to be cleaner: 1) Rename "offset" to "off" because that's shorter. 2) Get rid of the "cnt" variable and just use "size - off" directly. 3) Get rid of the "read" variable and just increment "off" directly. Fixes: 96fe6a2109db ("fbdev: Add VESA Coordinated Video Timings (CVT) support") Signed-off-by: Dan Carpenter Signed-off-by: Helge Deller --- drivers/video/fbdev/core/fbcvt.c | 53 +++++++++++++------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/drivers/video/fbdev/core/fbcvt.c b/drivers/video/fbdev/core/fbcvt.c index 55d2bd0ce5c022..64843464c66135 100644 --- a/drivers/video/fbdev/core/fbcvt.c +++ b/drivers/video/fbdev/core/fbcvt.c @@ -214,9 +214,11 @@ static u32 fb_cvt_aspect_ratio(struct fb_cvt_data *cvt) static void fb_cvt_print_name(struct fb_cvt_data *cvt) { u32 pixcount, pixcount_mod; - int cnt = 255, offset = 0, read = 0; - u8 *buf = kzalloc(256, GFP_KERNEL); + int size = 256; + int off = 0; + u8 *buf; + buf = kzalloc(size, GFP_KERNEL); if (!buf) return; @@ -224,43 +226,30 @@ static void fb_cvt_print_name(struct fb_cvt_data *cvt) pixcount_mod = (cvt->xres * (cvt->yres/cvt->interlace)) % 1000000; pixcount_mod /= 1000; - read = snprintf(buf+offset, cnt, "fbcvt: %dx%d@%d: CVT Name - ", - cvt->xres, cvt->yres, cvt->refresh); - offset += read; - cnt -= read; + off += scnprintf(buf + off, size - off, "fbcvt: %dx%d@%d: CVT Name - ", + cvt->xres, cvt->yres, cvt->refresh); - if (cvt->status) - snprintf(buf+offset, cnt, "Not a CVT standard - %d.%03d Mega " - "Pixel Image\n", pixcount, pixcount_mod); - else { - if (pixcount) { - read = snprintf(buf+offset, cnt, "%d", pixcount); - cnt -= read; - offset += read; - } + if (cvt->status) { + off += scnprintf(buf + off, size - off, + "Not a CVT standard - %d.%03d Mega Pixel Image\n", + pixcount, pixcount_mod); + } else { + if (pixcount) + off += scnprintf(buf + off, size - off, "%d", pixcount); - read = snprintf(buf+offset, cnt, ".%03dM", pixcount_mod); - cnt -= read; - offset += read; + off += scnprintf(buf + off, size - off, ".%03dM", pixcount_mod); if (cvt->aspect_ratio == 0) - read = snprintf(buf+offset, cnt, "3"); + off += scnprintf(buf + off, size - off, "3"); else if (cvt->aspect_ratio == 3) - read = snprintf(buf+offset, cnt, "4"); + off += scnprintf(buf + off, size - off, "4"); else if (cvt->aspect_ratio == 1 || cvt->aspect_ratio == 4) - read = snprintf(buf+offset, cnt, "9"); + off += scnprintf(buf + off, size - off, "9"); else if (cvt->aspect_ratio == 2) - read = snprintf(buf+offset, cnt, "A"); - else - read = 0; - cnt -= read; - offset += read; - - if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) { - read = snprintf(buf+offset, cnt, "-R"); - cnt -= read; - offset += read; - } + off += scnprintf(buf + off, size - off, "A"); + + if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) + off += scnprintf(buf + off, size - off, "-R"); } printk(KERN_INFO "%s\n", buf); From 863f946170515dfb08c2dbf3a5430bc43078b8d1 Mon Sep 17 00:00:00 2001 From: Yang Li Date: Tue, 1 Feb 2022 20:32:01 +0800 Subject: [PATCH 40/59] video: fbdev: pxa168fb: Remove unnecessary print function dev_err() The print function dev_err() is redundant because platform_get_irq() already prints an error. Eliminate the follow coccicheck warning: ./drivers/video/fbdev/pxa168fb.c:621:2-9: line 621 is redundant because platform_get_irq() already prints an error Reported-by: Abaci Robot Signed-off-by: Yang Li Signed-off-by: Helge Deller --- drivers/video/fbdev/pxa168fb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/video/fbdev/pxa168fb.c b/drivers/video/fbdev/pxa168fb.c index c25739f6934d93..e943300d23e8eb 100644 --- a/drivers/video/fbdev/pxa168fb.c +++ b/drivers/video/fbdev/pxa168fb.c @@ -617,10 +617,8 @@ static int pxa168fb_probe(struct platform_device *pdev) } irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "no IRQ defined\n"); + if (irq < 0) return -ENOENT; - } info = framebuffer_alloc(sizeof(struct pxa168fb_info), &pdev->dev); if (info == NULL) { From e2bc553359045472b5756d34010c7fad53ab0f40 Mon Sep 17 00:00:00 2001 From: Yang Li Date: Tue, 1 Feb 2022 20:32:02 +0800 Subject: [PATCH 41/59] video: fbdev: pxa3xx-gcu: Remove unnecessary print function dev_err() The print function dev_err() is redundant because platform_get_irq() already prints an error. Eliminate the follow coccicheck warning: ./drivers/video/fbdev/pxa3xx-gcu.c:615:2-9: line 615 is redundant because platform_get_irq() already prints an error Reported-by: Abaci Robot Signed-off-by: Yang Li Signed-off-by: Helge Deller --- drivers/video/fbdev/pxa3xx-gcu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/video/fbdev/pxa3xx-gcu.c b/drivers/video/fbdev/pxa3xx-gcu.c index 9239ecd3416935..350b3139c863ec 100644 --- a/drivers/video/fbdev/pxa3xx-gcu.c +++ b/drivers/video/fbdev/pxa3xx-gcu.c @@ -611,10 +611,8 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev) /* request the IRQ */ irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(dev, "no IRQ defined: %d\n", irq); + if (irq < 0) return irq; - } ret = devm_request_irq(dev, irq, pxa3xx_gcu_handle_irq, 0, DRV_NAME, priv); From c5510f53140c8d7c1c924414cbd8cc600a95d874 Mon Sep 17 00:00:00 2001 From: Wei Ming Chen Date: Wed, 8 Dec 2021 22:46:31 +0800 Subject: [PATCH 42/59] video: fbdev: Fix wrong file path for pvr2fb.c in Kconfig help text pvr2fb.c should be under drivers/video/fbdev/ instead of drivers/video/ Signed-off-by: Wei Ming Chen Reviewed-by: Andy Shevchenko Signed-off-by: Helge Deller --- 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 6ed5e608dd0412..93b8d84c34cf9c 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -829,7 +829,7 @@ config FB_PVR2 You can pass several parameters to the driver at boot time or at module load time. The parameters look like "video=pvr2:XXX", where the meaning of XXX can be found at the end of the main source file - (). Please see the file + (). Please see the file . config FB_OPENCORES From 4f37ea5d0e7c6ec65aa523db0ccd4ab9e52cb2e7 Mon Sep 17 00:00:00 2001 From: zhaoxiao Date: Fri, 11 Feb 2022 11:27:55 +0800 Subject: [PATCH 43/59] video: fbdev: s3c-fb: Use platform_get_irq() to get the interrupt platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static allocation of IRQ resources in DT core code, this causes an issue when using hierarchical interrupt domains using "interrupts" property in the node as this bypassed the hierarchical setup and messed up the irq chaining. In preparation for removal of static setup of IRQ resource from DT core code use platform_get_irq(). Signed-off-by: zhaoxiao Signed-off-by: Helge Deller --- drivers/video/fbdev/s3c-fb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/s3c-fb.c b/drivers/video/fbdev/s3c-fb.c index 55889fe7121008..576b0d9b88037a 100644 --- a/drivers/video/fbdev/s3c-fb.c +++ b/drivers/video/fbdev/s3c-fb.c @@ -1360,7 +1360,6 @@ static int s3c_fb_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct s3c_fb_platdata *pd; struct s3c_fb *sfb; - struct resource *res; int win; int ret = 0; u32 reg; @@ -1417,13 +1416,13 @@ static int s3c_fb_probe(struct platform_device *pdev) goto err_lcd_clk; } - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!res) { + sfb->irq_no = platform_get_irq(pdev, 0); + if (sfb->irq_no < 0) { dev_err(dev, "failed to acquire irq resource\n"); ret = -ENOENT; goto err_lcd_clk; } - sfb->irq_no = res->start; + ret = devm_request_irq(dev, sfb->irq_no, s3c_fb_irq, 0, "s3c_fb", sfb); if (ret) { From 0d84dcab5cf842011ed09ff52b8cd759c7e64d2a Mon Sep 17 00:00:00 2001 From: Guo Zhengkui Date: Fri, 19 Nov 2021 15:31:26 +0800 Subject: [PATCH 44/59] video: fbdev: omapfb: Use sysfs_emit() instead of snprintf() Use sysfs_emit() instead of snprintf(). Signed-off-by: Guo Zhengkui Signed-off-by: Helge Deller --- drivers/video/fbdev/omap/omapfb_main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/omap/omapfb_main.c b/drivers/video/fbdev/omap/omapfb_main.c index b495c09e610211..083388a4ceeb80 100644 --- a/drivers/video/fbdev/omap/omapfb_main.c +++ b/drivers/video/fbdev/omap/omapfb_main.c @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -1303,7 +1304,7 @@ static ssize_t omapfb_show_panel_name(struct device *dev, { struct omapfb_device *fbdev = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%s\n", fbdev->panel->name); + return sysfs_emit(buf, "%s\n", fbdev->panel->name); } static ssize_t omapfb_show_bklight_level(struct device *dev, @@ -1314,8 +1315,8 @@ static ssize_t omapfb_show_bklight_level(struct device *dev, int r; if (fbdev->panel->get_bklight_level) { - r = snprintf(buf, PAGE_SIZE, "%d\n", - fbdev->panel->get_bklight_level(fbdev->panel)); + r = sysfs_emit(buf, "%d\n", + fbdev->panel->get_bklight_level(fbdev->panel)); } else r = -ENODEV; return r; @@ -1348,8 +1349,8 @@ static ssize_t omapfb_show_bklight_max(struct device *dev, int r; if (fbdev->panel->get_bklight_level) { - r = snprintf(buf, PAGE_SIZE, "%d\n", - fbdev->panel->get_bklight_max(fbdev->panel)); + r = sysfs_emit(buf, "%d\n", + fbdev->panel->get_bklight_max(fbdev->panel)); } else r = -ENODEV; return r; @@ -1379,7 +1380,7 @@ static ssize_t omapfb_show_ctrl_name(struct device *dev, { struct omapfb_device *fbdev = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%s\n", fbdev->ctrl->name); + return sysfs_emit(buf, "%s\n", fbdev->ctrl->name); } static struct device_attribute dev_attr_ctrl_name = From f63658a59c3d439c8ad7b290f8ec270980e0f384 Mon Sep 17 00:00:00 2001 From: Jing Yao Date: Fri, 5 Nov 2021 08:13:33 +0000 Subject: [PATCH 45/59] video: fbdev: omapfb: panel-dsi-cm: Use sysfs_emit() instead of snprintf() Use sysfs_emit instead of scnprintf, snprintf or sprintf. Reported-by: Zeal Robot Signed-off-by: Jing Yao Signed-off-by: Helge Deller --- drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c index 4b0793abdd84b4..a2c7c5cb152346 100644 --- a/drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c +++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c @@ -409,7 +409,7 @@ static ssize_t dsicm_num_errors_show(struct device *dev, if (r) return r; - return snprintf(buf, PAGE_SIZE, "%d\n", errors); + return sysfs_emit(buf, "%d\n", errors); } static ssize_t dsicm_hw_revision_show(struct device *dev, @@ -439,7 +439,7 @@ static ssize_t dsicm_hw_revision_show(struct device *dev, if (r) return r; - return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x\n", id1, id2, id3); + return sysfs_emit(buf, "%02x.%02x.%02x\n", id1, id2, id3); } static ssize_t dsicm_store_ulps(struct device *dev, @@ -487,7 +487,7 @@ static ssize_t dsicm_show_ulps(struct device *dev, t = ddata->ulps_enabled; mutex_unlock(&ddata->lock); - return snprintf(buf, PAGE_SIZE, "%u\n", t); + return sysfs_emit(buf, "%u\n", t); } static ssize_t dsicm_store_ulps_timeout(struct device *dev, @@ -532,7 +532,7 @@ static ssize_t dsicm_show_ulps_timeout(struct device *dev, t = ddata->ulps_timeout; mutex_unlock(&ddata->lock); - return snprintf(buf, PAGE_SIZE, "%u\n", t); + return sysfs_emit(buf, "%u\n", t); } static DEVICE_ATTR(num_dsi_errors, S_IRUGO, dsicm_num_errors_show, NULL); From c07a039cbb96748f54c02995bae8131cc9a73b0a Mon Sep 17 00:00:00 2001 From: Jing Yao Date: Fri, 5 Nov 2021 08:20:44 +0000 Subject: [PATCH 46/59] video: fbdev: omapfb: panel-tpo-td043mtea1: Use sysfs_emit() instead of snprintf() Use sysfs_emit instead of scnprintf, snprintf or sprintf. Reported-by: Zeal Robot Signed-off-by: Jing Yao Signed-off-by: Helge Deller --- .../video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c index 3db0232c31ab6f..155b3f8ad158ba 100644 --- a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c +++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c @@ -169,7 +169,7 @@ static ssize_t tpo_td043_vmirror_show(struct device *dev, { struct panel_drv_data *ddata = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", ddata->vmirror); + return sysfs_emit(buf, "%d\n", ddata->vmirror); } static ssize_t tpo_td043_vmirror_store(struct device *dev, @@ -199,7 +199,7 @@ static ssize_t tpo_td043_mode_show(struct device *dev, { struct panel_drv_data *ddata = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", ddata->mode); + return sysfs_emit(buf, "%d\n", ddata->mode); } static ssize_t tpo_td043_mode_store(struct device *dev, From 81a998288956d09d7a7a2303d47e4d60ad55c401 Mon Sep 17 00:00:00 2001 From: Jing Yao Date: Thu, 4 Nov 2021 11:52:29 +0000 Subject: [PATCH 47/59] video: fbdev: udlfb: replace snprintf in show functions with sysfs_emit Use sysfs_emit instead of scnprintf, snprintf or sprintf. Reported-by: Zeal Robot Signed-off-by: Jing Yao Signed-off-by: Helge Deller --- drivers/video/fbdev/udlfb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index b9cdd02c100095..90f48b71fd8f79 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -1426,7 +1426,7 @@ 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 *dlfb = fb_info->par; - return snprintf(buf, PAGE_SIZE, "%u\n", + return sysfs_emit(buf, "%u\n", atomic_read(&dlfb->bytes_rendered)); } @@ -1434,7 +1434,7 @@ 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 *dlfb = fb_info->par; - return snprintf(buf, PAGE_SIZE, "%u\n", + return sysfs_emit(buf, "%u\n", atomic_read(&dlfb->bytes_identical)); } @@ -1442,7 +1442,7 @@ 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 *dlfb = fb_info->par; - return snprintf(buf, PAGE_SIZE, "%u\n", + return sysfs_emit(buf, "%u\n", atomic_read(&dlfb->bytes_sent)); } @@ -1450,7 +1450,7 @@ 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 *dlfb = fb_info->par; - return snprintf(buf, PAGE_SIZE, "%u\n", + return sysfs_emit(buf, "%u\n", atomic_read(&dlfb->cpu_kcycles_used)); } From 54a84a3cf0a6070a410d8e3f02c2c6aa7f1bb22d Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 15 Feb 2022 12:21:24 +0100 Subject: [PATCH 48/59] video: fbdev: atari: Fix TT High video mode The horizontal resolution (640) for the TT High video mode (1280x960) is definitely bogus. While fixing that, correct the timings to match the TTM195 service manual. Signed-off-by: Geert Uytterhoeven Signed-off-by: Helge Deller --- drivers/video/fbdev/atafb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c index e3812a8ff55a4f..a9f25cab4a1e67 100644 --- a/drivers/video/fbdev/atafb.c +++ b/drivers/video/fbdev/atafb.c @@ -487,8 +487,8 @@ static struct fb_videomode atafb_modedb[] __initdata = { "tt-mid", 60, 640, 480, 31041, 120, 100, 8, 16, 140, 30, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { - /* 1280x960, 29 kHz, 60 Hz (TT high) */ - "tt-high", 57, 640, 960, 31041, 120, 100, 8, 16, 140, 30, + /* 1280x960, 72 kHz, 72 Hz (TT high) */ + "tt-high", 57, 1280, 960, 7760, 260, 60, 36, 4, 192, 4, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, From 779ee89a2cfa0d511e9247ad9e5d7f8c87962ccb Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 15 Feb 2022 12:21:25 +0100 Subject: [PATCH 49/59] video: fbdev: atari: Convert to standard round_up() helper Remove the custom macro up(), and convert the code to use the standard round_up() helper instead. Signed-off-by: Geert Uytterhoeven Signed-off-by: Helge Deller --- drivers/video/fbdev/atafb.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c index a9f25cab4a1e67..b9d6aaaeae43f2 100644 --- a/drivers/video/fbdev/atafb.c +++ b/drivers/video/fbdev/atafb.c @@ -76,8 +76,6 @@ #define SWITCH_SND7 0x80 #define SWITCH_NONE 0x00 -#define up(x, r) (((x) + (r) - 1) & ~((r)-1)) - static int default_par; /* default resolution (0=none) */ @@ -1649,12 +1647,12 @@ static int falcon_pan_display(struct fb_var_screeninfo *var, int bpp = info->var.bits_per_pixel; if (bpp == 1) - var->xoffset = up(var->xoffset, 32); + var->xoffset = round_up(var->xoffset, 32); if (bpp != 16) par->hw.falcon.xoffset = var->xoffset & 15; else { par->hw.falcon.xoffset = 0; - var->xoffset = up(var->xoffset, 2); + var->xoffset = round_up(var->xoffset, 2); } par->hw.falcon.line_offset = bpp * (info->var.xres_virtual - info->var.xres) / 16; @@ -2268,7 +2266,7 @@ static int pan_display(struct fb_var_screeninfo *var, struct fb_info *info) if (!fbhw->set_screen_base || (!ATARIHW_PRESENT(EXTD_SHIFTER) && var->xoffset)) return -EINVAL; - var->xoffset = up(var->xoffset, 16); + var->xoffset = round_up(var->xoffset, 16); par->screen_base = screen_base + (var->yoffset * info->var.xres_virtual + var->xoffset) * info->var.bits_per_pixel / 8; From fdaae9fefb95b73d47fec00b40d688b2931076d1 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 15 Feb 2022 12:21:26 +0100 Subject: [PATCH 50/59] video: fbdev: atari: Remove unused atafb_setcolreg() atafb_probe() overrides the atafb_ops.fb_setcolreg() method to match the actual graphics hardware. Besides, the shifts by 8 were bogus, as the individual .fb_setcolreg() implementations already take care of that. Signed-off-by: Geert Uytterhoeven Signed-off-by: Helge Deller --- drivers/video/fbdev/atafb.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c index b9d6aaaeae43f2..e95333e004744b 100644 --- a/drivers/video/fbdev/atafb.c +++ b/drivers/video/fbdev/atafb.c @@ -2404,16 +2404,6 @@ static void atafb_set_disp(struct fb_info *info) atari_stram_to_virt(info->fix.smem_start)); } -static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, - u_int transp, struct fb_info *info) -{ - red >>= 8; - green >>= 8; - blue >>= 8; - - return info->fbops->fb_setcolreg(regno, red, green, blue, transp, info); -} - static int atafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { @@ -2724,7 +2714,6 @@ static struct fb_ops atafb_ops = { .owner = THIS_MODULE, .fb_check_var = atafb_check_var, .fb_set_par = atafb_set_par, - .fb_setcolreg = atafb_setcolreg, .fb_blank = atafb_blank, .fb_pan_display = atafb_pan_display, .fb_fillrect = atafb_fillrect, From c8be5edbd36ceed2ff3d6b8f8e40643c3f396ea3 Mon Sep 17 00:00:00 2001 From: Michael Schmitz Date: Wed, 16 Feb 2022 20:26:25 +1300 Subject: [PATCH 51/59] video: fbdev: atari: Atari 2 bpp (STe) palette bugfix The code to set the shifter STe palette registers has a long standing operator precedence bug, manifesting as colors set on a 2 bits per pixel frame buffer coming up with a distinctive blue tint. Add parentheses around the calculation of the per-color palette data before shifting those into their respective bit field position. This bug goes back a long way (2.4 days at the very least) so there won't be a Fixes: tag. Tested on ARAnyM as well on Falcon030 hardware. Cc: stable@vger.kernel.org Reported-by: Geert Uytterhoeven Link: https://lore.kernel.org/all/CAMuHMdU3ievhXxKR_xi_v3aumnYW7UNUO6qMdhgfyWTyVSsCkQ@mail.gmail.com Tested-by: Michael Schmitz Tested-by: Geert Uytterhoeven Signed-off-by: Michael Schmitz Signed-off-by: Helge Deller --- drivers/video/fbdev/atafb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c index e95333e004744b..52a35b66164381 100644 --- a/drivers/video/fbdev/atafb.c +++ b/drivers/video/fbdev/atafb.c @@ -1681,9 +1681,9 @@ static int falcon_setcolreg(unsigned int regno, unsigned int red, ((blue & 0xfc00) >> 8)); if (regno < 16) { shifter_tt.color_reg[regno] = - (((red & 0xe000) >> 13) | ((red & 0x1000) >> 12) << 8) | - (((green & 0xe000) >> 13) | ((green & 0x1000) >> 12) << 4) | - ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12); + ((((red & 0xe000) >> 13) | ((red & 0x1000) >> 12)) << 8) | + ((((green & 0xe000) >> 13) | ((green & 0x1000) >> 12)) << 4) | + ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12); ((u32 *)info->pseudo_palette)[regno] = ((red & 0xf800) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11)); @@ -1969,9 +1969,9 @@ static int stste_setcolreg(unsigned int regno, unsigned int red, green >>= 12; if (ATARIHW_PRESENT(EXTD_SHIFTER)) shifter_tt.color_reg[regno] = - (((red & 0xe) >> 1) | ((red & 1) << 3) << 8) | - (((green & 0xe) >> 1) | ((green & 1) << 3) << 4) | - ((blue & 0xe) >> 1) | ((blue & 1) << 3); + ((((red & 0xe) >> 1) | ((red & 1) << 3)) << 8) | + ((((green & 0xe) >> 1) | ((green & 1) << 3)) << 4) | + ((blue & 0xe) >> 1) | ((blue & 1) << 3); else shifter_tt.color_reg[regno] = ((red & 0xe) << 7) | From 0714ea330b998d94dc26834c113716563fab7f17 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 16 Feb 2022 09:40:29 +0100 Subject: [PATCH 52/59] video: fbdev: au1100fb: Spelling s/palette/palette/ Fix a misspelling of "palette" in a structure member. Signed-off-by: Geert Uytterhoeven Signed-off-by: Helge Deller --- drivers/video/fbdev/au1100fb.c | 2 +- drivers/video/fbdev/au1100fb.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c index 37a6512feda0fb..52f731a6148210 100644 --- a/drivers/video/fbdev/au1100fb.c +++ b/drivers/video/fbdev/au1100fb.c @@ -239,7 +239,7 @@ int au1100fb_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned u32 value; fbdev = to_au1100fb_device(fbi); - palette = fbdev->regs->lcd_pallettebase; + palette = fbdev->regs->lcd_palettebase; if (regno > (AU1100_LCD_NBR_PALETTE_ENTRIES - 1)) return -EINVAL; diff --git a/drivers/video/fbdev/au1100fb.h b/drivers/video/fbdev/au1100fb.h index e7239bceefd3ad..79f4048726f1af 100644 --- a/drivers/video/fbdev/au1100fb.h +++ b/drivers/video/fbdev/au1100fb.h @@ -92,7 +92,7 @@ struct au1100fb_regs u32 lcd_pwmdiv; u32 lcd_pwmhi; u32 reserved[(0x0400-0x002C)/4]; - u32 lcd_pallettebase[256]; + u32 lcd_palettebase[256]; }; struct au1100fb_device { From 997403e7782a3b9aa6e2b28c6b78793659483af3 Mon Sep 17 00:00:00 2001 From: Xiaoke Wang Date: Mon, 21 Feb 2022 18:37:34 +0800 Subject: [PATCH 53/59] video: fbdev: via: check the return value of kstrdup() kstrdup() is a memory allocation function which can return NULL when some internal memory errors happen. It is better to check the return value of it to catch the error in time during the setup of viafb. Signed-off-by: Xiaoke Wang Signed-off-by: Helge Deller --- drivers/video/fbdev/via/viafbdev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/video/fbdev/via/viafbdev.c b/drivers/video/fbdev/via/viafbdev.c index 22deb340a0484f..2d67c92c57749c 100644 --- a/drivers/video/fbdev/via/viafbdev.c +++ b/drivers/video/fbdev/via/viafbdev.c @@ -1939,8 +1939,12 @@ static int __init viafb_setup(void) if (!strncmp(this_opt, "viafb_mode1=", 12)) { viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL); + if (!viafb_mode1) + return -ENOMEM; } else if (!strncmp(this_opt, "viafb_mode=", 11)) { viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL); + if (!viafb_mode) + return -ENOMEM; } else if (!strncmp(this_opt, "viafb_bpp1=", 11)) { if (kstrtouint(this_opt + 11, 0, &viafb_bpp1) < 0) return -EINVAL; @@ -1969,6 +1973,8 @@ static int __init viafb_setup(void) return -EINVAL; } else if (!strncmp(this_opt, "viafb_active_dev=", 17)) { viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL); + if (!viafb_active_dev) + return -ENOMEM; } else if (!strncmp(this_opt, "viafb_display_hardware_layout=", 30)) { if (kstrtoint(this_opt + 30, 0, @@ -1995,8 +2001,12 @@ static int __init viafb_setup(void) return -EINVAL; } else if (!strncmp(this_opt, "viafb_lcd_port=", 15)) { viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL); + if (!viafb_lcd_port) + return -ENOMEM; } else if (!strncmp(this_opt, "viafb_dvi_port=", 15)) { viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL); + if (!viafb_dvi_port) + return -ENOMEM; } } return 0; From bd771cf5c4254511cc4abb88f3dab3bd58bdf8e8 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Sun, 27 Feb 2022 08:43:56 +0100 Subject: [PATCH 54/59] video: fbdev: sm712fb: Fix crash in smtcfb_read() Zheyu Ma reported this crash in the sm712fb driver when reading three bytes from the framebuffer: BUG: unable to handle page fault for address: ffffc90001ffffff RIP: 0010:smtcfb_read+0x230/0x3e0 Call Trace: vfs_read+0x198/0xa00 ? do_sys_openat2+0x27d/0x350 ? __fget_light+0x54/0x340 ksys_read+0xce/0x190 do_syscall_64+0x43/0x90 Fix it by removing the open-coded endianess fixup-code and by moving the pointer post decrement out the fb_readl() function. Reported-by: Zheyu Ma Signed-off-by: Helge Deller Tested-by: Zheyu Ma Cc: stable@vger.kernel.org --- drivers/video/fbdev/sm712fb.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c index 0dbc6bf8268acf..b60a2730f0a8a8 100644 --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -1047,7 +1047,7 @@ static ssize_t smtcfb_read(struct fb_info *info, char __user *buf, if (count + p > total_size) count = total_size - p; - buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, GFP_KERNEL); + buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!buffer) return -ENOMEM; @@ -1059,24 +1059,13 @@ static ssize_t smtcfb_read(struct fb_info *info, char __user *buf, while (count) { c = (count > PAGE_SIZE) ? PAGE_SIZE : count; dst = buffer; - for (i = c >> 2; i--;) { - *dst = fb_readl(src++); - *dst = big_swap(*dst); - dst++; - } - if (c & 3) { - u8 *dst8 = (u8 *)dst; - u8 __iomem *src8 = (u8 __iomem *)src; + for (i = (c + 3) >> 2; i--;) { + u32 val; - for (i = c & 3; i--;) { - if (i & 1) { - *dst8++ = fb_readb(++src8); - } else { - *dst8++ = fb_readb(--src8); - src8 += 2; - } - } - src = (u32 __iomem *)src8; + val = fb_readl(src); + *dst = big_swap(val); + src++; + dst++; } if (copy_to_user(buf, buffer, c)) { From 961e366c85314c31a367fcf32fa944be64167d75 Mon Sep 17 00:00:00 2001 From: Yihao Han Date: Tue, 1 Mar 2022 19:44:08 -0800 Subject: [PATCH 55/59] video: fbdev: s3c-fb: fix platform_get_irq.cocci warning Remove dev_err() messages after platform_get_irq*() failures. platform_get_irq() already prints an error. Generated by: scripts/coccinelle/api/platform_get_irq.cocci Signed-off-by: Yihao Han Signed-off-by: Helge Deller --- drivers/video/fbdev/s3c-fb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/fbdev/s3c-fb.c b/drivers/video/fbdev/s3c-fb.c index 576b0d9b88037a..fe3c8b6935cfce 100644 --- a/drivers/video/fbdev/s3c-fb.c +++ b/drivers/video/fbdev/s3c-fb.c @@ -1418,7 +1418,6 @@ static int s3c_fb_probe(struct platform_device *pdev) sfb->irq_no = platform_get_irq(pdev, 0); if (sfb->irq_no < 0) { - dev_err(dev, "failed to acquire irq resource\n"); ret = -ENOENT; goto err_lcd_clk; } From 4f01d09b2bbfbcb47b3eb305560a7f4857a32260 Mon Sep 17 00:00:00 2001 From: Zheyu Ma Date: Wed, 2 Mar 2022 22:33:11 +0800 Subject: [PATCH 56/59] video: fbdev: sm712fb: Fix crash in smtcfb_write() When the sm712fb driver writes three bytes to the framebuffer, the driver will crash: BUG: unable to handle page fault for address: ffffc90001ffffff RIP: 0010:smtcfb_write+0x454/0x5b0 Call Trace: vfs_write+0x291/0xd60 ? do_sys_openat2+0x27d/0x350 ? __fget_light+0x54/0x340 ksys_write+0xce/0x190 do_syscall_64+0x43/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae Fix it by removing the open-coded endianness fixup-code. Signed-off-by: Zheyu Ma Signed-off-by: Helge Deller --- drivers/video/fbdev/sm712fb.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c index b60a2730f0a8a8..092a1caa1208e1 100644 --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -1119,7 +1119,7 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf, count = total_size - p; } - buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, GFP_KERNEL); + buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!buffer) return -ENOMEM; @@ -1137,24 +1137,11 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf, break; } - for (i = c >> 2; i--;) { - fb_writel(big_swap(*src), dst++); + for (i = (c + 3) >> 2; i--;) { + fb_writel(big_swap(*src), dst); + dst++; src++; } - if (c & 3) { - u8 *src8 = (u8 *)src; - u8 __iomem *dst8 = (u8 __iomem *)dst; - - for (i = c & 3; i--;) { - if (i & 1) { - fb_writeb(*src8++, ++dst8); - } else { - fb_writeb(*src8++, --dst8); - dst8 += 2; - } - } - dst = (u32 __iomem *)dst8; - } *ppos += c; buf += c; From a58c22cfbbf62fefca090334bbd35fd132e92a23 Mon Sep 17 00:00:00 2001 From: Miaoqian Lin Date: Mon, 7 Mar 2022 12:38:12 +0000 Subject: [PATCH 57/59] video: fbdev: omapfb: Add missing of_node_put() in dvic_probe_of The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done. Fixes: f76ee892a99e ("omapfb: copy omapdss & displays for omapfb") Signed-off-by: Miaoqian Lin Signed-off-by: Helge Deller --- drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c b/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c index 2fa436475b406d..c8ad3ef42bd319 100644 --- a/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c +++ b/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c @@ -246,6 +246,7 @@ static int dvic_probe_of(struct platform_device *pdev) adapter_node = of_parse_phandle(node, "ddc-i2c-bus", 0); if (adapter_node) { adapter = of_get_i2c_adapter_by_node(adapter_node); + of_node_put(adapter_node); if (adapter == NULL) { dev_err(&pdev->dev, "failed to parse ddc-i2c-bus\n"); omap_dss_put_device(ddata->in); From 5b34b0c2248968ec83ebd78669dc0b9085d13f75 Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Fri, 11 Mar 2022 10:56:48 +0800 Subject: [PATCH 58/59] video: fbdev: offb: fix warning comparing pointer to 0 Fix the following coccicheck warning: drivers/video/fbdev/offb.c:415:13-14: WARNING comparing pointer to 0 Signed-off-by: Haowen Bai Signed-off-by: Helge Deller --- drivers/video/fbdev/offb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/offb.c b/drivers/video/fbdev/offb.c index 4501e848a36f2c..afdb6aa48add2c 100644 --- a/drivers/video/fbdev/offb.c +++ b/drivers/video/fbdev/offb.c @@ -412,7 +412,7 @@ static void __init offb_init_fb(const char *name, info = framebuffer_alloc(sizeof(u32) * 16, NULL); - if (info == 0) { + if (!info) { release_mem_region(res_start, res_size); return; } From e445c8b2aa2df0e49f6037886c32d54a5e3960b1 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 8 Mar 2022 20:23:28 +0000 Subject: [PATCH 59/59] video: fbdev: kyro: make read-only array ODValues static const Don't populate the read-only array ODValues on the stack but instead make it static const. Also makes the object code a little smaller. Signed-off-by: Colin Ian King Signed-off-by: Helge Deller --- drivers/video/fbdev/kyro/STG4000InitDevice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/kyro/STG4000InitDevice.c b/drivers/video/fbdev/kyro/STG4000InitDevice.c index 21875d3c2dc207..edfa0a04854d16 100644 --- a/drivers/video/fbdev/kyro/STG4000InitDevice.c +++ b/drivers/video/fbdev/kyro/STG4000InitDevice.c @@ -124,7 +124,7 @@ u32 ProgramClock(u32 refClock, u32 ulScore, ulPhaseScore, ulVcoScore; u32 ulTmp = 0, ulVCO; u32 ulScaleClockReq, ulMinClock, ulMaxClock; - u32 ODValues[] = { 1, 2, 0 }; + static const unsigned char ODValues[] = { 1, 2, 0 }; /* Translate clock in Hz */ coreClock *= 100; /* in Hz */