diff options
author | Andy Shevchenko <andy.shevchenko@gmail.com> | 2010-07-22 04:58:47 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 17:35:42 -0400 |
commit | 8156d158efa6370a8183f47327f122edbb4f2cb6 (patch) | |
tree | 45bde43e18dccb98ab8180c763515c08b825560a /drivers/usb/gadget | |
parent | 787f4e5adaabba01becd646818dbace2d7e6b386 (diff) |
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/169
Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/storage_common.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index a10faecfabcd..3bbddab72e57 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -748,9 +748,9 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr, | |||
748 | ssize_t rc = count; | 748 | ssize_t rc = count; |
749 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); | 749 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); |
750 | struct rw_semaphore *filesem = dev_get_drvdata(dev); | 750 | struct rw_semaphore *filesem = dev_get_drvdata(dev); |
751 | int i; | 751 | unsigned long ro; |
752 | 752 | ||
753 | if (sscanf(buf, "%d", &i) != 1) | 753 | if (strict_strtoul(buf, 2, &ro)) |
754 | return -EINVAL; | 754 | return -EINVAL; |
755 | 755 | ||
756 | /* | 756 | /* |
@@ -762,8 +762,8 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr, | |||
762 | LDBG(curlun, "read-only status change prevented\n"); | 762 | LDBG(curlun, "read-only status change prevented\n"); |
763 | rc = -EBUSY; | 763 | rc = -EBUSY; |
764 | } else { | 764 | } else { |
765 | curlun->ro = !!i; | 765 | curlun->ro = ro; |
766 | curlun->initially_ro = !!i; | 766 | curlun->initially_ro = ro; |
767 | LDBG(curlun, "read-only status set to %d\n", curlun->ro); | 767 | LDBG(curlun, "read-only status set to %d\n", curlun->ro); |
768 | } | 768 | } |
769 | up_read(filesem); | 769 | up_read(filesem); |