Commit 8156d158 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

usb: gadget: storage: strict coversion of 'ro' parameter

Bring a strict way to get the 'ro' parameter from the user.

The patch followed by this one adds another boolean parameter. To be consistent
Michał Nazarewicz proposed to use simple_strtol() in both cases (correspondend
discussion in LKML [1]). Due to simple_strtol() doesn't return error in a good
way and we have a boolean parameter the strict_strtoul() is used.

[1] http://lkml.org/lkml/2010/7/14/169Signed-off-by: default avatarAndy Shevchenko <ext-andriy.shevchenko@nokia.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 787f4e5a
...@@ -748,9 +748,9 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr, ...@@ -748,9 +748,9 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
ssize_t rc = count; ssize_t rc = count;
struct fsg_lun *curlun = fsg_lun_from_dev(dev); struct fsg_lun *curlun = fsg_lun_from_dev(dev);
struct rw_semaphore *filesem = dev_get_drvdata(dev); struct rw_semaphore *filesem = dev_get_drvdata(dev);
int i; unsigned long ro;
if (sscanf(buf, "%d", &i) != 1) if (strict_strtoul(buf, 2, &ro))
return -EINVAL; return -EINVAL;
/* /*
...@@ -762,8 +762,8 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr, ...@@ -762,8 +762,8 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
LDBG(curlun, "read-only status change prevented\n"); LDBG(curlun, "read-only status change prevented\n");
rc = -EBUSY; rc = -EBUSY;
} else { } else {
curlun->ro = !!i; curlun->ro = ro;
curlun->initially_ro = !!i; curlun->initially_ro = ro;
LDBG(curlun, "read-only status set to %d\n", curlun->ro); LDBG(curlun, "read-only status set to %d\n", curlun->ro);
} }
up_read(filesem); up_read(filesem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment