[PATCH 04/24] [Storage] Added fsg_lun::removable and fsg_lun::cdrom

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This way, storage_common.c file does not reference mod_data object.

Signed-off-by: Michal Nazarewicz <m.nazarewicz@xxxxxxxxxxx>
---
 drivers/usb/gadget/file_storage.c   |    6 +++---
 drivers/usb/gadget/storage_common.c |    4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index daf732c..9e99f07 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -3449,9 +3449,9 @@ 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->removable = mod_data.removable;
 		curlun->dev.release = lun_release;
 		curlun->dev.parent = &gadget->dev;
 		curlun->dev.driver = &fsg_driver.driver;
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index 597342b..6efb061 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -210,6 +210,8 @@ struct fsg_lun {
 	loff_t		num_sectors;
 
 	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;
@@ -505,7 +507,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) {
-- 
1.6.3.3


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux