devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Peter Korsgaard <peter@korsgaard.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org,
	mpm@selenic.com, kernel@stlinux.com
Subject: Re: [PATCH 2/6] hwrng: core: Simplify RNG switching from sysfs
Date: Mon, 14 Sep 2015 08:27:01 +0100	[thread overview]
Message-ID: <20150914072701.GB27591@x1> (raw)
In-Reply-To: <87a8sq4ctu.fsf@dell.be.48ers.dk>

On Sun, 13 Sep 2015, Peter Korsgaard wrote:

> >>>>> "Lee" == Lee Jones <lee.jones@linaro.org> writes:
> 
>  > If we attempt to use sysfs to change the current RNG in the usual
>  > way i.e. issuing something like:
> 
>  > `echo 8a8a000.rng > /sys/devices/virtual/misc/hw_random/rng_current`
> 
>  > ... it will fail because the code doesn't currently take the '\n'
>  > into consideration.  Well, now it does.
> 
>  > Signed-off-by: Lee Jones <lee.jones@linaro.org>
>  > ---
>  >  drivers/char/hw_random/core.c | 7 ++++++-
>  >  1 file changed, 6 insertions(+), 1 deletion(-)
> 
>  > diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
>  > index da8faf7..14dc984 100644
>  > --- a/drivers/char/hw_random/core.c
>  > +++ b/drivers/char/hw_random/core.c
>  > @@ -316,6 +316,7 @@ static ssize_t hwrng_attr_current_store(struct device *dev,
>  >  					const char *buf, size_t len)
>  >  {
>  >  	int err;
>  > +	int snip = 0;
>  >  	struct hwrng *rng;
>  
>  >  	err = mutex_lock_interruptible(&rng_mutex);
>  > @@ -323,7 +324,11 @@ static ssize_t hwrng_attr_current_store(struct device *dev,
>  >  		return -ERESTARTSYS;
>  >  	err = -ENODEV;
>  >  	list_for_each_entry(rng, &rng_list, list) {
>  > -		if (strcmp(rng->name, buf) == 0) {
>  > +
>  > +		if (buf[len-1] == '\n')
>  > +			snip = 1; /* Snip one character */
>  > +
> 
> How about using sysfs_streq() instead, which is what is done elsewhere?

Perfect.  This is exactly what I'm trying to do, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2015-09-14  7:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11 20:08 [PATCH 0/6] hwrng: Add support for STMicroelectronics' RNG IP Lee Jones
2015-09-11 20:08 ` [PATCH 1/6] Documentation: hw_random: Fix device node name /dev/hw_random => /dev/hwrng Lee Jones
     [not found]   ` <1442002110-28733-2-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-09-14 14:57     ` Kieran Bingham
2015-09-11 20:08 ` [PATCH 2/6] hwrng: core: Simplify RNG switching from sysfs Lee Jones
     [not found]   ` <1442002110-28733-3-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-09-13 14:24     ` Peter Korsgaard
2015-09-14  7:27       ` Lee Jones [this message]
2015-09-11 20:08 ` [PATCH 3/6] hwrng: st: Provide DT bindings for ST's Random Number Generator Lee Jones
2015-09-11 20:08 ` [PATCH 4/6] hwrng: st: Add support for ST's HW " Lee Jones
2015-09-12 22:58   ` Kieran Bingham
2015-09-14  8:04     ` Lee Jones
2015-09-12 23:04   ` Fabio Estevam
2015-09-14  7:42     ` Lee Jones
2015-09-11 20:08 ` [PATCH 5/6] ARM: STi: STiH407: Enable the 2 HW Random Number Generators for STiH4{07,10} Lee Jones
2015-09-11 20:08 ` [PATCH 6/6] MAINTAINERS: Add ST's Random Number Generator to the ST entry Lee Jones

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=20150914072701.GB27591@x1 \
    --to=lee.jones@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=kernel@stlinux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=peter@korsgaard.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).