diff options
author | Michal Nazarewicz <m.nazarewicz@samsung.com> | 2009-10-28 11:57:16 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-11 14:55:18 -0500 |
commit | e909ef5def59236b91fa9ee83446084eb6f48d1a (patch) | |
tree | 16ace044a13fac99c58444dd99ffa9a5b1a65aca /drivers/usb/gadget/file_storage.c | |
parent | d6181702f510302dce5666a50344b5acb196ab4e (diff) |
USB: g_file_storage: per-LUN ro, removable and cdrom flags handling changed
removable and cdrom flag has been added to the fsg_lun structure
removing any references to mod_data object from storage_common.c.
As of read-only flag, previously it was set if a read-only
backing file was specified (which is good) and remained set
even after the file has been closed (which may be considered an
issue). Currently, the initial read-only flag is preserved so
if it was unset each time file is opened code will try to open
it read-write even if previous file was opened read-only.
Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/file_storage.c')
-rw-r--r-- | drivers/usb/gadget/file_storage.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 90233f4f3601..ee712a5715e7 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -3138,7 +3138,9 @@ static ssize_t show_ro(struct device *dev, struct device_attribute *attr, char * | |||
3138 | { | 3138 | { |
3139 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); | 3139 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); |
3140 | 3140 | ||
3141 | return sprintf(buf, "%d\n", curlun->ro); | 3141 | return sprintf(buf, "%d\n", fsg_lun_is_open(curlun) |
3142 | ? curlun->ro | ||
3143 | : curlun->initially_ro); | ||
3142 | } | 3144 | } |
3143 | 3145 | ||
3144 | static ssize_t show_file(struct device *dev, struct device_attribute *attr, | 3146 | static ssize_t show_file(struct device *dev, struct device_attribute *attr, |
@@ -3188,6 +3190,7 @@ static ssize_t store_ro(struct device *dev, struct device_attribute *attr, | |||
3188 | rc = -EBUSY; | 3190 | rc = -EBUSY; |
3189 | } else { | 3191 | } else { |
3190 | curlun->ro = !!i; | 3192 | curlun->ro = !!i; |
3193 | curlun->initially_ro = !!i; | ||
3191 | LDBG(curlun, "read-only status set to %d\n", curlun->ro); | 3194 | LDBG(curlun, "read-only status set to %d\n", curlun->ro); |
3192 | } | 3195 | } |
3193 | up_read(&fsg->filesem); | 3196 | up_read(&fsg->filesem); |
@@ -3433,9 +3436,10 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3433 | 3436 | ||
3434 | for (i = 0; i < fsg->nluns; ++i) { | 3437 | for (i = 0; i < fsg->nluns; ++i) { |
3435 | curlun = &fsg->luns[i]; | 3438 | curlun = &fsg->luns[i]; |
3436 | curlun->ro = mod_data.ro[i]; | 3439 | curlun->cdrom = !!mod_data.cdrom; |
3437 | if (mod_data.cdrom) | 3440 | curlun->ro = mod_data.cdrom || mod_data.ro[i]; |
3438 | curlun->ro = 1; | 3441 | curlun->initially_ro = curlun->ro; |
3442 | curlun->removable = mod_data.removable; | ||
3439 | curlun->dev.release = lun_release; | 3443 | curlun->dev.release = lun_release; |
3440 | curlun->dev.parent = &gadget->dev; | 3444 | curlun->dev.parent = &gadget->dev; |
3441 | curlun->dev.driver = &fsg_driver.driver; | 3445 | curlun->dev.driver = &fsg_driver.driver; |