Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Yi Yang <yiyang13@huawei.com>, ulf.hansson@linaro.org
Cc: linux-mmc@vger.kernel.org, Liming Sun <limings@nvidia.com>,
	David Thompson <davthompson@nvidia.com>,
	Shawn Lin <shawn.lin@rock-chips.com>
Subject: Re: [PATCH v2] mmc: sdhci-of-dwcmshc: Use helper function devm_clk_get_enabled()
Date: Thu, 24 Aug 2023 10:42:08 +0300	[thread overview]
Message-ID: <79151ed0-46da-489c-1335-4f0286a6fdf1@intel.com> (raw)
In-Reply-To: <842a0ac5-7eb2-390e-41af-f86e894b3c79@intel.com>

On 24/08/23 10:37, Adrian Hunter wrote:
> On 21/08/23 09:23, Yi Yang wrote:
>> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
>> prepared and enabled clocks"), devm_clk_get() and clk_prepare_enable()
>> can now be replaced by devm_clk_get_enabled() when the driver enables
>> (and possibly prepares) the clocks for the whole lifetime of the device.
>> Moreover, it is no longer necessary to unprepare and disable the clocks
>> explicitly.
>>
>> Signed-off-by: Yi Yang <yiyang13@huawei.com>
>> ---
>> v2: Remove clk_disable_unprepare in dwcmshc_remove()
>> ---
>>  drivers/mmc/host/sdhci-of-dwcmshc.c | 20 ++++++++------------
>>  1 file changed, 8 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c
>> index 31c1892f4ecd..08b566984733 100644
>> --- a/drivers/mmc/host/sdhci-of-dwcmshc.c
>> +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
>> @@ -495,19 +495,19 @@ static int dwcmshc_probe(struct platform_device *pdev)
>>  	priv = sdhci_pltfm_priv(pltfm_host);
>>  
>>  	if (dev->of_node) {
>> -		pltfm_host->clk = devm_clk_get(dev, "core");
>> +		pltfm_host->clk = devm_clk_get_enabled(dev, "core");
>>  		if (IS_ERR(pltfm_host->clk)) {
>>  			err = PTR_ERR(pltfm_host->clk);
>> -			dev_err(dev, "failed to get core clk: %d\n", err);
>> +			dev_err(dev, "failed to get or enable core clk: %d\n", err);
>>  			goto free_pltfm;
>>  		}
>> -		err = clk_prepare_enable(pltfm_host->clk);
>> -		if (err)
>> -			goto free_pltfm;
>>  
>> -		priv->bus_clk = devm_clk_get(dev, "bus");
>> -		if (!IS_ERR(priv->bus_clk))
>> -			clk_prepare_enable(priv->bus_clk);
>> +		priv->bus_clk = devm_clk_get_enabled(dev, "bus");
>> +		if (!IS_ERR(priv->bus_clk)) {
> 
> "!" does not belong, should be "if (IS_ERR(priv->bus_clk))" instead

Although previously it seemed like the clock was optional.
At least the error was not considered fatal.

> 
>> +			err = PTR_ERR(priv->bus_clk);
>> +			dev_err(dev, "failed to get or enable bus clk: %d\n", err);
>> +			goto free_pltfm;
>> +		}
>>  	}
>>  
>>  	err = mmc_of_parse(host->mmc);
>> @@ -564,8 +564,6 @@ static int dwcmshc_probe(struct platform_device *pdev)
>>  err_setup_host:
>>  	sdhci_cleanup_host(host);
>>  err_clk:
>> -	clk_disable_unprepare(pltfm_host->clk);
>> -	clk_disable_unprepare(priv->bus_clk);
>>  	if (rk_priv)
>>  		clk_bulk_disable_unprepare(RK35xx_MAX_CLKS,
>>  					   rk_priv->rockchip_clks);
>> @@ -583,8 +581,6 @@ static void dwcmshc_remove(struct platform_device *pdev)
>>  
>>  	sdhci_remove_host(host, 0);
>>  
>> -	clk_disable_unprepare(pltfm_host->clk);
>> -	clk_disable_unprepare(priv->bus_clk);
>>  	if (rk_priv)
>>  		clk_bulk_disable_unprepare(RK35xx_MAX_CLKS,
>>  					   rk_priv->rockchip_clks);
> 


  reply	other threads:[~2023-08-24  7:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21  6:23 [PATCH v2] mmc: sdhci-of-dwcmshc: Use helper function devm_clk_get_enabled() Yi Yang
2023-08-24  7:37 ` Adrian Hunter
2023-08-24  7:42   ` Adrian Hunter [this message]
2023-08-24  8:06     ` yiyang (D)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=79151ed0-46da-489c-1335-4f0286a6fdf1@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=davthompson@nvidia.com \
    --cc=limings@nvidia.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=ulf.hansson@linaro.org \
    --cc=yiyang13@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox