lkml.org 
[lkml]   [2011]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCHv2] usb: gadget: storage_common: use kstrto*()
Date
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)

\
 
 \ /
  Last update: 2011-04-14 02:43    [W:0.037 / U:18.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site