linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: baruch@tkos.co.il (Baruch Siach)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2] hw_random: add driver for atmel true hardware random number generator
Date: Thu, 6 Oct 2011 22:52:29 +0200	[thread overview]
Message-ID: <20111006205229.GF24034@tarshish> (raw)
In-Reply-To: <87ty7l3l5b.fsf@macbook.be.48ers.dk>

Hi Peter,

On Thu, Oct 06, 2011 at 10:44:32PM +0200, Peter Korsgaard wrote:
> >>>>> "Baruch" == Baruch Siach <baruch@tkos.co.il> writes:
>  >> +static int atmel_trng_read(struct hwrng *rng, void *buf, size_t max,
>  >> +			   bool wait)
>  >> +{
>  >> +	struct atmel_trng *trng = container_of(rng, struct atmel_trng, rng);
>  >> +	u32 *data = buf;
>  >> +
>  >> +	/* data ready? */
>  >> +	if (readl(trng->base + TRNG_ODATA) & 1) {
>  >> +		*data = readl(trng->base + TRNG_ODATA);
>  >> +		return 4;
> 
>  Baruch> Shouldn't you check for max >= 4 before writing to *buf?
> 
> Conceptually, yes. The other hw_random drivers don't seem to do it
> though, and the buffer size is guaranteed to be atleast 32 bytes, 

Ah, you're right, I missed that.

> but I can stick a '&& max >= 4' in the conditional if you prefer.

It probably doesn't worth the trouble, and the little added overhead. Thanks 
for the explanation.

baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

  reply	other threads:[~2011-10-06 20:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-06 17:56 [PATCHv2] hw_random: add driver for atmel true hardware random number generator Peter Korsgaard
2011-10-06 20:30 ` Baruch Siach
2011-10-06 20:44   ` Peter Korsgaard
2011-10-06 20:52     ` Baruch Siach [this message]
2011-10-07  9:21 ` Jamie Iles
2011-10-07  9:53 ` Nicolas Ferre
2011-10-07 18:45   ` 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=20111006205229.GF24034@tarshish \
    --to=baruch@tkos.co.il \
    --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;
as well as URLs for NNTP newsgroup(s).