diff mbox

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

Message ID 20170226121057.9717-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, 12:10 p.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.

Count forward in order to fix it and be more future proof.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
v2: change the for loop from a backward to a forward one, to ease reading.
---
 drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Walter Harms Feb. 26, 2017, 2:28 p.m. UTC | #1
looks good to me.

Reviewed-by: wharms@bfs.de

Am 26.02.2017 13:10, 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.
> 
> Count forward in order to fix it and be more future proof.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> v2: change the for loop from a backward to a forward one, to ease reading.
> ---
>  drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 1fc07ce24686..e6f56cd8ce08 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -422,7 +422,7 @@ static int dsi_clk_init(struct msm_dsi_host *msm_host)
>  static int dsi_bus_clk_enable(struct msm_dsi_host *msm_host)
>  {
>  	const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg;
> -	int i, ret;
> +	int i, j, ret;
>  
>  	DBG("id=%d", msm_host->id);
>  
> @@ -437,8 +437,8 @@ 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]);
> +	for (j = 0; j < i; j++)
> +		clk_disable_unprepare(msm_host->bus_clks[j]);
>  
>  	return ret;
>  }
--
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, 3:25 p.m. UTC | #2
On Sun, Feb 26, 2017 at 7:10 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.
>
> Count forward in order to fix it and be more future proof.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> v2: change the for loop from a backward to a forward one, to ease reading.

fwiw, I prefer your v1, for reasons discussed on a similar patch
fixing the same issue:

https://lists.freedesktop.org/archives/dri-devel/2017-February/133097.html

(although your v1 is a better solution than the original, since we
probably don't want to clk_disable_unprepare() the clk that failed to
enable.)

BR,
-R

> ---
>  drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 1fc07ce24686..e6f56cd8ce08 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -422,7 +422,7 @@ static int dsi_clk_init(struct msm_dsi_host *msm_host)
>  static int dsi_bus_clk_enable(struct msm_dsi_host *msm_host)
>  {
>         const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg;
> -       int i, ret;
> +       int i, j, ret;
>
>         DBG("id=%d", msm_host->id);
>
> @@ -437,8 +437,8 @@ 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]);
> +       for (j = 0; j < i; j++)
> +               clk_disable_unprepare(msm_host->bus_clks[j]);
>
>         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..e6f56cd8ce08 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -422,7 +422,7 @@  static int dsi_clk_init(struct msm_dsi_host *msm_host)
 static int dsi_bus_clk_enable(struct msm_dsi_host *msm_host)
 {
 	const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg;
-	int i, ret;
+	int i, j, ret;
 
 	DBG("id=%d", msm_host->id);
 
@@ -437,8 +437,8 @@  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]);
+	for (j = 0; j < i; j++)
+		clk_disable_unprepare(msm_host->bus_clks[j]);
 
 	return ret;
 }