mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Martin Kaiser <martin@kaiser.cx>
To: Huan Yang <link@vivo.com>
Cc: "Olivia Mackall" <olivia@selenic.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	opensource.kernel@vivo.com
Subject: Re: [PATCH] char: mxc-rnga: Use devm_clk_get_enabled() helpers
Date: Wed, 21 Aug 2024 08:42:14 +0200	[thread overview]
Message-ID: <ZsWMRn1gPNnrdaRy@akranes.kaiser.cx> (raw)
In-Reply-To: <20240820094715.104998-1-link@vivo.com>

Thus wrote Huan Yang (link@vivo.com):

> The devm_clk_get_enabled() helpers:
>     - call devm_clk_get()
>     - call clk_prepare_enable() and register what is needed in order to
>      call clk_disable_unprepare() when needed, as a managed resource.

> This simplifies the code and avoids the calls to clk_disable_unprepare().

> Signed-off-by: Huan Yang <link@vivo.com>
> ---
>  drivers/char/hw_random/mxc-rnga.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)

> diff --git a/drivers/char/hw_random/mxc-rnga.c b/drivers/char/hw_random/mxc-rnga.c
> index 94ee18a1120a..f01eb95bee31 100644
> --- a/drivers/char/hw_random/mxc-rnga.c
> +++ b/drivers/char/hw_random/mxc-rnga.c
> @@ -147,33 +147,25 @@ static int mxc_rnga_probe(struct platform_device *pdev)
>  	mxc_rng->rng.data_present = mxc_rnga_data_present;
>  	mxc_rng->rng.data_read = mxc_rnga_data_read;

> -	mxc_rng->clk = devm_clk_get(&pdev->dev, NULL);
> +	mxc_rng->clk = devm_clk_get_enabled(&pdev->dev, NULL);
>  	if (IS_ERR(mxc_rng->clk)) {
>  		dev_err(&pdev->dev, "Could not get rng_clk!\n");
>  		return PTR_ERR(mxc_rng->clk);
>  	}

> -	err = clk_prepare_enable(mxc_rng->clk);
> -	if (err)
> -		return err;
> -
>  	mxc_rng->mem = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(mxc_rng->mem)) {
>  		err = PTR_ERR(mxc_rng->mem);
> -		goto err_ioremap;
> +		return err;
>  	}

>  	err = hwrng_register(&mxc_rng->rng);
>  	if (err) {
>  		dev_err(&pdev->dev, "MXC RNGA registering failed (%d)\n", err);
> -		goto err_ioremap;
> +		return err;
>  	}

>  	return 0;
> -
> -err_ioremap:
> -	clk_disable_unprepare(mxc_rng->clk);
> -	return err;
>  }

>  static void mxc_rnga_remove(struct platform_device *pdev)
> @@ -181,8 +173,6 @@ static void mxc_rnga_remove(struct platform_device *pdev)
>  	struct mxc_rng *mxc_rng = platform_get_drvdata(pdev);

>  	hwrng_unregister(&mxc_rng->rng);
> -
> -	clk_disable_unprepare(mxc_rng->clk);
>  }

>  static const struct of_device_id mxc_rnga_of_match[] = {
> -- 
> 2.45.2

looks good to me

Reviewed-by: Martin Kaiser <martin@kaiser.cx>

  reply	other threads:[~2024-08-21  6:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-20  9:47 Huan Yang
2024-08-21  6:42 ` Martin Kaiser [this message]
2024-08-30 10:36 ` Herbert Xu

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=ZsWMRn1gPNnrdaRy@akranes.kaiser.cx \
    --to=martin@kaiser.cx \
    --cc=herbert@gondor.apana.org.au \
    --cc=link@vivo.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olivia@selenic.com \
    --cc=opensource.kernel@vivo.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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

all inboxes | Powered by JetHome®