Commit cc6df3a2 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Tomi Valkeinen

video: fbdev: imxfb: add some error handling

clk_prepare_enable can fail and if it does the controller must not be
considered enabled. So check for errors, properly unwind and give the
error code back to the caller.

While touching the clock code also enable the clocks in the same
direction and disable in reverse order.
Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 46ffe109
...@@ -473,11 +473,12 @@ static int imxfb_set_par(struct fb_info *info) ...@@ -473,11 +473,12 @@ static int imxfb_set_par(struct fb_info *info)
return 0; return 0;
} }
static void imxfb_enable_controller(struct imxfb_info *fbi) static int imxfb_enable_controller(struct imxfb_info *fbi)
{ {
int ret;
if (fbi->enabled) if (fbi->enabled)
return; return 0;
pr_debug("Enabling LCD controller\n"); pr_debug("Enabling LCD controller\n");
...@@ -496,10 +497,29 @@ static void imxfb_enable_controller(struct imxfb_info *fbi) ...@@ -496,10 +497,29 @@ static void imxfb_enable_controller(struct imxfb_info *fbi)
*/ */
writel(RMCR_LCDC_EN_MX1, fbi->regs + LCDC_RMCR); writel(RMCR_LCDC_EN_MX1, fbi->regs + LCDC_RMCR);
clk_prepare_enable(fbi->clk_ipg); ret = clk_prepare_enable(fbi->clk_ipg);
clk_prepare_enable(fbi->clk_ahb); if (ret)
clk_prepare_enable(fbi->clk_per); goto err_enable_ipg;
ret = clk_prepare_enable(fbi->clk_ahb);
if (ret)
goto err_enable_ahb;
ret = clk_prepare_enable(fbi->clk_per);
if (ret)
goto err_enable_per;
fbi->enabled = true; fbi->enabled = true;
return 0;
err_enable_per:
clk_disable_unprepare(fbi->clk_ahb);
err_enable_ahb:
clk_disable_unprepare(fbi->clk_ipg);
err_enable_ipg:
writel(0, fbi->regs + LCDC_RMCR);
return ret;
} }
static void imxfb_disable_controller(struct imxfb_info *fbi) static void imxfb_disable_controller(struct imxfb_info *fbi)
...@@ -510,8 +530,8 @@ static void imxfb_disable_controller(struct imxfb_info *fbi) ...@@ -510,8 +530,8 @@ static void imxfb_disable_controller(struct imxfb_info *fbi)
pr_debug("Disabling LCD controller\n"); pr_debug("Disabling LCD controller\n");
clk_disable_unprepare(fbi->clk_per); clk_disable_unprepare(fbi->clk_per);
clk_disable_unprepare(fbi->clk_ipg);
clk_disable_unprepare(fbi->clk_ahb); clk_disable_unprepare(fbi->clk_ahb);
clk_disable_unprepare(fbi->clk_ipg);
fbi->enabled = false; fbi->enabled = false;
writel(0, fbi->regs + LCDC_RMCR); writel(0, fbi->regs + LCDC_RMCR);
...@@ -532,8 +552,7 @@ static int imxfb_blank(int blank, struct fb_info *info) ...@@ -532,8 +552,7 @@ static int imxfb_blank(int blank, struct fb_info *info)
break; break;
case FB_BLANK_UNBLANK: case FB_BLANK_UNBLANK:
imxfb_enable_controller(fbi); return imxfb_enable_controller(fbi);
break;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment