From e755554568fbe638bb69f0faffb116436ec28af2 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 5 Mar 2024 17:22:36 +0100 Subject: hid: hid-picolcd: Fix initialization order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For drivers that support backlight, LCD and fbdev devices, fbdev has to be initialized last. See documentation for struct fbinfo.bl_dev. Signed-off-by: Thomas Zimmermann Cc: Bruno Prémont Reviewed-by: Javier Martinez Canillas Link: https://lore.kernel.org/r/20240305162425.23845-4-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/hid/hid-picolcd_core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/hid') diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c index bbda231a7ce3..5ddebe25eb91 100644 --- a/drivers/hid/hid-picolcd_core.c +++ b/drivers/hid/hid-picolcd_core.c @@ -474,11 +474,6 @@ static int picolcd_probe_lcd(struct hid_device *hdev, struct picolcd_data *data) if (error) goto err; - /* Set up the framebuffer device */ - error = picolcd_init_framebuffer(data); - if (error) - goto err; - /* Setup lcd class device */ error = picolcd_init_lcd(data, picolcd_out_report(REPORT_CONTRAST, hdev)); if (error) @@ -489,6 +484,11 @@ static int picolcd_probe_lcd(struct hid_device *hdev, struct picolcd_data *data) if (error) goto err; + /* Set up the framebuffer device */ + error = picolcd_init_framebuffer(data); + if (error) + goto err; + /* Setup the LED class devices */ error = picolcd_init_leds(data, picolcd_out_report(REPORT_LED_STATE, hdev)); if (error) @@ -502,9 +502,9 @@ static int picolcd_probe_lcd(struct hid_device *hdev, struct picolcd_data *data) return 0; err: picolcd_exit_leds(data); + picolcd_exit_framebuffer(data); picolcd_exit_backlight(data); picolcd_exit_lcd(data); - picolcd_exit_framebuffer(data); picolcd_exit_cir(data); picolcd_exit_keys(data); return error; @@ -623,9 +623,9 @@ static void picolcd_remove(struct hid_device *hdev) /* Cleanup LED */ picolcd_exit_leds(data); /* Clean up the framebuffer */ + picolcd_exit_framebuffer(data); picolcd_exit_backlight(data); picolcd_exit_lcd(data); - picolcd_exit_framebuffer(data); /* Cleanup input */ picolcd_exit_cir(data); picolcd_exit_keys(data); -- cgit v1.2.3 From c34b107770ed6643ea999d7be3566f54ec065239 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 5 Mar 2024 17:22:37 +0100 Subject: hid: hid-picolcd: Remove struct backlight_ops.check_fb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the driver to initialize struct fb_info.bl_dev to its backlight device, if any. Thus rely on the backlight core code to match backlight and framebuffer devices, and remove the extra check_fb function from struct backlight_ops. v2: * protect against CONFIG_FB_BACKLIGHT (Javier, kernel test robot) * reword commit message (Daniel) Signed-off-by: Thomas Zimmermann Cc: Bruno Prémont Reviewed-by: Javier Martinez Canillas Link: https://lore.kernel.org/r/20240305162425.23845-5-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/hid/hid-picolcd_backlight.c | 7 ------- drivers/hid/hid-picolcd_fb.c | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers/hid') diff --git a/drivers/hid/hid-picolcd_backlight.c b/drivers/hid/hid-picolcd_backlight.c index 5bd2a8c4bbd6..08d16917eb60 100644 --- a/drivers/hid/hid-picolcd_backlight.c +++ b/drivers/hid/hid-picolcd_backlight.c @@ -9,7 +9,6 @@ #include -#include #include #include "hid-picolcd.h" @@ -39,15 +38,9 @@ static int picolcd_set_brightness(struct backlight_device *bdev) return 0; } -static int picolcd_check_bl_fb(struct backlight_device *bdev, struct fb_info *fb) -{ - return fb && fb == picolcd_fbinfo((struct picolcd_data *)bl_get_data(bdev)); -} - static const struct backlight_ops picolcd_blops = { .update_status = picolcd_set_brightness, .get_brightness = picolcd_get_brightness, - .check_fb = picolcd_check_bl_fb, }; int picolcd_init_backlight(struct picolcd_data *data, struct hid_report *report) diff --git a/drivers/hid/hid-picolcd_fb.c b/drivers/hid/hid-picolcd_fb.c index d7dddd99d325..750206f5fc67 100644 --- a/drivers/hid/hid-picolcd_fb.c +++ b/drivers/hid/hid-picolcd_fb.c @@ -493,6 +493,12 @@ int picolcd_init_framebuffer(struct picolcd_data *data) info->fix = picolcdfb_fix; info->fix.smem_len = PICOLCDFB_SIZE*8; +#ifdef CONFIG_FB_BACKLIGHT +#ifdef CONFIG_HID_PICOLCD_BACKLIGHT + info->bl_dev = data->backlight; +#endif +#endif + fbdata = info->par; spin_lock_init(&fbdata->lock); fbdata->picolcd = data; -- cgit v1.2.3 From b8beae949433ab03de0ddfc97bc56db956a04662 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 24 Apr 2024 08:33:41 +0200 Subject: HID: picoLCD: Constify lcd_ops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'struct lcd_ops' is not modified by core backlight code, so it can be made const for increased code safety. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Bruno Prémont Link: https://lore.kernel.org/r/20240424-video-backlight-lcd-ops-v2-15-1aaa82b07bc6@kernel.org Signed-off-by: Lee Jones --- drivers/hid/hid-picolcd_lcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/hid') diff --git a/drivers/hid/hid-picolcd_lcd.c b/drivers/hid/hid-picolcd_lcd.c index 0c4b76de8ae5..061a33ba7b1d 100644 --- a/drivers/hid/hid-picolcd_lcd.c +++ b/drivers/hid/hid-picolcd_lcd.c @@ -46,7 +46,7 @@ static int picolcd_check_lcd_fb(struct lcd_device *ldev, struct fb_info *fb) return fb && fb == picolcd_fbinfo((struct picolcd_data *)lcd_get_data(ldev)); } -static struct lcd_ops picolcd_lcdops = { +static const struct lcd_ops picolcd_lcdops = { .get_contrast = picolcd_get_contrast, .set_contrast = picolcd_set_contrast, .check_fb = picolcd_check_lcd_fb, -- cgit v1.2.3