From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFA8E26FD84; Fri, 28 Feb 2025 14:37:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740753451; cv=none; b=Gx/GtLg61jpUqgA1sZbsxA2dfkeQ3kv6Ua5gCzFw8XBIVL5KsvbAEkx0XXuBSkURZOqbkOp+hGVYygrzqqxEw9RbvLw7MSjRc9ZyhkkPbqefK5rmUNRSx6cg6WPUkLJTanhY9upzCEKRCEmFUAXCnkJuKT/ixCxKlB+Y2ZgfuB4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740753451; c=relaxed/simple; bh=yMgIGlMHYKOZUSzIfEj56HpFq1oS5jJiBWijR4VLAog=; h=Message-ID:Date:MIME-Version:Subject:To:References:From:Cc: In-Reply-To:Content-Type; b=k4gHhrUzQguQtYwp/ua87YORF1odJ9gYbLgp7NvB3KQSmy7gvLtJ9kQGCn2fQHn1Ni7YpZ8n8GRFOTW2cBXRFK8ghdegsDwyreWB74158S539Fx+Yc/9eWe96yLtTBdUT8nHEEIpJt+n6z6F/fcMdBoMOoJ8ITez0NmocfkLmWQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 567C91515; Fri, 28 Feb 2025 06:37:44 -0800 (PST) Received: from [10.57.79.187] (unknown [10.57.79.187]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1E15E3F6A8; Fri, 28 Feb 2025 06:37:26 -0800 (PST) Message-ID: Date: Fri, 28 Feb 2025 14:37:24 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/4] drivers/thermal/exynos: Refactor clk_sec initialization inside SOC-specific case To: Anand Moon References: <20250216195850.5352-1-linux.amoon@gmail.com> <20250216195850.5352-2-linux.amoon@gmail.com> Content-Language: en-US From: Lukasz Luba Cc: Krzysztof Kozlowski , "open list:SAMSUNG THERMAL DRIVER" , Alim Akhtar , Daniel Lezcano , "Rafael J. Wysocki" , "open list:SAMSUNG THERMAL DRIVER" , Zhang Rui , "moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES" , Bartlomiej Zolnierkiewicz , open list In-Reply-To: <20250216195850.5352-2-linux.amoon@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Anand, On 2/16/25 19:58, Anand Moon wrote: > Refactor the initialization of the clk_sec clock to be inside the > SOC_ARCH_EXYNOS5420_TRIMINFO case. It ensures that the clk_sec clock > is only initialized for the specified SOC and not for other SOCs, > thereby simplifying the code. So IIUC there was no need to init that clock for other types of SoCs... Do we know that for sure (e.g. from other TRMs)? If that was the case, then simplification here can go further, but after some fixes. > > Signed-off-by: Anand Moon > --- > v3: improve the commit message > --- > drivers/thermal/samsung/exynos_tmu.c | 26 +++++++++++++------------- > 1 file changed, 13 insertions(+), 13 deletions(-) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c > index 47a99b3c5395..9c138772d380 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -1040,19 +1040,6 @@ static int exynos_tmu_probe(struct platform_device *pdev) > if (IS_ERR(data->clk)) > return dev_err_probe(dev, PTR_ERR(data->clk), "Failed to get clock\n"); > > - data->clk_sec = devm_clk_get(dev, "tmu_triminfo_apbif"); > - if (IS_ERR(data->clk_sec)) { > - if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) > - return dev_err_probe(dev, PTR_ERR(data->clk_sec), > - "Failed to get triminfo clock\n"); > - } else { > - ret = clk_prepare(data->clk_sec); > - if (ret) { > - dev_err(dev, "Failed to get clock\n"); > - return ret; > - } > - } > - > ret = clk_prepare(data->clk); Here the data->clk is now used in different order. > if (ret) { > dev_err(dev, "Failed to get clock\n"); > @@ -1060,6 +1047,19 @@ static int exynos_tmu_probe(struct platform_device *pdev) > } > > switch (data->soc) { > + case SOC_ARCH_EXYNOS5420_TRIMINFO: > + data->clk_sec = devm_clk_get(dev, "tmu_triminfo_apbif"); > + if (IS_ERR(data->clk_sec)) { > + return dev_err_probe(dev, PTR_ERR(data->clk_sec), > + "Failed to get triminfo clock\n"); Then here you shouldn't simply copy the old code. Now the data->clk is first, so should be 'clk_unprepare()' before return of the function. > + } else { You can get rid of this 'else' above and still be safe in your refactoring. > + ret = clk_prepare(data->clk_sec); > + if (ret) { > + dev_err(dev, "Failed to get clock\n"); > + return ret; > + } Here you can further simplify this to something like: -----------------------8<------------------------------------- + case SOC_ARCH_EXYNOS5420_TRIMINFO: + data->clk_sec = devm_clk_get(dev, "tmu_triminfo_apbif"); + if (IS_ERR(data->clk_sec)) { + clk_unprepare(data->clk); ///// <---- + return dev_err_probe(dev, PTR_ERR(data->clk_sec), + "Failed to get triminfo clock\n"); + } + ret = clk_prepare(data->clk_sec); + if (ret) { + dev_err(dev, "Failed to get clock\n"); + clk_unprepare(data->clk); ///// <---- + return ret; + } + + break; --------------------------->8--------------------------------- Or with better 'goto' flow. > + } > + break; > case SOC_ARCH_EXYNOS5433: > case SOC_ARCH_EXYNOS7: > data->sclk = devm_clk_get(dev, "tmu_sclk"); Also, you should revisit the 'goto' cleanup section at the bottom. Regards, Lukasz