* [PATCH] usb: gadget: storage_common: use kstrto*()
@ 2011-04-13 22:37 Michal Nazarewicz
2011-04-14 0:40 ` [PATCHv2] " Michal Nazarewicz
2011-04-14 10:29 ` [PATCH] usb: gadget: storage_common: use kstrto*() Sergei Shtylyov
0 siblings, 2 replies; 6+ messages in thread
From: Michal Nazarewicz @ 2011-04-13 22:37 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alan Stern, linux-usb, linux-kernel
This commit replaces the usage of strict_strtoul() (which
became deprecated after commit 33ee3b2e) with kstrtouint().
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
drivers/usb/gadget/storage_common.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
Feel free to ignore the patch.
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index b015561..109635a 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -711,10 +711,11 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
ssize_t rc = count;
struct fsg_lun *curlun = fsg_lun_from_dev(dev);
struct rw_semaphore *filesem = dev_get_drvdata(dev);
- unsigned long ro;
+ unsigned ro;
- if (strict_strtoul(buf, 2, &ro))
- return -EINVAL;
+ rc = kstrtouint(buf, 2, &ro);
+ if (rc)
+ return rc;
/*
* Allow the write-enable status to change only while the
@@ -738,10 +739,12 @@ static ssize_t fsg_store_nofua(struct device *dev,
const char *buf, size_t count)
{
struct fsg_lun *curlun = fsg_lun_from_dev(dev);
- unsigned long nofua;
+ unsigned nofua;
+ int ret;
- if (strict_strtoul(buf, 2, &nofua))
- return -EINVAL;
+ ret = kstrtouint(buf, 2, &nofua);
+ if (ret)
+ return ret;
/* Sync data when switching from async mode to sync */
if (!nofua && curlun->nofua)
--
1.7.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv2] usb: gadget: storage_common: use kstrto*()
2011-04-13 22:37 [PATCH] usb: gadget: storage_common: use kstrto*() Michal Nazarewicz
@ 2011-04-14 0:40 ` Michal Nazarewicz
2011-04-14 2:16 ` Greg KH
2011-04-14 10:29 ` [PATCH] usb: gadget: storage_common: use kstrto*() Sergei Shtylyov
1 sibling, 1 reply; 6+ messages in thread
From: Michal Nazarewicz @ 2011-04-14 0:40 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alan Stern, linux-usb, linux-kernel
This commit replaces the usage of strict_strtoul() (which
became deprecated after commit 33ee3b2e) with kstrtouint().
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
drivers/usb/gadget/storage_common.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
> @@ -711,10 +711,11 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
> ssize_t rc = count;
> struct fsg_lun *curlun = fsg_lun_from_dev(dev);
> struct rw_semaphore *filesem = dev_get_drvdata(dev);
> - unsigned long ro;
> + unsigned ro;
>
> - if (strict_strtoul(buf, 2, &ro))
> - return -EINVAL;
> + rc = kstrtouint(buf, 2, &ro);
> + if (rc)
> + return rc;
>
Sorry, I've just noticed this zeroes the rc so that the function returns
invalid read length. Attached patch has the following delta included:
| @@ -708,7 +708,7 @@ static ssize_t fsg_show_file(struct device *dev, struct devi
| static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
| const char *buf, size_t count)
| {
| - ssize_t rc = count;
| + ssize_t rc;
| struct fsg_lun *curlun = fsg_lun_from_dev(dev);
| struct rw_semaphore *filesem = dev_get_drvdata(dev);
| unsigned ro;
| @@ -729,6 +729,7 @@ static ssize_t fsg_store_ro(struct device *dev, struct devic
| curlun->ro = ro;
| curlun->initially_ro = ro;
| LDBG(curlun, "read-only status set to %d\n", curlun->ro);
| + rc = count;
| }
| up_read(filesem);
| return rc;
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index b015561..1fa4f70 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -708,13 +708,14 @@ static ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr,
static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- ssize_t rc = count;
+ ssize_t rc;
struct fsg_lun *curlun = fsg_lun_from_dev(dev);
struct rw_semaphore *filesem = dev_get_drvdata(dev);
- unsigned long ro;
+ unsigned ro;
- if (strict_strtoul(buf, 2, &ro))
- return -EINVAL;
+ rc = kstrtouint(buf, 2, &ro);
+ if (rc)
+ return rc;
/*
* Allow the write-enable status to change only while the
@@ -728,6 +729,7 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
curlun->ro = ro;
curlun->initially_ro = ro;
LDBG(curlun, "read-only status set to %d\n", curlun->ro);
+ rc = count;
}
up_read(filesem);
return rc;
@@ -738,10 +740,12 @@ static ssize_t fsg_store_nofua(struct device *dev,
const char *buf, size_t count)
{
struct fsg_lun *curlun = fsg_lun_from_dev(dev);
- unsigned long nofua;
+ unsigned nofua;
+ int ret;
- if (strict_strtoul(buf, 2, &nofua))
- return -EINVAL;
+ ret = kstrtouint(buf, 2, &nofua);
+ if (ret)
+ return ret;
/* Sync data when switching from async mode to sync */
if (!nofua && curlun->nofua)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCHv2] usb: gadget: storage_common: use kstrto*()
2011-04-14 0:40 ` [PATCHv2] " Michal Nazarewicz
@ 2011-04-14 2:16 ` Greg KH
2011-04-14 9:55 ` [PATCH] usb: gadget: storage_common: use kstrto*() [bug fix] Michal Nazarewicz
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2011-04-14 2:16 UTC (permalink / raw)
To: Michal Nazarewicz; +Cc: Alan Stern, linux-usb, linux-kernel
On Thu, Apr 14, 2011 at 02:40:39AM +0200, Michal Nazarewicz wrote:
> This commit replaces the usage of strict_strtoul() (which
> became deprecated after commit 33ee3b2e) with kstrtouint().
>
> Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
> ---
> drivers/usb/gadget/storage_common.c | 18 +++++++++++-------
> 1 files changed, 11 insertions(+), 7 deletions(-)
>
> > @@ -711,10 +711,11 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
> > ssize_t rc = count;
> > struct fsg_lun *curlun = fsg_lun_from_dev(dev);
> > struct rw_semaphore *filesem = dev_get_drvdata(dev);
> > - unsigned long ro;
> > + unsigned ro;
> >
> > - if (strict_strtoul(buf, 2, &ro))
> > - return -EINVAL;
> > + rc = kstrtouint(buf, 2, &ro);
> > + if (rc)
> > + return rc;
> >
>
> Sorry, I've just noticed this zeroes the rc so that the function returns
> invalid read length. Attached patch has the following delta included:
Ugh, I applied the first one already :(
Care to send a follow-on patch that fixes this properly?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] usb: gadget: storage_common: use kstrto*() [bug fix]
2011-04-14 2:16 ` Greg KH
@ 2011-04-14 9:55 ` Michal Nazarewicz
0 siblings, 0 replies; 6+ messages in thread
From: Michal Nazarewicz @ 2011-04-14 9:55 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alan Stern, linux-usb, linux-kernel
This commit fixes an embarrassing bug in the "storage_common:
use kstrto*()" patch which caused fsg_store_ro() to return
zero instead of the length of the consumed buffer.
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
drivers/usb/gadget/storage_common.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
On Thu, 14 Apr 2011 04:16:35 +0200, Greg KH <gregkh@suse.de> wrote:
> Ugh, I applied the first one already :(
Yes, I hoped you could quickly replace the patch without anyone
noticing.
> Care to send a follow-on patch that fixes this properly?
Natuarry.
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index 109635a..1fa4f70 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -708,7 +708,7 @@ static ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr,
static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- ssize_t rc = count;
+ ssize_t rc;
struct fsg_lun *curlun = fsg_lun_from_dev(dev);
struct rw_semaphore *filesem = dev_get_drvdata(dev);
unsigned ro;
@@ -729,6 +729,7 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
curlun->ro = ro;
curlun->initially_ro = ro;
LDBG(curlun, "read-only status set to %d\n", curlun->ro);
+ rc = count;
}
up_read(filesem);
return rc;
--
1.7.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: gadget: storage_common: use kstrto*()
2011-04-13 22:37 [PATCH] usb: gadget: storage_common: use kstrto*() Michal Nazarewicz
2011-04-14 0:40 ` [PATCHv2] " Michal Nazarewicz
@ 2011-04-14 10:29 ` Sergei Shtylyov
2011-04-14 10:32 ` Michal Nazarewicz
1 sibling, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2011-04-14 10:29 UTC (permalink / raw)
To: Michal Nazarewicz; +Cc: Greg Kroah-Hartman, Alan Stern, linux-usb, linux-kernel
Hello.
On 14-04-2011 2:37, Michal Nazarewicz wrote:
> This commit replaces the usage of strict_strtoul() (which
> became deprecated after commit 33ee3b2e) with kstrtouint().
Please also specify that commit's summary -- for the human readers.
> Signed-off-by: Michal Nazarewicz<mina86@mina86.com>
WBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: gadget: storage_common: use kstrto*()
2011-04-14 10:29 ` [PATCH] usb: gadget: storage_common: use kstrto*() Sergei Shtylyov
@ 2011-04-14 10:32 ` Michal Nazarewicz
0 siblings, 0 replies; 6+ messages in thread
From: Michal Nazarewicz @ 2011-04-14 10:32 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: Greg Kroah-Hartman, Alan Stern, linux-usb, linux-kernel
> On 14-04-2011 2:37, Michal Nazarewicz wrote:
>> This commit replaces the usage of strict_strtoul() (which
>> became deprecated after commit 33ee3b2e) with kstrtouint().
On Thu, 14 Apr 2011 12:29:47 +0200, Sergei Shtylyov <sshtylyov@mvista.com>
wrote:
> Please also specify that commit's summary -- for the human readers.
Guess it's too late (Greg already pulled the patch). Good point though,
will keep in mind in the future.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +-----<email/xmpp: mnazarewicz@google.com>-----ooO--(_)--Ooo--
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-04-14 10:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-13 22:37 [PATCH] usb: gadget: storage_common: use kstrto*() Michal Nazarewicz
2011-04-14 0:40 ` [PATCHv2] " Michal Nazarewicz
2011-04-14 2:16 ` Greg KH
2011-04-14 9:55 ` [PATCH] usb: gadget: storage_common: use kstrto*() [bug fix] Michal Nazarewicz
2011-04-14 10:29 ` [PATCH] usb: gadget: storage_common: use kstrto*() Sergei Shtylyov
2011-04-14 10:32 ` Michal Nazarewicz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.