drm/tegra: Fix some error handling paths
cover drm/tegra: Fix some error handling paths
Most of the patches are retated to tegra_output_probe() and missing tegra_output_remove(). Others are things spotted while writting the serie.
Patches 1, 3, 4 are verbose, but some functions called in the probe can return -EPROBE_DEFER, so it is nice to correctly release resources.
Maybe moving the tegra_output_probe() call would minimize the changes, but I'm always reluctant to move code, because of possible side-effects.
Christophe JAILLET (6):
drm/tegra: dsi: Fix some error handling paths in tegra_dsi_probe() drm/tegra: dsi: Fix missing pm_runtime_disable() in the error handling
path of tegra_dsi_probe()
drm/tegra: dsi: Fix some error handling paths in tegra_hdmi_probe() drm/tegra: rgb: Fix some error handling paths in tegra_dc_rgb_probe() drm/tegra: rgb: Fix missing clk_put() in the error handling paths of
tegra_dc_rgb_probe()
drm/tegra: output: Fix missing i2c_put_adapter() in the error handling
paths of tegra_output_probe()
drivers/gpu/drm/tegra/dsi.c | 55 ++++++++++++++++++++++------------ drivers/gpu/drm/tegra/hdmi.c | 20 ++++++++----- drivers/gpu/drm/tegra/output.c | 16 +++++++--- drivers/gpu/drm/tegra/rgb.c | 18 +++++++---- 4 files changed, 74 insertions(+), 35 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/6 drm/tegra: dsi: Fix some error handling paths in tegra_dsi_probe()
If an error occurs after calling tegra_output_probe(), tegra_output_remove() should be called as already done in the remove function.
--- drivers/gpu/drm/tegra/dsi.c | 54 ++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 19 deletions(-)
drivers/gpu/drm/tegra/dsi.c +35 -19
@@ -1593,44 +1593,58 @@ static int tegra_dsi_probe(struct platform_device *pdev)if (!pdev->dev.pm_domain) { dsi->rst =devm_reset_control_get (&pdev->dev,"dsi" ); -if (IS_ERR (dsi->rst)) -return PTR_ERR (dsi->rst); +if (IS_ERR (dsi->rst)) { + err =PTR_ERR (dsi->rst); + goto tegra_remove; + } } dsi->clk =devm_clk_get (&pdev->dev,NULL ); -if (IS_ERR (dsi->clk)) -return dev_err_probe (&pdev->dev,PTR_ERR (dsi->clk), -"cannot get DSI clock\n" ); +if (IS_ERR (dsi->clk)) { + err =dev_err_probe (&pdev->dev,PTR_ERR (dsi->clk), +"cannot get DSI clock\n" ); + goto tegra_remove; + } dsi->clk_lp =devm_clk_get (&pdev->dev,"lp" ); -if (IS_ERR (dsi->clk_lp)) -return dev_err_probe (&pdev->dev,PTR_ERR (dsi->clk_lp), -"cannot get low-power clock\n" ); +if (IS_ERR (dsi->clk_lp)) { + err =dev_err_probe (&pdev->dev,PTR_ERR (dsi->clk_lp), +"cannot get low-power clock\n" ); + goto tegra_remove; + } dsi->clk_parent =devm_clk_get (&pdev->dev,"parent" ); -if (IS_ERR (dsi->clk_parent)) -return dev_err_probe (&pdev->dev,PTR_ERR (dsi->clk_parent), -"cannot get parent clock\n" ); +if (IS_ERR (dsi->clk_parent)) { + err =dev_err_probe (&pdev->dev,PTR_ERR (dsi->clk_parent), +"cannot get parent clock\n" ); + goto tegra_remove; + } dsi->vdd =devm_regulator_get (&pdev->dev,"avdd-dsi-csi" ); -if (IS_ERR (dsi->vdd)) -return dev_err_probe (&pdev->dev,PTR_ERR (dsi->vdd), -"cannot get VDD supply\n" ); +if (IS_ERR (dsi->vdd)) { + err =dev_err_probe (&pdev->dev,PTR_ERR (dsi->vdd), +"cannot get VDD supply\n" ); + goto tegra_remove; + } err =tegra_dsi_setup_clocks (dsi);if (err <0 ) {dev_err (&pdev->dev,"cannot setup clocks\n" ); -return err; + goto tegra_remove; } regs =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); dsi->regs =devm_ioremap_resource (&pdev->dev, regs); -if (IS_ERR (dsi->regs)) -return PTR_ERR (dsi->regs); +if (IS_ERR (dsi->regs)) { + err =PTR_ERR (dsi->regs); + goto tegra_remove; + } dsi->mipi =tegra_mipi_request (&pdev->dev, pdev->dev.of_node); -if (IS_ERR (dsi->mipi)) -return PTR_ERR (dsi->mipi); +if (IS_ERR (dsi->mipi)) { + err =PTR_ERR (dsi->mipi); + goto tegra_remove; + } dsi->host.ops = &tegra_dsi_host_ops; dsi->host.dev = &pdev->dev;
@@ -1661,6 +1675,8 @@ static int tegra_dsi_probe(struct platform_device *pdev)mipi_dsi_host_unregister (&dsi->host); mipi_free:tegra_mipi_free (dsi->mipi); +tegra_remove: +tegra_output_remove (&dsi->output);return err; }
Signature · 1 line
2.34.1
PATCH 2/6 drm/tegra: dsi: Fix missing pm_runtime_disable() in the error handling path of tegra_dsi_probe()
In reply to Christophe JAILLETIf an error occurs after calling pm_runtime_enable(), pm_runtime_disable() should be called as already done in the remove function.
--- drivers/gpu/drm/tegra/dsi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/tegra/dsi.c +1 -0
@@ -1672,6 +1672,7 @@ static int tegra_dsi_probe(struct platform_device *pdev)return 0 ; unregister: +pm_runtime_disable (&pdev->dev);mipi_dsi_host_unregister (&dsi->host); mipi_free:tegra_mipi_free (dsi->mipi);
Signature · 1 line
2.34.1
PATCH 3/6 drm/tegra: hdmi: Fix some error handling paths in tegra_hdmi_probe()
In reply to Christophe JAILLETIf an error occurs after calling tegra_output_probe(), tegra_output_remove() should be called as already done in the remove function.
--- drivers/gpu/drm/tegra/hdmi.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/gpu/drm/tegra/hdmi.c +13 -7
@@ -1854,12 +1854,14 @@ static int tegra_hdmi_probe(struct platform_device *pdev)return err; hdmi->regs =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (hdmi->regs)) -return PTR_ERR (hdmi->regs); +if (IS_ERR (hdmi->regs)) { + err =PTR_ERR (hdmi->regs); + goto tegra_remove; + } err =platform_get_irq (pdev,0 );if (err <0 ) -return err; + goto tegra_remove; hdmi->irq = err;
@@ -1868,18 +1870,18 @@ static int tegra_hdmi_probe(struct platform_device *pdev)if (err <0 ) {dev_err (&pdev->dev,"failed to request IRQ#%u: %d\n" , hdmi->irq, err); -return err; + goto tegra_remove; }platform_set_drvdata (pdev, hdmi); err =devm_pm_runtime_enable (&pdev->dev);if (err) -return err; + goto tegra_remove; err =devm_tegra_core_dev_init_opp_table_common (&pdev->dev);if (err) -return err; + goto tegra_remove;INIT_LIST_HEAD (&hdmi->client.list); hdmi->client.ops = &hdmi_client_ops;
@@ -1889,10 +1891,14 @@ static int tegra_hdmi_probe(struct platform_device *pdev)if (err <0 ) {dev_err (&pdev->dev,"failed to register host1x client: %d\n" , err); -return err; + goto tegra_remove; }return 0 ; + +tegra_remove: +tegra_output_remove (&hdmi->output); +return err; }static void tegra_hdmi_remove (struct platform_device *pdev)
Signature · 1 line
2.34.1
PATCH 4/6 drm/tegra: rgb: Fix some error handling paths in tegra_dc_rgb_probe()
In reply to Christophe JAILLETIf an error occurs after calling tegra_output_probe(), tegra_output_remove() should be called as already done in the remove function.
--- drivers/gpu/drm/tegra/rgb.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/gpu/drm/tegra/rgb.c +11 -5
@@ -215,26 +215,28 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc) rgb->clk =devm_clk_get (dc->dev,NULL );if (IS_ERR (rgb->clk)) {dev_err (dc->dev,"failed to get clock\n" ); -return PTR_ERR (rgb->clk); + err =PTR_ERR (rgb->clk); + goto tegra_remove; } rgb->clk_parent =devm_clk_get (dc->dev,"parent" );if (IS_ERR (rgb->clk_parent)) {dev_err (dc->dev,"failed to get parent clock\n" ); -return PTR_ERR (rgb->clk_parent); + err =PTR_ERR (rgb->clk_parent); + goto tegra_remove; } err =clk_set_parent (rgb->clk, rgb->clk_parent);if (err <0 ) {dev_err (dc->dev,"failed to set parent clock: %d\n" , err); -return err; + goto tegra_remove; } rgb->pll_d_out0 =clk_get_sys (NULL ,"pll_d_out0" );if (IS_ERR (rgb->pll_d_out0)) { err =PTR_ERR (rgb->pll_d_out0);dev_err (dc->dev,"failed to get pll_d_out0: %d\n" , err); -return err; + goto tegra_remove; }if (dc->soc->has_pll_d2_out0) {
@@ -242,13 +244,17 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)if (IS_ERR (rgb->pll_d2_out0)) { err =PTR_ERR (rgb->pll_d2_out0);dev_err (dc->dev,"failed to get pll_d2_out0: %d\n" , err); -return err; + goto tegra_remove; } } dc->rgb = &rgb->output;return 0 ; + +tegra_remove: +tegra_output_remove (&rgb->output); +return err; }void tegra_dc_rgb_remove (struct tegra_dc *dc)
Signature · 1 line
2.34.1
PATCH 5/6 drm/tegra: rgb: Fix missing clk_put() in the error handling paths of tegra_dc_rgb_probe()
In reply to Christophe JAILLETIf clk_get_sys(..., "pll_d2_out0") fails, the clk_get_sys() call must be undone.
Add the missing clk_put and a new 'put_pll_d_out0' label in the error handling path, and use it.
--- drivers/gpu/drm/tegra/rgb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/tegra/rgb.c +3 -1
@@ -244,7 +244,7 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)if (IS_ERR (rgb->pll_d2_out0)) { err =PTR_ERR (rgb->pll_d2_out0);dev_err (dc->dev,"failed to get pll_d2_out0: %d\n" , err); - goto tegra_remove; + goto put_pll_d_out0; } }
@@ -252,6 +252,8 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)return 0 ; +put_pll_d_out0: +clk_put (rgb->pll_d_out0); tegra_remove:tegra_output_remove (&rgb->output);return err;
Signature · 1 line
2.34.1
PATCH 6/6 drm/tegra: output: Fix missing i2c_put_adapter() in the error handling paths of tegra_output_probe()
In reply to Christophe JAILLETIf an error occurs after a successful of_get_i2c_adapter_by_node() call, it should be undone by a corresponding i2c_put_adapter().
Add the missing i2c_put_adapter() call.
--- drivers/gpu/drm/tegra/output.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/tegra/output.c +12 -4
@@ -142,8 +142,10 @@ int tegra_output_probe(struct tegra_output *output)GPIOD_IN , "HDMI hotplug detect");if (IS_ERR (output->hpd_gpio)) { -if (PTR_ERR (output->hpd_gpio) != -ENOENT ) -return PTR_ERR (output->hpd_gpio); +if (PTR_ERR (output->hpd_gpio) != -ENOENT ) { + err =PTR_ERR (output->hpd_gpio); + goto put_i2c; + } output->hpd_gpio =NULL ; }
@@ -152,7 +154,7 @@ int tegra_output_probe(struct tegra_output *output) err =gpiod_to_irq (output->hpd_gpio);if (err <0 ) {dev_err (output->dev,"gpiod_to_irq(): %d\n" , err); -return err; + goto put_i2c; } output->hpd_irq = err;
@@ -165,7 +167,7 @@ int tegra_output_probe(struct tegra_output *output)if (err <0 ) {dev_err (output->dev,"failed to request IRQ#%u: %d\n" , output->hpd_irq, err); -return err; + goto put_i2c; } output->connector.polled =DRM_CONNECTOR_POLL_HPD ;
@@ -179,6 +181,12 @@ int tegra_output_probe(struct tegra_output *output) }return 0 ; + +put_i2c: +if (output->ddc) +i2c_put_adapter (output->ddc); + +return err; }void tegra_output_remove (struct tegra_output *output)
Signature · 1 line
2.34.1
Quoted 22 lines · Christophe JAILLET
Most of the patches are retated to
tegra_output_probe()and missingtegra_output_remove(). Others are things spotted while writting the serie.Patches 1, 3, 4 are verbose, but some functions called in the probe can return -EPROBE_DEFER, so it is nice to correctly release resources.
Maybe moving the
tegra_output_probe()call would minimize the changes, but I'm always reluctant to move code, because of possible side-effects.Christophe JAILLET (6):
drm/tegra: dsi: Fix some error handling paths integra_dsi_probe()drm/tegra: dsi: Fix missingpm_runtime_disable()in the error handling
path oftegra_dsi_probe()
drm/tegra: dsi: Fix some error handling paths integra_hdmi_probe()drm/tegra: rgb: Fix some error handling paths integra_dc_rgb_probe()drm/tegra: rgb: Fix missingclk_put()in the error handling paths of
tegra_dc_rgb_probe()
drm/tegra: output: Fix missingi2c_put_adapter()in the error handling
paths oftegra_output_probe()
Quoted 5 lines
drivers/gpu/drm/tegra/dsi.c | 55 ++++++++++++++++++++++------------ drivers/gpu/drm/tegra/hdmi.c | 20 ++++++++----- drivers/gpu/drm/tegra/output.c | 16 +++++++--- drivers/gpu/drm/tegra/rgb.c | 18 +++++++---- 4 files changed, 74 insertions(+), 35 deletions(-)
Sorry, this fell through the cracks. Applied now, thanks.
Thierry