aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2017-10-09 23:20:00 -0400
committerMaxime Ripard <maxime.ripard@free-electrons.com>2017-10-11 03:52:58 -0400
commit544c5048bcdc5d5c395d99d61ab7a52964a1420b (patch)
tree8caf9cc1a930d641cce19c94c0f32bb8b521cdc6
parent67e326450d7af554e80fbbac73b2b65b6468afca (diff)
drm/sun4i: hdmi: Disable clks in bind function error path and unbind function
The HDMI driver enables the bus and mod clocks in the bind function, but does not disable them if it then bails our due to any errors. Neither does it disable the clocks in the unbind function. Fix this by adding a proper error path to the bind function, and clk_disable_unprepare calls to the unbind function. Also rename the err_cleanup_connector label to err_cleanup_encoder, since it is the encoder that gets cleaned up. Fixes: 9c5681011a0c ("drm/sun4i: Add HDMI support") Signed-off-by: Chen-Yu Tsai <wens@csie.org> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Link: https://patchwork.freedesktop.org/patch/msgid/20171010032008.682-4-wens@csie.org
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
index 9ea6cd5a1370..3cf1a6932fac 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
@@ -302,26 +302,29 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master,
302 hdmi->mod_clk = devm_clk_get(dev, "mod"); 302 hdmi->mod_clk = devm_clk_get(dev, "mod");
303 if (IS_ERR(hdmi->mod_clk)) { 303 if (IS_ERR(hdmi->mod_clk)) {
304 dev_err(dev, "Couldn't get the HDMI mod clock\n"); 304 dev_err(dev, "Couldn't get the HDMI mod clock\n");
305 return PTR_ERR(hdmi->mod_clk); 305 ret = PTR_ERR(hdmi->mod_clk);
306 goto err_disable_bus_clk;
306 } 307 }
307 clk_prepare_enable(hdmi->mod_clk); 308 clk_prepare_enable(hdmi->mod_clk);
308 309
309 hdmi->pll0_clk = devm_clk_get(dev, "pll-0"); 310 hdmi->pll0_clk = devm_clk_get(dev, "pll-0");
310 if (IS_ERR(hdmi->pll0_clk)) { 311 if (IS_ERR(hdmi->pll0_clk)) {
311 dev_err(dev, "Couldn't get the HDMI PLL 0 clock\n"); 312 dev_err(dev, "Couldn't get the HDMI PLL 0 clock\n");
312 return PTR_ERR(hdmi->pll0_clk); 313 ret = PTR_ERR(hdmi->pll0_clk);
314 goto err_disable_mod_clk;
313 } 315 }
314 316
315 hdmi->pll1_clk = devm_clk_get(dev, "pll-1"); 317 hdmi->pll1_clk = devm_clk_get(dev, "pll-1");
316 if (IS_ERR(hdmi->pll1_clk)) { 318 if (IS_ERR(hdmi->pll1_clk)) {
317 dev_err(dev, "Couldn't get the HDMI PLL 1 clock\n"); 319 dev_err(dev, "Couldn't get the HDMI PLL 1 clock\n");
318 return PTR_ERR(hdmi->pll1_clk); 320 ret = PTR_ERR(hdmi->pll1_clk);
321 goto err_disable_mod_clk;
319 } 322 }
320 323
321 ret = sun4i_tmds_create(hdmi); 324 ret = sun4i_tmds_create(hdmi);
322 if (ret) { 325 if (ret) {
323 dev_err(dev, "Couldn't create the TMDS clock\n"); 326 dev_err(dev, "Couldn't create the TMDS clock\n");
324 return ret; 327 goto err_disable_mod_clk;
325 } 328 }
326 329
327 writel(SUN4I_HDMI_CTRL_ENABLE, hdmi->base + SUN4I_HDMI_CTRL_REG); 330 writel(SUN4I_HDMI_CTRL_ENABLE, hdmi->base + SUN4I_HDMI_CTRL_REG);
@@ -362,7 +365,7 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master,
362 ret = sun4i_hdmi_i2c_create(dev, hdmi); 365 ret = sun4i_hdmi_i2c_create(dev, hdmi);
363 if (ret) { 366 if (ret) {
364 dev_err(dev, "Couldn't create the HDMI I2C adapter\n"); 367 dev_err(dev, "Couldn't create the HDMI I2C adapter\n");
365 return ret; 368 goto err_disable_mod_clk;
366 } 369 }
367 370
368 drm_encoder_helper_add(&hdmi->encoder, 371 drm_encoder_helper_add(&hdmi->encoder,
@@ -422,6 +425,10 @@ err_cleanup_connector:
422 drm_encoder_cleanup(&hdmi->encoder); 425 drm_encoder_cleanup(&hdmi->encoder);
423err_del_i2c_adapter: 426err_del_i2c_adapter:
424 i2c_del_adapter(hdmi->i2c); 427 i2c_del_adapter(hdmi->i2c);
428err_disable_mod_clk:
429 clk_disable_unprepare(hdmi->mod_clk);
430err_disable_bus_clk:
431 clk_disable_unprepare(hdmi->bus_clk);
425 return ret; 432 return ret;
426} 433}
427 434
@@ -434,6 +441,8 @@ static void sun4i_hdmi_unbind(struct device *dev, struct device *master,
434 drm_connector_cleanup(&hdmi->connector); 441 drm_connector_cleanup(&hdmi->connector);
435 drm_encoder_cleanup(&hdmi->encoder); 442 drm_encoder_cleanup(&hdmi->encoder);
436 i2c_del_adapter(hdmi->i2c); 443 i2c_del_adapter(hdmi->i2c);
444 clk_disable_unprepare(hdmi->mod_clk);
445 clk_disable_unprepare(hdmi->bus_clk);
437} 446}
438 447
439static const struct component_ops sun4i_hdmi_ops = { 448static const struct component_ops sun4i_hdmi_ops = {