mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Juergen Kilb <J.Kilb@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] Add /dev/urandom device.
Date: Fri, 27 Jul 2012 10:30:58 +0200	[thread overview]
Message-ID: <20120727083058.GB30009@pengutronix.de> (raw)
In-Reply-To: <1342686830-30950-1-git-send-email-J.Kilb@phytec.de>

On Thu, Jul 19, 2012 at 10:33:49AM +0200, Juergen Kilb wrote:
> Nice for testing purposes.

Can we have an extra file with an extra config option for this? I agree
this is nice for debugging, but no need to bloat every build with it.

Sascha

> 
> Signed-off-by: Juergen Kilb <J.Kilb@phytec.de>
> ---
>  commands/stddev.c |   39 +++++++++++++++++++++++++++++++++++++++
>  1 files changed, 39 insertions(+), 0 deletions(-)
> 
> diff --git a/commands/stddev.c b/commands/stddev.c
> index 098aea8..b807df6 100644
> --- a/commands/stddev.c
> +++ b/commands/stddev.c
> @@ -20,7 +20,9 @@
>   */
>  
>  #include <common.h>
> +#include <clock.h>
>  #include <init.h>
> +#include <stdlib.h>
>  
>  static ssize_t zero_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
>  {
> @@ -104,3 +106,40 @@ static int null_init(void)
>  }
>  
>  device_initcall(null_init);
> +
> +static ssize_t urandom_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
> +{
> +	size_t i;
> +	unsigned int *buffer;
> +
> +	buffer = (unsigned int *) buf;
> +
> +	for (i = 0; i < (count / sizeof(size_t)); i++)
> +		buffer[i] = rand() | rand() << 16;
> +
> +	return count;
> +}
> +
> +static struct file_operations urandomops = {
> +	.read  = urandom_read,
> +	.lseek = dev_lseek_default,
> +};
> +
> +static int urandom_init(void)
> +{
> +	struct cdev *cdev;
> +
> +	cdev = xzalloc(sizeof(*cdev));
> +
> +	cdev->name = "urandom";
> +	cdev->size = ~0;
> +	cdev->ops = &urandomops;
> +
> +	devfs_create(cdev);
> +
> +	srand(get_time_ns());
> +
> +	return 0;
> +}
> +
> +device_initcall(urandom_init);
> -- 
> 1.7.0.4
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2012-07-27  8:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19  8:33 Juergen Kilb
2012-07-19  8:33 ` [PATCH] add possibility to mark blocks as bad during write Juergen Kilb
2012-07-19 14:14   ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-27  8:30 ` Sascha Hauer [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=20120727083058.GB30009@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=J.Kilb@phytec.de \
    --cc=barebox@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