linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-kernel@vger.kernel.org, Matt Mackall <mpm@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>, Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Eric Anholt <eric@anholt.net>,
	Stefan Wahren <stefan.wahren@i2se.com>,
	PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Harald Freudenberger <freude@linux.vnet.ibm.com>,
	Sean Wang <sean.wang@mediatek.com>,
	Martin Kaiser <martin@kaiser.cx>,
	Steffen Trumtrar <s.trumtrar@pengutronix.de>
Subject: Re: [v2,08/12] hwrng: bcm2835-rng: Abstract I/O accessors
Date: Mon, 13 Nov 2017 01:54:45 -0300	[thread overview]
Message-ID: <720033c0-ccb6-0be1-37b6-c3d38e6174fe@amsat.org> (raw)
In-Reply-To: <20171108004449.32730-9-f.fainelli@gmail.com>

On 11/07/2017 09:44 PM, Florian Fainelli wrote:
> In preparation for allowing BCM63xx to use this driver, we abstract I/O
> accessors such that we can easily change those later on.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> Reviewed-by: Eric Anholt <eric@anholt.net>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  drivers/char/hw_random/bcm2835-rng.c | 27 +++++++++++++++++++--------
>  1 file changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
> index 99b56fd5482c..3a607472687d 100644
> --- a/drivers/char/hw_random/bcm2835-rng.c
> +++ b/drivers/char/hw_random/bcm2835-rng.c
> @@ -42,6 +42,17 @@ static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng)
>  	return container_of(rng, struct bcm2835_rng_priv, rng);
>  }
>  
> +static inline u32 rng_readl(struct bcm2835_rng_priv *priv, u32 offset)
> +{
> +	return readl(priv->base + offset);
> +}
> +
> +static inline void rng_writel(struct bcm2835_rng_priv *priv, u32 val,
> +			      u32 offset)
> +{
> +	writel(val, priv->base + offset);
> +}
> +
>  static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,
>  			       bool wait)
>  {
> @@ -49,18 +60,18 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,
>  	u32 max_words = max / sizeof(u32);
>  	u32 num_words, count;
>  
> -	while ((__raw_readl(priv->base + RNG_STATUS) >> 24) == 0) {
> +	while ((rng_readl(priv, RNG_STATUS) >> 24) == 0) {
>  		if (!wait)
>  			return 0;
>  		cpu_relax();
>  	}
>  
> -	num_words = readl(priv->base + RNG_STATUS) >> 24;
> +	num_words = rng_readl(priv, RNG_STATUS) >> 24;
>  	if (num_words > max_words)
>  		num_words = max_words;
>  
>  	for (count = 0; count < num_words; count++)
> -		((u32 *)buf)[count] = readl(priv->base + RNG_DATA);
> +		((u32 *)buf)[count] = rng_readl(priv, RNG_DATA);
>  
>  	return num_words * sizeof(u32);
>  }
> @@ -79,14 +90,14 @@ static int bcm2835_rng_init(struct hwrng *rng)
>  
>  	if (priv->mask_interrupts) {
>  		/* mask the interrupt */
> -		val = readl(priv->base + RNG_INT_MASK);
> +		val = rng_readl(priv, RNG_INT_MASK);
>  		val |= RNG_INT_OFF;
> -		writel(val, priv->base + RNG_INT_MASK);
> +		rng_writel(priv, val, RNG_INT_MASK);
>  	}
>  
>  	/* set warm-up count & enable */
> -	__raw_writel(RNG_WARMUP_COUNT, priv->base + RNG_STATUS);
> -	__raw_writel(RNG_RBGEN, priv->base + RNG_CTRL);
> +	rng_writel(priv, RNG_WARMUP_COUNT, RNG_STATUS);
> +	rng_writel(priv, RNG_RBGEN, RNG_CTRL);
>  
>  	return ret;
>  }
> @@ -96,7 +107,7 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)
>  	struct bcm2835_rng_priv *priv = to_rng_priv(rng);
>  
>  	/* disable rng hardware */
> -	__raw_writel(0, priv->base + RNG_CTRL);
> +	rng_writel(priv, 0, RNG_CTRL);
>  
>  	if (!IS_ERR(priv->clk))
>  		clk_disable_unprepare(priv->clk);
> 
> 

  parent reply	other threads:[~2017-11-13  4:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08  0:44 [PATCH v2 00/12] bcm63xx-rng conversion to bcm2835-rng Florian Fainelli
2017-11-08  0:44 ` [PATCH v2 01/12] hwrng: bcm2835-rng: Obtain base register via resource Florian Fainelli
2017-11-29  6:30   ` [v2,01/12] hwrng: bcm2835 - " Herbert Xu
2017-11-29 17:38     ` Florian Fainelli
2017-11-30  7:14       ` Herbert Xu
2017-11-08  0:44 ` [PATCH v2 02/12] hwrng: bcm2835-rng: Define a driver private context Florian Fainelli
2017-11-08 18:22   ` Eric Anholt
2017-11-08  0:44 ` [PATCH v2 03/12] hwrng: bcm2835-rng: Move enabling to hwrng::init Florian Fainelli
2017-11-08  0:44 ` [PATCH v2 04/12] hwrng: bcm2835-rng: Implementation cleanup callback Florian Fainelli
2017-11-08  0:44 ` [PATCH v2 05/12] hwrng: bcm2835-rng: Use device managed helpers Florian Fainelli
2017-11-08 18:24   ` Eric Anholt
2017-11-08  0:44 ` [PATCH v2 06/12] hwrng: bcm2835-rng: Rework interrupt masking Florian Fainelli
2017-11-08 18:26   ` Eric Anholt
2017-11-08 18:46   ` Stefan Wahren
2017-11-08 20:41     ` Eric Anholt
2017-11-08  0:44 ` [PATCH v2 07/12] hwrng: bcm2835-rng: Manage an optional clock Florian Fainelli
2017-11-08 18:31   ` Eric Anholt
2017-11-08 19:19   ` Stefan Wahren
2017-11-08 19:23     ` Russell King - ARM Linux
2017-11-08  0:44 ` [PATCH v2 08/12] hwrng: bcm2835-rng: Abstract I/O accessors Florian Fainelli
2017-11-08 18:33   ` Eric Anholt
2017-11-13  4:54   ` Philippe Mathieu-Daudé [this message]
2017-11-08  0:44 ` [PATCH v2 09/12] hwrng: bcm2835-rng: Add Broadcom MIPS " Florian Fainelli
2017-11-08  0:44 ` [PATCH v2 10/12] dt-bindings: rng: Incorporate brcm,bcm6368.txt binding Florian Fainelli
2017-11-08  0:44 ` [PATCH v2 11/12] hwrng: bcm2835-rng: Enable BCM2835 RNG to work on BCM63xx platforms Florian Fainelli
2017-11-08  0:44 ` [PATCH v2 12/12] hwrng: bcm63xx-rng: Remove since bcm2835-rng takes over Florian Fainelli
2017-11-08 18:36   ` Eric Anholt

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=720033c0-ccb6-0be1-37b6-c3d38e6174fe@amsat.org \
    --to=f4bug@amsat.org \
    --cc=eric@anholt.net \
    --cc=f.fainelli@gmail.com \
    --cc=freude@linux.vnet.ibm.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=martin@kaiser.cx \
    --cc=mpm@selenic.com \
    --cc=prasannatsmkumar@gmail.com \
    --cc=rjui@broadcom.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=robh+dt@kernel.org \
    --cc=s.trumtrar@pengutronix.de \
    --cc=sbranden@broadcom.com \
    --cc=sean.wang@mediatek.com \
    --cc=stefan.wahren@i2se.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;
as well as URLs for NNTP newsgroup(s).