Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 174917
b: refs/heads/master
c: e909ef5
h: refs/heads/master
i:
  174915: 19d48f8
v: v3
  • Loading branch information
Michal Nazarewicz authored and Greg Kroah-Hartman committed Dec 11, 2009
1 parent f6a4493 commit 92d25c6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d6181702f510302dce5666a50344b5acb196ab4e
refs/heads/master: e909ef5def59236b91fa9ee83446084eb6f48d1a
12 changes: 8 additions & 4 deletions trunk/drivers/usb/gadget/file_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -3138,7 +3138,9 @@ static ssize_t show_ro(struct device *dev, struct device_attribute *attr, char *
{
struct fsg_lun *curlun = fsg_lun_from_dev(dev);

return sprintf(buf, "%d\n", curlun->ro);
return sprintf(buf, "%d\n", fsg_lun_is_open(curlun)
? curlun->ro
: curlun->initially_ro);
}

static ssize_t show_file(struct device *dev, struct device_attribute *attr,
Expand Down Expand Up @@ -3188,6 +3190,7 @@ static ssize_t store_ro(struct device *dev, struct device_attribute *attr,
rc = -EBUSY;
} else {
curlun->ro = !!i;
curlun->initially_ro = !!i;
LDBG(curlun, "read-only status set to %d\n", curlun->ro);
}
up_read(&fsg->filesem);
Expand Down Expand Up @@ -3433,9 +3436,10 @@ static int __init fsg_bind(struct usb_gadget *gadget)

for (i = 0; i < fsg->nluns; ++i) {
curlun = &fsg->luns[i];
curlun->ro = mod_data.ro[i];
if (mod_data.cdrom)
curlun->ro = 1;
curlun->cdrom = !!mod_data.cdrom;
curlun->ro = mod_data.cdrom || mod_data.ro[i];
curlun->initially_ro = curlun->ro;
curlun->removable = mod_data.removable;
curlun->dev.release = lun_release;
curlun->dev.parent = &gadget->dev;
curlun->dev.driver = &fsg_driver.driver;
Expand Down
7 changes: 5 additions & 2 deletions trunk/drivers/usb/gadget/storage_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ struct fsg_lun {
loff_t file_length;
loff_t num_sectors;

unsigned int initially_ro : 1;
unsigned int ro : 1;
unsigned int removable : 1;
unsigned int cdrom : 1;
unsigned int prevent_medium_removal : 1;
unsigned int registered : 1;
unsigned int info_valid : 1;
Expand Down Expand Up @@ -478,7 +481,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
loff_t min_sectors;

/* R/W if we can, R/O if we must */
ro = curlun->ro;
ro = curlun->initially_ro;
if (!ro) {
filp = filp_open(filename, O_RDWR | O_LARGEFILE, 0);
if (-EROFS == PTR_ERR(filp))
Expand Down Expand Up @@ -521,7 +524,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
}
num_sectors = size >> 9; // File size in 512-byte blocks
min_sectors = 1;
if (mod_data.cdrom) {
if (curlun->cdrom) {
num_sectors &= ~3; // Reduce to a multiple of 2048
min_sectors = 300*4; // Smallest track is 300 frames
if (num_sectors >= 256*60*75*4) {
Expand Down

0 comments on commit 92d25c6

Please sign in to comment.