From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753555AbbINH1K (ORCPT ); Mon, 14 Sep 2015 03:27:10 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:35209 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751553AbbINH1G (ORCPT ); Mon, 14 Sep 2015 03:27:06 -0400 Date: Mon, 14 Sep 2015 08:27:01 +0100 From: Lee Jones To: Peter Korsgaard 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 Message-ID: <20150914072701.GB27591@x1> References: <1442002110-28733-1-git-send-email-lee.jones@linaro.org> <1442002110-28733-3-git-send-email-lee.jones@linaro.org> <87a8sq4ctu.fsf@dell.be.48ers.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87a8sq4ctu.fsf@dell.be.48ers.dk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 13 Sep 2015, Peter Korsgaard wrote: > >>>>> "Lee" == Lee Jones 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 > > --- > > 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