Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1223082 > unrolled thread
| Started by | Lee Jones <lee.jones@linaro.org> |
|---|---|
| First post | 2015-09-11 22:20 +0200 |
| Last post | 2015-09-14 09:30 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/6] hwrng: core: Simplify RNG switching from sysfs Lee Jones <lee.jones@linaro.org> - 2015-09-11 22:20 +0200
Re: [PATCH 2/6] hwrng: core: Simplify RNG switching from sysfs Peter Korsgaard <peter@korsgaard.com> - 2015-09-13 16:30 +0200
Re: [PATCH 2/6] hwrng: core: Simplify RNG switching from sysfs Lee Jones <lee.jones@linaro.org> - 2015-09-14 09:30 +0200
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2015-09-11 22:20 +0200 |
| Subject | [PATCH 2/6] hwrng: core: Simplify RNG switching from sysfs |
| Message-ID | <q7CXF-3Ma-15@gated-at.bofh.it> |
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 */
+
+ if (strncmp(rng->name, buf, len - snip) == 0) {
err = 0;
if (rng != current_rng)
err = set_current_rng(rng);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Peter Korsgaard <peter@korsgaard.com> |
|---|---|
| Date | 2015-09-13 16:30 +0200 |
| Message-ID | <q8gs2-1MH-11@gated-at.bofh.it> |
| In reply to | #1223082 |
>>>>> "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?
--
Bye, Peter Korsgaard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2015-09-14 09:30 +0200 |
| Message-ID | <q8wn8-7NZ-9@gated-at.bofh.it> |
| In reply to | #1223679 |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web