From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752067AbdBZJFq (ORCPT ); Sun, 26 Feb 2017 04:05:46 -0500 Received: from mx02-sz.bfs.de ([194.94.69.103]:43976 "EHLO mx02-sz.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751983AbdBZJFg (ORCPT ); Sun, 26 Feb 2017 04:05:36 -0500 Message-ID: <58B299CA.4060203@bfs.de> Date: Sun, 26 Feb 2017 10:03:06 +0100 From: walter harms Reply-To: wharms@bfs.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.16) Gecko/20101125 SUSE/3.0.11 Thunderbird/3.0.11 MIME-Version: 1.0 To: Christophe JAILLET CC: robdclark@gmail.com, airlied@linux.ie, architt@codeaurora.org, hali@codeaurora.org, yongjun_wei@trendmicro.com.cn, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] drm/msm/dsi: Fix the releasing of resources in error path in 'dsi_bus_clk_enable()' References: <20170226075206.25762-1-christophe.jaillet@wanadoo.fr> In-Reply-To: <20170226075206.25762-1-christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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;jbus_clks[j]); re, wh