From b27c46d143def69a3517e3ff8cdd2e0e01716a8b Mon Sep 17 00:00:00 2001 From: Lars Ivar Miljeteig Date: Wed, 6 May 2020 19:59:16 +0200 Subject: [PATCH] video: mxsfb: Don't set blank state if enable failed Check if lcd interface enable was a success before setting current blank state. This fixes a bug where the pan function failes when waiting for an interrupt, when the driver believes the display is unblanked when in fact it is not. Also user space applications that call ioctl to do blanking will be notified when the blanking failed. --- drivers/video/fbdev/mxsfb.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c index 0e28d16f8a52..5fff150ab1c9 100644 --- a/drivers/video/fbdev/mxsfb.c +++ b/drivers/video/fbdev/mxsfb.c @@ -672,7 +672,7 @@ static int mxsfb_check_var(struct fb_var_screeninfo *var, return 0; } -static void mxsfb_enable_controller(struct fb_info *fb_info) +static int mxsfb_enable_controller(struct fb_info *fb_info) { struct mxsfb_info *host = fb_info->par; u32 reg; @@ -688,7 +688,7 @@ static void mxsfb_enable_controller(struct fb_info *fb_info) if (ret < 0) { dev_err(&host->pdev->dev, "failed to setup" "dispdrv:%s\n", host->dispdrv->drv->name); - return; + return ret; } host->sync = fb_info->var.sync; } @@ -698,7 +698,7 @@ static void mxsfb_enable_controller(struct fb_info *fb_info) if (ret) { dev_err(&host->pdev->dev, "lcd regulator enable failed: %d\n", ret); - return; + return ret; } } @@ -707,7 +707,7 @@ static void mxsfb_enable_controller(struct fb_info *fb_info) if (ret) { dev_err(&host->pdev->dev, "lcd2 regulator enable failed: %d\n", ret); - return; + return ret; } } @@ -746,7 +746,7 @@ static void mxsfb_enable_controller(struct fb_info *fb_info) "lcd2 regulator disable failed: %d\n", ret); } - return; + return ret; } clk_enable_pix(host); #ifdef CONFIG_FB_IMX64_DEBUG @@ -773,6 +773,7 @@ static void mxsfb_enable_controller(struct fb_info *fb_info) host->enabled = 1; + return 0; } static void mxsfb_disable_controller(struct fb_info *fb_info) @@ -1095,11 +1096,14 @@ static int mxsfb_ioctl(struct fb_info *fb_info, unsigned int cmd, static int mxsfb_blank(int blank, struct fb_info *fb_info) { struct mxsfb_info *host = fb_info->par; + int ret = 0; + int prev_blank; #ifdef CONFIG_FB_IMX64_DEBUG return 0; #endif + prev_blank = host->cur_blank; host->cur_blank = blank; switch (blank) { @@ -1130,11 +1134,13 @@ static int mxsfb_blank(int blank, struct fb_info *fb_info) writel(0, host->base + LCDC_CTRL); mxsfb_set_par(host->fb_info); - mxsfb_enable_controller(fb_info); + ret = mxsfb_enable_controller(fb_info); + if (ret) + host->cur_blank = prev_blank; } break; } - return 0; + return ret; } static int mxsfb_pan_display(struct fb_var_screeninfo *var,