diff mbox

drm/msm/dsi: Fix the releasing of resources in error path in 'dsi_bus_clk_enable()'

Message ID 20170226075206.25762-1-christophe.jaillet@wanadoo.fr (mailing list archive)
State Not Applicable, archived
Delegated to: Andy Gross
Headers show

Commit Message

Christophe JAILLET Feb. 26, 2017, 7:52 a.m. UTC
If a 'clk_prepare_enable()' fails, then we need to disable_unprepare the
clk already handled.

With the current implemenatation, we try to do that on the clk that has
triggered the error, which is a no-op, and leave 'msm_host->bus_clks[0]'
untouched.

Shift by one the index array to free resources correctly.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Walter Harms Feb. 26, 2017, 9:03 a.m. UTC | #1
Am 26.02.2017 08:52, schrieb Christophe JAILLET:
> If a 'clk_prepare_enable()' fails, then we need to disable_unprepare the
> clk already handled.
> 
> With the current implemenatation, we try to do that on the clk that has
> triggered the error, which is a no-op, and leave 'msm_host->bus_clks[0]'
> untouched.
> 
> Shift by one the index array to free resources correctly.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 1fc07ce24686..eac4987f3946 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -438,7 +438,7 @@ static int dsi_bus_clk_enable(struct msm_dsi_host *msm_host)
>  	return 0;
>  err:
>  	for (; i > 0; i--)
> -		clk_disable_unprepare(msm_host->bus_clks[i]);
> +		clk_disable_unprepare(msm_host->bus_clks[i-1]);
>  
>  	return ret;
>  }

i guess it is technical correct but programmes are
very bad at counting backwards so its more future proof to
do something like:

for (j=0;j<i;j++)
	clk_disable_unprepare(msm_host->bus_clks[j]);

re,
 wh




--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rob Clark Feb. 26, 2017, 1:03 p.m. UTC | #2
On Sun, Feb 26, 2017 at 2:52 AM, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
> If a 'clk_prepare_enable()' fails, then we need to disable_unprepare the
> clk already handled.
>
> With the current implemenatation, we try to do that on the clk that has
> triggered the error, which is a no-op, and leave 'msm_host->bus_clks[0]'
> untouched.
>
> Shift by one the index array to free resources correctly.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Rob Clark <robdclark@gmail.com>

> ---
>  drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 1fc07ce24686..eac4987f3946 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -438,7 +438,7 @@ static int dsi_bus_clk_enable(struct msm_dsi_host *msm_host)
>         return 0;
>  err:
>         for (; i > 0; i--)
> -               clk_disable_unprepare(msm_host->bus_clks[i]);
> +               clk_disable_unprepare(msm_host->bus_clks[i-1]);
>
>         return ret;
>  }
> --
> 2.9.3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 1fc07ce24686..eac4987f3946 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -438,7 +438,7 @@  static int dsi_bus_clk_enable(struct msm_dsi_host *msm_host)
 	return 0;
 err:
 	for (; i > 0; i--)
-		clk_disable_unprepare(msm_host->bus_clks[i]);
+		clk_disable_unprepare(msm_host->bus_clks[i-1]);
 
 	return ret;
 }