public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: mpm@selenic.com (Matt Mackall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] arm nomadik: add hardware RNG driver
Date: Thu, 03 Dec 2009 13:50:17 -0600	[thread overview]
Message-ID: <1259869817.29740.1715.camel@calx> (raw)
In-Reply-To: <defe399f8475d30be15ee694eadd45afa9cc64ca.1259840968.git.rubini@unipv.it>

On Thu, 2009-12-03 at 13:04 +0100, Alessandro Rubini wrote:
> From: Alessandro Rubini <rubini@unipv.it>
> 
> The hardware random number generator by ST is used in both the Nomadik
> 8815 SoC and the U8500. It returns 16 bits every 400ns with automatic
> delay if a read is issued too early. It depends on PLAT_NOMADIK.


> +static int nmk_rng_read(struct hwrng *rng, u32 *buffer)
> +{
> +	void __iomem *base = (void __iomem *)rng->priv;
> +	/*
> +	 * We have the low 16 bits as random data. It takes 0.4us to read them
> +	 * so return only one 32-bit sample (minimum allowed).
> +	 * High bits are guaranteed to be 0.
> +	 */
> +	*buffer = __raw_readl(base + 8) << 16 | __raw_readl(base + 8);
> +	return 4;

Please adjust this to use the new read interface we just introduced:

http://git.kernel.org/?p=linux/kernel/git/herbert/cryptodev-2.6.git;a=blobdiff;f=include/linux/hw_random.h;h=9bede7633f745d7c5bd866d2f46df9a51021f92d;hp=7244456e7e6573466f0534857bef00b8b1dbdad7;hb=9996508b3353063f2d6c48c1a28a84543d72d70b;hpb=2f32bfd834d5d7eb230bcbf39aaacccd2a01d767

(sorry for the git URL awesomeness)

This will actually let us do 8 or 16-bit reads, so we can reduce latency
and even slightly simplify your code.

Otherwise, looks fine.

-- 
http://selenic.com : development and support for Mercurial and Linux

      reply	other threads:[~2009-12-03 19:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-03 12:04 [PATCH 1/2] arm nomadik: add hardware RNG driver Alessandro Rubini
2009-12-03 19:50 ` Matt Mackall [this message]

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=1259869817.29740.1715.camel@calx \
    --to=mpm@selenic.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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