Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kamlesh Gurudasani <kamlesh@ti.com>
To: Martin Kaiser <martin@kaiser.cx>,
	Herbert Xu <herbert@gondor.apana.org.au>
Cc: <linux-crypto@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, Martin Kaiser <martin@kaiser.cx>
Subject: Re: [PATCH] hwrng: imx-rngc - add runtime pm
Date: Mon, 27 Jan 2025 22:12:03 +0530	[thread overview]
Message-ID: <87wmegi4ys.fsf@kamlesh.mail-host-address-is-not-set> (raw)
In-Reply-To: <20250118160701.32624-1-martin@kaiser.cx>

Martin Kaiser <martin@kaiser.cx> writes:
...
> @@ -169,7 +178,11 @@ static int imx_rngc_init(struct hwrng *rng)
>  {
>  	struct imx_rngc *rngc = container_of(rng, struct imx_rngc, rng);
>  	u32 cmd, ctrl;
> -	int ret;
> +	int ret, err;
> +
> +	err = pm_runtime_resume_and_get(rngc->dev);
> +	if (err)
> +		return err;
>  
>  	/* clear error */
>  	cmd = readl(rngc->base + RNGC_COMMAND);
> @@ -186,15 +199,15 @@ static int imx_rngc_init(struct hwrng *rng)
>  		ret = wait_for_completion_timeout(&rngc->rng_op_done,
>  						  msecs_to_jiffies(RNGC_SEED_TIMEOUT));
>  		if (!ret) {
> -			ret = -ETIMEDOUT;
> -			goto err;
> +			err = -ETIMEDOUT;
> +			goto out;
>  		}
>  
>  	} while (rngc->err_reg == RNGC_ERROR_STATUS_STAT_ERR);
>  
>  	if (rngc->err_reg) {
> -		ret = -EIO;
> -		goto err;
> +		err = -EIO;
> +		goto out;
>  	}
>  
>  	/*
> @@ -205,23 +218,30 @@ static int imx_rngc_init(struct hwrng *rng)
>  	ctrl |= RNGC_CTRL_AUTO_SEED;
>  	writel(ctrl, rngc->base + RNGC_CONTROL);
>  
> +	err = 0;
is this really needed? The only time control reaches here when err = 0
in below equation
	err = pm_runtime_resume_and_get(rngc->dev);
	if (err)
		return err;

or am I missing something?

Regards,
Kamlesh

> +out:
>  	/*
>  	 * if initialisation was successful, we keep the interrupt
>  	 * unmasked until imx_rngc_cleanup is called
>  	 * we mask the interrupt ourselves if we return an error
>  	 */
> -	return 0;
> +	if (err)
> +		imx_rngc_irq_mask_clear(rngc);
>  
> -err:


  reply	other threads:[~2025-01-27 16:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-18 16:07 [PATCH] hwrng: imx-rngc - add runtime pm Martin Kaiser
2025-01-27 16:42 ` Kamlesh Gurudasani [this message]
2025-02-01 18:39 ` [PATCH v2] " Martin Kaiser
2025-02-09 10:25   ` 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=87wmegi4ys.fsf@kamlesh.mail-host-address-is-not-set \
    --to=kamlesh@ti.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin@kaiser.cx \
    /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