aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/storage_common.c
diff options
context:
space:
mode:
authorMichal Nazarewicz <m.nazarewicz@samsung.com>2009-10-28 11:57:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 14:55:18 -0500
commite909ef5def59236b91fa9ee83446084eb6f48d1a (patch)
tree16ace044a13fac99c58444dd99ffa9a5b1a65aca /drivers/usb/gadget/storage_common.c
parentd6181702f510302dce5666a50344b5acb196ab4e (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/storage_common.c')
-rw-r--r--drivers/usb/gadget/storage_common.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index 19bf1e330dd0..affd23b5436f 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -225,7 +225,10 @@ struct fsg_lun {
225 loff_t file_length; 225 loff_t file_length;
226 loff_t num_sectors; 226 loff_t num_sectors;
227 227
228 unsigned int initially_ro : 1;
228 unsigned int ro : 1; 229 unsigned int ro : 1;
230 unsigned int removable : 1;
231 unsigned int cdrom : 1;
229 unsigned int prevent_medium_removal : 1; 232 unsigned int prevent_medium_removal : 1;
230 unsigned int registered : 1; 233 unsigned int registered : 1;
231 unsigned int info_valid : 1; 234 unsigned int info_valid : 1;
@@ -478,7 +481,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
478 loff_t min_sectors; 481 loff_t min_sectors;
479 482
480 /* R/W if we can, R/O if we must */ 483 /* R/W if we can, R/O if we must */
481 ro = curlun->ro; 484 ro = curlun->initially_ro;
482 if (!ro) { 485 if (!ro) {
483 filp = filp_open(filename, O_RDWR | O_LARGEFILE, 0); 486 filp = filp_open(filename, O_RDWR | O_LARGEFILE, 0);
484 if (-EROFS == PTR_ERR(filp)) 487 if (-EROFS == PTR_ERR(filp))
@@ -521,7 +524,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
521 } 524 }
522 num_sectors = size >> 9; // File size in 512-byte blocks 525 num_sectors = size >> 9; // File size in 512-byte blocks
523 min_sectors = 1; 526 min_sectors = 1;
524 if (mod_data.cdrom) { 527 if (curlun->cdrom) {
525 num_sectors &= ~3; // Reduce to a multiple of 2048 528 num_sectors &= ~3; // Reduce to a multiple of 2048
526 min_sectors = 300*4; // Smallest track is 300 frames 529 min_sectors = 300*4; // Smallest track is 300 frames
527 if (num_sectors >= 256*60*75*4) { 530 if (num_sectors >= 256*60*75*4) {