[PATCH 06/11] [Storage] Parts of the struct msf moved to struct msf_common

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

 



In the final version, many msf structures will refer to a single
msf_common structure and so it is required to move common data
to another object which can be shared.

Signed-off-by: Michal Nazarewicz <mnazarewicz@xxxxxxxxxxx>
---
 drivers/usb/gadget/f_mass_storage.c |  331 ++++++++++++++++++-----------------
 1 files changed, 173 insertions(+), 158 deletions(-)

diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 99bf6af..2a6d754 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -328,14 +328,32 @@ module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO);
 MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk");


+/* Data shared by all the MSF instances. */
+struct msf_common {
+	/* filesem protects: backing files in use */
+	struct rw_semaphore	filesem;
+
+	struct stor_buffhd	*next_buffhd_to_fill;
+	struct stor_buffhd	*next_buffhd_to_drain;
+	struct stor_buffhd	buffhds[STORAGE_NUM_BUFFERS];
+
+	int			cmnd_size;
+	u8			cmnd[MAX_COMMAND_SIZE];
+
+	unsigned int		nluns;
+	unsigned int		lun;
+	struct storage_lun	*luns;
+	struct storage_lun	*curlun;
+};
+
+
 struct msf {
-	/* lock protects: state, all the req_busy's, and cbbuf_cmnd */
+	struct msf_common	*common;
+
+	/* lock protects: state, all the req_busy's */
 	spinlock_t		lock;
 	struct usb_gadget	*gadget;

-	/* filesem protects: backing files in use */
-	struct rw_semaphore	filesem;
-
 	/* reference counting: wait until all LUNs are released */
 	struct kref		ref;

@@ -364,34 +382,24 @@ struct msf {
 	struct usb_ep		*bulk_in;
 	struct usb_ep		*bulk_out;

-	struct stor_buffhd	*next_buffhd_to_fill;
-	struct stor_buffhd	*next_buffhd_to_drain;
-	struct stor_buffhd	buffhds[STORAGE_NUM_BUFFERS];
-
 	int			thread_wakeup_needed;
 	struct completion	thread_notifier;
 	struct task_struct	*thread_task;

-	int			cmnd_size;
-	u8			cmnd[MAX_COMMAND_SIZE];
 	enum stor_data_direction	data_dir;
 	u32			data_size;
 	u32			data_size_from_cmnd;
 	u32			tag;
-	unsigned int		lun;
 	u32			residue;
 	u32			usb_amount_left;

-	unsigned int		nluns;
-	struct storage_lun	*luns;
-	struct storage_lun	*curlun;
 };

 typedef void (*msf_routine_t)(struct msf *);

 static int msf_exception_in_progress(struct msf *msf)
 {
-	return (msf->state > STOR_STATE_IDLE);
+	return msf->state > STOR_STATE_IDLE;
 }

 /* Make bulk-out requests be divisible by the maxpacket size */
@@ -417,7 +425,7 @@ static inline void dump_cdb(struct msf *msf)
 {
 #if defined DUMP_MSGS || !defined VERBOSE_DEBUG
 	print_hex_dump(KERN_DEBUG, "SCSI CDB: ", DUMP_PREFIX_NONE,
-			16, 1, msf->cmnd, msf->cmnd_size, 0);
+		       16, 1, msf->common->cmnd, msf->common->cmnd_size, 0);
 #endif
 }

@@ -700,7 +708,7 @@ static int msf_class_setup_req(struct msf *msf,
 			break;
 		}
 		VSDBG(msf, "get max LUN\n");
-		*(u8 *) req->buf = msf->nluns - 1;
+		*(u8 *) req->buf = msf->common->nluns - 1;
 		value = 1;
 		break;

@@ -934,7 +942,7 @@ static int msf_sleep_thread(struct msf *msf)

 static int msf_do_read(struct msf *msf)
 {
-	struct storage_lun		*curlun = msf->curlun;
+	struct storage_lun		*curlun = msf->common->curlun;
 	u32			lba;
 	struct stor_buffhd	*bh;
 	int			rc;
@@ -946,15 +954,15 @@ static int msf_do_read(struct msf *msf)

 	/* Get the starting Logical Block Address and check that it's
 	 * not too big */
-	if (msf->cmnd[0] == SC_READ_6)
-		lba = get_unaligned_be24(&msf->cmnd[1]);
+	if (msf->common->cmnd[0] == SC_READ_6)
+		lba = get_unaligned_be24(&msf->common->cmnd[1]);
 	else {
-		lba = get_unaligned_be32(&msf->cmnd[2]);
+		lba = get_unaligned_be32(&msf->common->cmnd[2]);

 		/* We allow DPO (Disable Page Out = don't save data in the
 		 * cache) and FUA (Force Unit Access = don't read from the
 		 * cache), but we don't implement them. */
-		if ((msf->cmnd[1] & ~0x18) != 0) {
+		if ((msf->common->cmnd[1] & ~0x18) != 0) {
 			curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 			return -EINVAL;
 		}
@@ -989,7 +997,7 @@ static int msf_do_read(struct msf *msf)
 					partial_page);

 		/* Wait for the next buffer to become available */
-		bh = msf->next_buffhd_to_fill;
+		bh = msf->common->next_buffhd_to_fill;
 		while (bh->state != BUF_STATE_EMPTY) {
 			rc = msf_sleep_thread(msf);
 			if (rc)
@@ -1049,7 +1057,7 @@ static int msf_do_read(struct msf *msf)
 		bh->inreq->zero = 0;
 		msf_start_transfer(msf, msf->bulk_in, bh->inreq,
 				&bh->inreq_busy, &bh->state);
-		msf->next_buffhd_to_fill = bh->next;
+		msf->common->next_buffhd_to_fill = bh->next;
 	}

 	return -EIO;		// No default reply
@@ -1060,7 +1068,7 @@ static int msf_do_read(struct msf *msf)

 static int msf_do_write(struct msf *msf)
 {
-	struct storage_lun		*curlun = msf->curlun;
+	struct storage_lun		*curlun = msf->common->curlun;
 	u32			lba;
 	struct stor_buffhd	*bh;
 	int			get_some_more;
@@ -1081,20 +1089,20 @@ static int msf_do_write(struct msf *msf)

 	/* Get the starting Logical Block Address and check that it's
 	 * not too big */
-	if (msf->cmnd[0] == SC_WRITE_6)
-		lba = get_unaligned_be24(&msf->cmnd[1]);
+	if (msf->common->cmnd[0] == SC_WRITE_6)
+		lba = get_unaligned_be24(&msf->common->cmnd[1]);
 	else {
-		lba = get_unaligned_be32(&msf->cmnd[2]);
+		lba = get_unaligned_be32(&msf->common->cmnd[2]);

 		/* We allow DPO (Disable Page Out = don't save data in the
 		 * cache) and FUA (Force Unit Access = write directly to the
 		 * medium).  We don't implement DPO; we implement FUA by
 		 * performing synchronous output. */
-		if ((msf->cmnd[1] & ~0x18) != 0) {
+		if ((msf->common->cmnd[1] & ~0x18) != 0) {
 			curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 			return -EINVAL;
 		}
-		if (msf->cmnd[1] & 0x08) {	// FUA
+		if (msf->common->cmnd[1] & 0x08) {	// FUA
 			spin_lock(&curlun->filp->f_lock);
 			curlun->filp->f_flags |= O_SYNC;
 			spin_unlock(&curlun->filp->f_lock);
@@ -1113,7 +1121,7 @@ static int msf_do_write(struct msf *msf)
 	while (amount_left_to_write > 0) {

 		/* Queue a request for more data from the host */
-		bh = msf->next_buffhd_to_fill;
+		bh = msf->common->next_buffhd_to_fill;
 		if (bh->state == BUF_STATE_EMPTY && get_some_more) {

 			/* Figure out how much we want to get:
@@ -1164,17 +1172,17 @@ static int msf_do_write(struct msf *msf)
 			bh->outreq->short_not_ok = 1;
 			msf_start_transfer(msf, msf->bulk_out, bh->outreq,
 					&bh->outreq_busy, &bh->state);
-			msf->next_buffhd_to_fill = bh->next;
+			msf->common->next_buffhd_to_fill = bh->next;
 			continue;
 		}

 		/* Write the received data to the backing file */
-		bh = msf->next_buffhd_to_drain;
+		bh = msf->common->next_buffhd_to_drain;
 		if (bh->state == BUF_STATE_EMPTY && !get_some_more)
 			break;			// We stopped early
 		if (bh->state == BUF_STATE_FULL) {
 			smp_rmb();
-			msf->next_buffhd_to_drain = bh->next;
+			msf->common->next_buffhd_to_drain = bh->next;
 			bh->state = BUF_STATE_EMPTY;

 			/* Did something go wrong with the transfer? */
@@ -1249,7 +1257,7 @@ static int msf_do_write(struct msf *msf)

 static int msf_do_synchronize_cache(struct msf *msf)
 {
-	struct storage_lun	*curlun = msf->curlun;
+	struct storage_lun	*curlun = msf->common->curlun;
 	int		rc;

 	/* We ignore the requested LBA and write out all file's
@@ -1275,10 +1283,10 @@ static void msf_invalidate_sub(struct storage_lun *curlun)

 static int msf_do_verify(struct msf *msf)
 {
-	struct storage_lun		*curlun = msf->curlun;
+	struct storage_lun		*curlun = msf->common->curlun;
 	u32			lba;
 	u32			verification_length;
-	struct stor_buffhd	*bh = msf->next_buffhd_to_fill;
+	struct stor_buffhd	*bh = msf->common->next_buffhd_to_fill;
 	loff_t			file_offset, file_offset_tmp;
 	u32			amount_left;
 	unsigned int		amount;
@@ -1286,7 +1294,7 @@ static int msf_do_verify(struct msf *msf)

 	/* Get the starting Logical Block Address and check that it's
 	 * not too big */
-	lba = get_unaligned_be32(&msf->cmnd[2]);
+	lba = get_unaligned_be32(&msf->common->cmnd[2]);
 	if (lba >= curlun->num_sectors) {
 		curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
 		return -EINVAL;
@@ -1294,12 +1302,12 @@ static int msf_do_verify(struct msf *msf)

 	/* We allow DPO (Disable Page Out = don't save data in the
 	 * cache) but we don't implement it. */
-	if ((msf->cmnd[1] & ~0x10) != 0) {
+	if ((msf->common->cmnd[1] & ~0x10) != 0) {
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
 	}

-	verification_length = get_unaligned_be16(&msf->cmnd[7]);
+	verification_length = get_unaligned_be16(&msf->common->cmnd[7]);
 	if (unlikely(verification_length == 0))
 		return -EIO;		// No default reply

@@ -1379,7 +1387,7 @@ static int msf_do_inquiry(struct msf *msf, struct stor_buffhd *bh)
 	static char product_disk_id[] = "File-Stor Gadget";
 	static char product_cdrom_id[] = "File-CD Gadget  ";

-	if (!msf->curlun) {		// Unsupported LUNs are okay
+	if (!msf->common->curlun) {		// Unsupported LUNs are okay
 		msf->bad_lun_okay = 1;
 		memset(buf, 0, 36);
 		buf[0] = 0x7f;		// Unsupported, no device-type
@@ -1405,7 +1413,7 @@ static int msf_do_inquiry(struct msf *msf, struct stor_buffhd *bh)

 static int msf_do_request_sense(struct msf *msf, struct stor_buffhd *bh)
 {
-	struct storage_lun	*curlun = msf->curlun;
+	struct storage_lun	*curlun = msf->common->curlun;
 	u8		*buf = (u8 *) bh->buf;
 	u32		sd, sdinfo;
 	int		valid;
@@ -1459,9 +1467,9 @@ static int msf_do_request_sense(struct msf *msf, struct stor_buffhd *bh)

 static int msf_do_read_capacity(struct msf *msf, struct stor_buffhd *bh)
 {
-	struct storage_lun	*curlun = msf->curlun;
-	u32		lba = get_unaligned_be32(&msf->cmnd[2]);
-	int		pmi = msf->cmnd[8];
+	struct storage_lun	*curlun = msf->common->curlun;
+	u32		lba = get_unaligned_be32(&msf->common->cmnd[2]);
+	int		pmi = msf->common->cmnd[8];
 	u8		*buf = (u8 *) bh->buf;

 	/* Check the PMI and LBA fields */
@@ -1479,11 +1487,11 @@ static int msf_do_read_capacity(struct msf *msf, struct stor_buffhd *bh)

 static int msf_do_read_header(struct msf *msf, struct stor_buffhd *bh)
 {
-	struct storage_lun	*curlun = msf->curlun;
-	u32		lba = get_unaligned_be32(&msf->cmnd[2]);
+	struct storage_lun	*curlun = msf->common->curlun;
+	u32		lba = get_unaligned_be32(&msf->common->cmnd[2]);
 	u8		*buf = (u8 *) bh->buf;

-	if ((msf->cmnd[1] & ~0x02) != 0) {		/* Mask away MSF */
+	if ((msf->common->cmnd[1] & ~0x02) != 0) {		/* Mask away MSF */
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
 	}
@@ -1494,18 +1502,18 @@ static int msf_do_read_header(struct msf *msf, struct stor_buffhd *bh)

 	memset(buf, 0, 8);
 	buf[0] = 0x01;		/* 2048 bytes of user data, rest is EC */
-	store_cdrom_address(&buf[4], msf->cmnd[1] & 0x02 /* MSF */, lba);
+	store_cdrom_address(&buf[4], msf->common->cmnd[1] & 0x02 /* MSF */, lba);
 	return 8;
 }


 static int msf_do_read_toc(struct msf *msf, struct stor_buffhd *bh)
 {
-	struct storage_lun	*curlun = msf->curlun;
-	int		start_track = msf->cmnd[6];
+	struct storage_lun	*curlun = msf->common->curlun;
+	int		start_track = msf->common->cmnd[6];
 	u8		*buf = (u8 *) bh->buf;

-	if ((msf->cmnd[1] & ~0x02) != 0 ||		/* Mask away MSF */
+	if ((msf->common->cmnd[1] & ~0x02) != 0 ||		/* Mask away MSF */
 			start_track > 1) {
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
@@ -1517,11 +1525,11 @@ static int msf_do_read_toc(struct msf *msf, struct stor_buffhd *bh)
 	buf[3] = 1;			/* Last track number */
 	buf[5] = 0x16;			/* Data track, copying allowed */
 	buf[6] = 0x01;			/* Only track is number 1 */
-	store_cdrom_address(&buf[8], msf->cmnd[1] & 0x02 /* MSF */, 0);
+	store_cdrom_address(&buf[8], msf->common->cmnd[1] & 0x02 /* MSF */, 0);

 	buf[13] = 0x16;			/* Lead-out track is data */
 	buf[14] = 0xAA;			/* Lead-out track number */
-	store_cdrom_address(&buf[16], msf->cmnd[1] & 0x02 /* MSF */,
+	store_cdrom_address(&buf[16], msf->common->cmnd[1] & 0x02 /* MSF */,
 			    curlun->num_sectors);
 	return 20;
 }
@@ -1529,8 +1537,8 @@ static int msf_do_read_toc(struct msf *msf, struct stor_buffhd *bh)

 static int msf_do_mode_sense(struct msf *msf, struct stor_buffhd *bh)
 {
-	struct storage_lun	*curlun = msf->curlun;
-	int		mscmnd = msf->cmnd[0];
+	struct storage_lun	*curlun = msf->common->curlun;
+	int		mscmnd = msf->common->cmnd[0];
 	u8		*buf = (u8 *) bh->buf;
 	u8		*buf0 = buf;
 	int		pc, page_code;
@@ -1538,12 +1546,12 @@ static int msf_do_mode_sense(struct msf *msf, struct stor_buffhd *bh)
 	int		valid_page = 0;
 	int		len, limit;

-	if ((msf->cmnd[1] & ~0x08) != 0) {		// Mask away DBD
+	if ((msf->common->cmnd[1] & ~0x08) != 0) {		// Mask away DBD
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
 	}
-	pc = msf->cmnd[2] >> 6;
-	page_code = msf->cmnd[2] & 0x3f;
+	pc = msf->common->cmnd[2] >> 6;
+	page_code = msf->common->cmnd[2] & 0x3f;
 	if (pc == 3) {
 		curlun->sense_data = SS_SAVING_PARAMETERS_NOT_SUPPORTED;
 		return -EINVAL;
@@ -1611,7 +1619,7 @@ static int msf_do_mode_sense(struct msf *msf, struct stor_buffhd *bh)
 static int msf_do_start_stop(struct msf *msf)
 {
 	if (!mod_data.removable) {
-		msf->curlun->sense_data = SS_INVALID_COMMAND;
+		msf->common->curlun->sense_data = SS_INVALID_COMMAND;
 		return -EINVAL;
 	}
 	return 0;
@@ -1620,7 +1628,7 @@ static int msf_do_start_stop(struct msf *msf)

 static int msf_do_prevent_allow(struct msf *msf)
 {
-	struct storage_lun	*curlun = msf->curlun;
+	struct storage_lun	*curlun = msf->common->curlun;
 	int		prevent;

 	if (!mod_data.removable) {
@@ -1628,8 +1636,8 @@ static int msf_do_prevent_allow(struct msf *msf)
 		return -EINVAL;
 	}

-	prevent = msf->cmnd[4] & 0x01;
-	if ((msf->cmnd[4] & ~0x01) != 0) {		// Mask away Prevent
+	prevent = msf->common->cmnd[4] & 0x01;
+	if ((msf->common->cmnd[4] & ~0x01) != 0) {		// Mask away Prevent
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
 	}
@@ -1644,7 +1652,7 @@ static int msf_do_prevent_allow(struct msf *msf)
 static int msf_do_read_format_capacities(struct msf *msf,
 			struct stor_buffhd *bh)
 {
-	struct storage_lun	*curlun = msf->curlun;
+	struct storage_lun	*curlun = msf->common->curlun;
 	u8		*buf = (u8 *) bh->buf;

 	buf[0] = buf[1] = buf[2] = 0;
@@ -1661,7 +1669,7 @@ static int msf_do_read_format_capacities(struct msf *msf,

 static int msf_do_mode_select(struct msf *msf, struct stor_buffhd *bh)
 {
-	struct storage_lun	*curlun = msf->curlun;
+	struct storage_lun	*curlun = msf->common->curlun;

 	/* We don't support MODE SELECT */
 	curlun->sense_data = SS_INVALID_COMMAND;
@@ -1718,7 +1726,7 @@ static int msf_wedge_bulk_in_endpoint(struct msf *msf)

 static int msf_pad_with_zeros(struct msf *msf)
 {
-	struct stor_buffhd	*bh = msf->next_buffhd_to_fill;
+	struct stor_buffhd	*bh = msf->common->next_buffhd_to_fill;
 	u32			nkeep = bh->inreq->length;
 	u32			nsend;
 	int			rc;
@@ -1740,7 +1748,7 @@ static int msf_pad_with_zeros(struct msf *msf)
 		bh->inreq->zero = 0;
 		msf_start_transfer(msf, msf->bulk_in, bh->inreq,
 				&bh->inreq_busy, &bh->state);
-		bh = msf->next_buffhd_to_fill = bh->next;
+		bh = msf->common->next_buffhd_to_fill = bh->next;
 		msf->usb_amount_left -= nsend;
 		nkeep = 0;
 	}
@@ -1753,14 +1761,14 @@ static int msf_throw_away_data(struct msf *msf)
 	u32			amount;
 	int			rc;

-	while ((bh = msf->next_buffhd_to_drain)->state != BUF_STATE_EMPTY ||
+	while ((bh = msf->common->next_buffhd_to_drain)->state != BUF_STATE_EMPTY ||
 			msf->usb_amount_left > 0) {

 		/* Throw away the data in a filled buffer */
 		if (bh->state == BUF_STATE_FULL) {
 			smp_rmb();
 			bh->state = BUF_STATE_EMPTY;
-			msf->next_buffhd_to_drain = bh->next;
+			msf->common->next_buffhd_to_drain = bh->next;

 			/* A short packet or an error ends everything */
 			if (bh->outreq->actual != bh->outreq->length ||
@@ -1772,7 +1780,7 @@ static int msf_throw_away_data(struct msf *msf)
 		}

 		/* Try to submit another request if we need one */
-		bh = msf->next_buffhd_to_fill;
+		bh = msf->common->next_buffhd_to_fill;
 		if (bh->state == BUF_STATE_EMPTY && msf->usb_amount_left > 0) {
 			amount = min(msf->usb_amount_left, STORAGE_BUFLEN);

@@ -1783,7 +1791,7 @@ static int msf_throw_away_data(struct msf *msf)
 			bh->outreq->short_not_ok = 1;
 			msf_start_transfer(msf, msf->bulk_out, bh->outreq,
 					&bh->outreq_busy, &bh->state);
-			msf->next_buffhd_to_fill = bh->next;
+			msf->common->next_buffhd_to_fill = bh->next;
 			msf->usb_amount_left -= amount;
 			continue;
 		}
@@ -1799,7 +1807,7 @@ static int msf_throw_away_data(struct msf *msf)

 static int msf_finish_reply(struct msf *msf)
 {
-	struct stor_buffhd	*bh = msf->next_buffhd_to_fill;
+	struct stor_buffhd	*bh = msf->common->next_buffhd_to_fill;
 	int			rc = 0;

 	switch (msf->data_dir) {
@@ -1827,7 +1835,7 @@ static int msf_finish_reply(struct msf *msf)
 			bh->inreq->zero = 0;
 			msf_start_transfer(msf, msf->bulk_in, bh->inreq,
 					&bh->inreq_busy, &bh->state);
-			msf->next_buffhd_to_fill = bh->next;
+			msf->common->next_buffhd_to_fill = bh->next;

 		/* There is a residue.  For CB and CBI, simply mark the end
 		 * of the data with a short packet.  However, if we are
@@ -1843,7 +1851,7 @@ static int msf_finish_reply(struct msf *msf)
 			bh->inreq->zero = 1;
 			msf_start_transfer(msf, msf->bulk_in, bh->inreq,
 				       &bh->inreq_busy, &bh->state);
-			msf->next_buffhd_to_fill = bh->next;
+			msf->common->next_buffhd_to_fill = bh->next;
 			rc = msf_halt_bulk_in_endpoint(msf);
 		} else {
 			rc = msf_pad_with_zeros(msf);
@@ -1888,7 +1896,7 @@ static int msf_finish_reply(struct msf *msf)

 static int msf_send_status(struct msf *msf)
 {
-	struct storage_lun		*curlun = msf->curlun;
+	struct storage_lun		*curlun = msf->common->curlun;
 	struct stor_bulk_cs_wrap	*csw;
 	struct stor_buffhd	*bh;
 	int			rc;
@@ -1896,7 +1904,7 @@ static int msf_send_status(struct msf *msf)
 	u32			sd, sdinfo = 0;

 	/* Wait for the next buffer to become available */
-	bh = msf->next_buffhd_to_fill;
+	bh = msf->common->next_buffhd_to_fill;
 	while (bh->state != BUF_STATE_EMPTY) {
 		rc = msf_sleep_thread(msf);
 		if (rc)
@@ -1936,7 +1944,7 @@ static int msf_send_status(struct msf *msf)
 	msf_start_transfer(msf, msf->bulk_in, bh->inreq,
 		       &bh->inreq_busy, &bh->state);

-	msf->next_buffhd_to_fill = bh->next;
+	msf->common->next_buffhd_to_fill = bh->next;
 	return 0;
 }

@@ -1950,7 +1958,7 @@ static int msf_check_command(struct msf *msf, int cmnd_size,
 		int needs_medium, const char *name)
 {
 	int			i;
-	int			lun = msf->cmnd[1] >> 5;
+	int			lun = msf->common->cmnd[1] >> 5;
 	static const char	dirletter[4] = {'u', 'o', 'i', 'n'};
 	char			hdlen[20];
 	struct storage_lun		*curlun;
@@ -1961,7 +1969,7 @@ static int msf_check_command(struct msf *msf, int cmnd_size,
 			msf->data_size);
 	VSDBG(msf, "SCSI command: %s;  Dc=%d, D%c=%u;  Hc=%d%s\n",
 	      name, cmnd_size, dirletter[(int) data_dir],
-	      msf->data_size_from_cmnd, msf->cmnd_size, hdlen);
+	      msf->data_size_from_cmnd, msf->common->cmnd_size, hdlen);

 	/* We can't reply at all until we know the correct data direction
 	 * and size. */
@@ -1990,7 +1998,7 @@ static int msf_check_command(struct msf *msf, int cmnd_size,
 	}

 	/* Verify the length of the command itself */
-	if (cmnd_size != msf->cmnd_size) {
+	if (cmnd_size != msf->common->cmnd_size) {

 		/* Special case workaround: There are plenty of buggy SCSI
 		 * implementations. Many have issues with cbw->Length
@@ -2004,11 +2012,11 @@ static int msf_check_command(struct msf *msf, int cmnd_size,
 		 * REQUEST SENSE with cbw->Length == 10 where it should
 		 * be 6 as well.
 		 */
-		if (cmnd_size <= msf->cmnd_size) {
+		if (cmnd_size <= msf->common->cmnd_size) {
 			SDBG(msf, "%s is buggy! Expected length %d "
 			     "but we got %d\n", name,
-			     cmnd_size, msf->cmnd_size);
-			cmnd_size = msf->cmnd_size;
+			     cmnd_size, msf->common->cmnd_size);
+			cmnd_size = msf->common->cmnd_size;
 		} else {
 			msf->phase_error = 1;
 			return -EINVAL;
@@ -2016,27 +2024,27 @@ static int msf_check_command(struct msf *msf, int cmnd_size,
 	}

 	/* Check that the LUN values are consistent */
-	if (msf->lun != lun)
+	if (msf->common->lun != lun)
 		SDBG(msf, "using LUN %d from CBW, not LUN %d from CDB\n",
-		     msf->lun, lun);
+		     msf->common->lun, lun);

 	/* Check the LUN */
-	if (msf->lun >= 0 && msf->lun < msf->nluns) {
-		msf->curlun = curlun = &msf->luns[msf->lun];
-		if (msf->cmnd[0] != SC_REQUEST_SENSE) {
+	if (msf->common->lun >= 0 && msf->common->lun < msf->common->nluns) {
+		msf->common->curlun = curlun = &msf->common->luns[msf->common->lun];
+		if (msf->common->cmnd[0] != SC_REQUEST_SENSE) {
 			curlun->sense_data = SS_NO_SENSE;
 			curlun->sense_data_info = 0;
 			curlun->info_valid = 0;
 		}
 	} else {
-		msf->curlun = curlun = NULL;
+		msf->common->curlun = curlun = NULL;
 		msf->bad_lun_okay = 0;

 		/* INQUIRY and REQUEST SENSE commands are explicitly allowed
 		 * to use unsupported LUNs; all others may not. */
-		if (msf->cmnd[0] != SC_INQUIRY &&
-		    msf->cmnd[0] != SC_REQUEST_SENSE) {
-			SDBG(msf, "unsupported LUN %d\n", msf->lun);
+		if (msf->common->cmnd[0] != SC_INQUIRY &&
+		    msf->common->cmnd[0] != SC_REQUEST_SENSE) {
+			SDBG(msf, "unsupported LUN %d\n", msf->common->lun);
 			return -EINVAL;
 		}
 	}
@@ -2044,17 +2052,17 @@ static int msf_check_command(struct msf *msf, int cmnd_size,
 	/* If a unit attention condition exists, only INQUIRY and
 	 * REQUEST SENSE commands are allowed; anything else must fail. */
 	if (curlun && curlun->unit_attention_data != SS_NO_SENSE &&
-			msf->cmnd[0] != SC_INQUIRY &&
-			msf->cmnd[0] != SC_REQUEST_SENSE) {
+			msf->common->cmnd[0] != SC_INQUIRY &&
+			msf->common->cmnd[0] != SC_REQUEST_SENSE) {
 		curlun->sense_data = curlun->unit_attention_data;
 		curlun->unit_attention_data = SS_NO_SENSE;
 		return -EINVAL;
 	}

 	/* Check that only command bytes listed in the mask are non-zero */
-	msf->cmnd[1] &= 0x1f;			// Mask away the LUN
+	msf->common->cmnd[1] &= 0x1f;			// Mask away the LUN
 	for (i = 1; i < cmnd_size; ++i) {
-		if (msf->cmnd[i] && !(mask & (1 << i))) {
+		if (msf->common->cmnd[i] && !(mask & (1 << i))) {
 			if (curlun)
 				curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 			return -EINVAL;
@@ -2083,7 +2091,7 @@ static int msf_do_scsi_command(struct msf *msf)
 	dump_cdb(msf);

 	/* Wait for the next buffer to become available for data or status */
-	bh = msf->next_buffhd_to_drain = msf->next_buffhd_to_fill;
+	bh = msf->common->next_buffhd_to_drain = msf->common->next_buffhd_to_fill;
 	while (bh->state != BUF_STATE_EMPTY) {
 		rc = msf_sleep_thread(msf);
 		if (rc)
@@ -2092,11 +2100,11 @@ static int msf_do_scsi_command(struct msf *msf)
 	msf->phase_error = 0;
 	msf->short_packet_received = 0;

-	down_read(&msf->filesem);	// We're using the backing file
-	switch (msf->cmnd[0]) {
+	down_read(&msf->common->filesem);	// We're using the backing file
+	switch (msf->common->cmnd[0]) {

 	case SC_INQUIRY:
-		msf->data_size_from_cmnd = msf->cmnd[4];
+		msf->data_size_from_cmnd = msf->common->cmnd[4];
 		if ((reply = msf_check_command(msf, 6, DATA_DIR_TO_HOST,
 				(1<<4), 0,
 				"INQUIRY")) == 0)
@@ -2104,7 +2112,7 @@ static int msf_do_scsi_command(struct msf *msf)
 		break;

 	case SC_MODE_SELECT_6:
-		msf->data_size_from_cmnd = msf->cmnd[4];
+		msf->data_size_from_cmnd = msf->common->cmnd[4];
 		if ((reply = msf_check_command(msf, 6, DATA_DIR_FROM_HOST,
 				(1<<1) | (1<<4), 0,
 				"MODE SELECT(6)")) == 0)
@@ -2112,7 +2120,7 @@ static int msf_do_scsi_command(struct msf *msf)
 		break;

 	case SC_MODE_SELECT_10:
-		msf->data_size_from_cmnd = get_unaligned_be16(&msf->cmnd[7]);
+		msf->data_size_from_cmnd = get_unaligned_be16(&msf->common->cmnd[7]);
 		if ((reply = msf_check_command(msf, 10, DATA_DIR_FROM_HOST,
 				(1<<1) | (3<<7), 0,
 				"MODE SELECT(10)")) == 0)
@@ -2120,7 +2128,7 @@ static int msf_do_scsi_command(struct msf *msf)
 		break;

 	case SC_MODE_SENSE_6:
-		msf->data_size_from_cmnd = msf->cmnd[4];
+		msf->data_size_from_cmnd = msf->common->cmnd[4];
 		if ((reply = msf_check_command(msf, 6, DATA_DIR_TO_HOST,
 				(1<<1) | (1<<2) | (1<<4), 0,
 				"MODE SENSE(6)")) == 0)
@@ -2128,7 +2136,7 @@ static int msf_do_scsi_command(struct msf *msf)
 		break;

 	case SC_MODE_SENSE_10:
-		msf->data_size_from_cmnd = get_unaligned_be16(&msf->cmnd[7]);
+		msf->data_size_from_cmnd = get_unaligned_be16(&msf->common->cmnd[7]);
 		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(1<<1) | (1<<2) | (3<<7), 0,
 				"MODE SENSE(10)")) == 0)
@@ -2144,7 +2152,7 @@ static int msf_do_scsi_command(struct msf *msf)
 		break;

 	case SC_READ_6:
-		i = msf->cmnd[4];
+		i = msf->common->cmnd[4];
 		msf->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
 		if ((reply = msf_check_command(msf, 6, DATA_DIR_TO_HOST,
 				(7<<1) | (1<<4), 1,
@@ -2154,7 +2162,7 @@ static int msf_do_scsi_command(struct msf *msf)

 	case SC_READ_10:
 		msf->data_size_from_cmnd =
-				get_unaligned_be16(&msf->cmnd[7]) << 9;
+				get_unaligned_be16(&msf->common->cmnd[7]) << 9;
 		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(1<<1) | (0xf<<2) | (3<<7), 1,
 				"READ(10)")) == 0)
@@ -2163,7 +2171,7 @@ static int msf_do_scsi_command(struct msf *msf)

 	case SC_READ_12:
 		msf->data_size_from_cmnd =
-				get_unaligned_be32(&msf->cmnd[6]) << 9;
+				get_unaligned_be32(&msf->common->cmnd[6]) << 9;
 		if ((reply = msf_check_command(msf, 12, DATA_DIR_TO_HOST,
 				(1<<1) | (0xf<<2) | (0xf<<6), 1,
 				"READ(12)")) == 0)
@@ -2181,7 +2189,7 @@ static int msf_do_scsi_command(struct msf *msf)
 	case SC_READ_HEADER:
 		if (!mod_data.cdrom)
 			goto unknown_cmnd;
-		msf->data_size_from_cmnd = get_unaligned_be16(&msf->cmnd[7]);
+		msf->data_size_from_cmnd = get_unaligned_be16(&msf->common->cmnd[7]);
 		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(3<<7) | (0x1f<<1), 1,
 				"READ HEADER")) == 0)
@@ -2191,7 +2199,7 @@ static int msf_do_scsi_command(struct msf *msf)
 	case SC_READ_TOC:
 		if (!mod_data.cdrom)
 			goto unknown_cmnd;
-		msf->data_size_from_cmnd = get_unaligned_be16(&msf->cmnd[7]);
+		msf->data_size_from_cmnd = get_unaligned_be16(&msf->common->cmnd[7]);
 		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(7<<6) | (1<<1), 1,
 				"READ TOC")) == 0)
@@ -2199,7 +2207,7 @@ static int msf_do_scsi_command(struct msf *msf)
 		break;

 	case SC_READ_FORMAT_CAPACITIES:
-		msf->data_size_from_cmnd = get_unaligned_be16(&msf->cmnd[7]);
+		msf->data_size_from_cmnd = get_unaligned_be16(&msf->common->cmnd[7]);
 		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(3<<7), 1,
 				"READ FORMAT CAPACITIES")) == 0)
@@ -2207,7 +2215,7 @@ static int msf_do_scsi_command(struct msf *msf)
 		break;

 	case SC_REQUEST_SENSE:
-		msf->data_size_from_cmnd = msf->cmnd[4];
+		msf->data_size_from_cmnd = msf->common->cmnd[4];
 		if ((reply = msf_check_command(msf, 6, DATA_DIR_TO_HOST,
 				(1<<4), 0,
 				"REQUEST SENSE")) == 0)
@@ -2248,7 +2256,7 @@ static int msf_do_scsi_command(struct msf *msf)
 		break;

 	case SC_WRITE_6:
-		i = msf->cmnd[4];
+		i = msf->common->cmnd[4];
 		msf->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
 		if ((reply = msf_check_command(msf, 6, DATA_DIR_FROM_HOST,
 				(7<<1) | (1<<4), 1,
@@ -2258,7 +2266,7 @@ static int msf_do_scsi_command(struct msf *msf)

 	case SC_WRITE_10:
 		msf->data_size_from_cmnd =
-				get_unaligned_be16(&msf->cmnd[7]) << 9;
+				get_unaligned_be16(&msf->common->cmnd[7]) << 9;
 		if ((reply = msf_check_command(msf, 10, DATA_DIR_FROM_HOST,
 				(1<<1) | (0xf<<2) | (3<<7), 1,
 				"WRITE(10)")) == 0)
@@ -2267,7 +2275,7 @@ static int msf_do_scsi_command(struct msf *msf)

 	case SC_WRITE_12:
 		msf->data_size_from_cmnd =
-				get_unaligned_be32(&msf->cmnd[6]) << 9;
+				get_unaligned_be32(&msf->common->cmnd[6]) << 9;
 		if ((reply = msf_check_command(msf, 12, DATA_DIR_FROM_HOST,
 				(1<<1) | (0xf<<2) | (0xf<<6), 1,
 				"WRITE(12)")) == 0)
@@ -2287,15 +2295,15 @@ static int msf_do_scsi_command(struct msf *msf)
 	default:
  unknown_cmnd:
 		msf->data_size_from_cmnd = 0;
-		sprintf(unknown, "Unknown x%02x", msf->cmnd[0]);
-		if ((reply = msf_check_command(msf, msf->cmnd_size,
+		sprintf(unknown, "Unknown x%02x", msf->common->cmnd[0]);
+		if ((reply = msf_check_command(msf, msf->common->cmnd_size,
 				DATA_DIR_UNKNOWN, 0xff, 0, unknown)) == 0) {
-			msf->curlun->sense_data = SS_INVALID_COMMAND;
+			msf->common->curlun->sense_data = SS_INVALID_COMMAND;
 			reply = -EINVAL;
 		}
 		break;
 	}
-	up_read(&msf->filesem);
+	up_read(&msf->common->filesem);

 	if (reply == -EINTR || signal_pending(current))
 		return -EINTR;
@@ -2364,8 +2372,8 @@ static int msf_received_cbw(struct msf *msf, struct stor_buffhd *bh)
 	}

 	/* Save the command for later */
-	msf->cmnd_size = cbw->Length;
-	memcpy(msf->cmnd, cbw->CDB, msf->cmnd_size);
+	msf->common->cmnd_size = cbw->Length;
+	memcpy(msf->common->cmnd, cbw->CDB, msf->common->cmnd_size);
 	if (cbw->Flags & USB_BULK_IN_FLAG)
 		msf->data_dir = DATA_DIR_TO_HOST;
 	else
@@ -2373,7 +2381,7 @@ static int msf_received_cbw(struct msf *msf, struct stor_buffhd *bh)
 	msf->data_size = le32_to_cpu(cbw->DataTransferLength);
 	if (msf->data_size == 0)
 		msf->data_dir = DATA_DIR_NONE;
-	msf->lun = cbw->Lun;
+	msf->common->lun = cbw->Lun;
 	msf->tag = cbw->Tag;
 	return 0;
 }
@@ -2385,7 +2393,7 @@ static int msf_get_next_command(struct msf *msf)
 	int			rc = 0;

 	/* Wait for the next buffer to become available */
-	bh = msf->next_buffhd_to_fill;
+	bh = msf->common->next_buffhd_to_fill;
 	while (bh->state != BUF_STATE_EMPTY) {
 		rc = msf_sleep_thread(msf);
 		if (rc)
@@ -2457,7 +2465,7 @@ static int msf_do_set_interface(struct msf *msf, int altsetting)
 reset:
 	/* Deallocate the requests */
 	for (i = 0; i < STORAGE_NUM_BUFFERS; ++i) {
-		struct stor_buffhd *bh = &msf->buffhds[i];
+		struct stor_buffhd *bh = &msf->common->buffhds[i];

 		if (bh->inreq) {
 			usb_ep_free_request(msf->bulk_in, bh->inreq);
@@ -2501,7 +2509,7 @@ reset:

 	/* Allocate the requests */
 	for (i = 0; i < STORAGE_NUM_BUFFERS; ++i) {
-		struct stor_buffhd	*bh = &msf->buffhds[i];
+		struct stor_buffhd	*bh = &msf->common->buffhds[i];

 		if ((rc = msf_alloc_request(msf, msf->bulk_in, &bh->inreq)) != 0)
 			goto reset;
@@ -2514,8 +2522,8 @@ reset:
 	}

 	msf->running = 1;
-	for (i = 0; i < msf->nluns; ++i)
-		msf->luns[i].unit_attention_data = SS_RESET_OCCURRED;
+	for (i = 0; i < msf->common->nluns; ++i)
+		msf->common->luns[i].unit_attention_data = SS_RESET_OCCURRED;
 	return rc;
 }

@@ -2589,7 +2597,7 @@ static void msf_handle_exception(struct msf *msf)

 	/* Cancel all the pending transfers */
 	for (i = 0; i < STORAGE_NUM_BUFFERS; ++i) {
-		bh = &msf->buffhds[i];
+		bh = &msf->common->buffhds[i];
 		if (bh->inreq_busy)
 			usb_ep_dequeue(msf->bulk_in, bh->inreq);
 		if (bh->outreq_busy)
@@ -2600,7 +2608,7 @@ static void msf_handle_exception(struct msf *msf)
 	for (;;) {
 		int num_active = 0;
 		for (i = 0; i < STORAGE_NUM_BUFFERS; ++i) {
-			bh = &msf->buffhds[i];
+			bh = &msf->common->buffhds[i];
 			num_active += bh->inreq_busy + bh->outreq_busy;
 		}
 		if (num_active == 0)
@@ -2620,11 +2628,11 @@ static void msf_handle_exception(struct msf *msf)
 	spin_lock_irq(&msf->lock);

 	for (i = 0; i < STORAGE_NUM_BUFFERS; ++i) {
-		bh = &msf->buffhds[i];
+		bh = &msf->common->buffhds[i];
 		bh->state = BUF_STATE_EMPTY;
 	}
-	msf->next_buffhd_to_fill = msf->next_buffhd_to_drain =
-			&msf->buffhds[0];
+	msf->common->next_buffhd_to_fill = msf->common->next_buffhd_to_drain =
+			&msf->common->buffhds[0];

 	exception_req_tag = msf->exception_req_tag;
 	new_config = msf->new_config;
@@ -2633,8 +2641,8 @@ static void msf_handle_exception(struct msf *msf)
 	if (old_state == STOR_STATE_ABORT_BULK_OUT)
 		msf->state = STOR_STATE_STATUS_PHASE;
 	else {
-		for (i = 0; i < msf->nluns; ++i) {
-			curlun = &msf->luns[i];
+		for (i = 0; i < msf->common->nluns; ++i) {
+			curlun = &msf->common->luns[i];
 			curlun->prevent_medium_removal = 0;
 			curlun->sense_data = curlun->unit_attention_data =
 					SS_NO_SENSE;
@@ -2671,8 +2679,8 @@ static void msf_handle_exception(struct msf *msf)
 		/* Technically this should go here, but it would only be
 		 * a waste of time.  Ditto for the INTERFACE_CHANGE and
 		 * CONFIG_CHANGE cases. */
-		// for (i = 0; i < msf->nluns; ++i)
-		//	msf->luns[i].unit_attention_data = SS_RESET_OCCURRED;
+		// for (i = 0; i < msf->common->nluns; ++i)
+		//	msf->common->luns[i].unit_attention_data = SS_RESET_OCCURRED;
 		break;

 	case STOR_STATE_INTERFACE_CHANGE:
@@ -2696,8 +2704,8 @@ static void msf_handle_exception(struct msf *msf)
 		break;

 	case STOR_STATE_DISCONNECT:
-		for (i = 0; i < msf->nluns; ++i)
-			stor_lun_fsync_sub(&msf->luns[i]);
+		for (i = 0; i < msf->common->nluns; ++i)
+			stor_lun_fsync_sub(&msf->common->luns[i]);
 		msf_do_set_config(msf, 0);		// Unconfigured state
 		break;

@@ -2801,7 +2809,7 @@ static ssize_t msf_show_file(struct device *dev, struct device_attribute *attr,
 	char		*p;
 	ssize_t		rc;

-	down_read(&msf->filesem);
+	down_read(&msf->common->filesem);
 	if (stor_lun_is_open(curlun)) {	// Get the complete pathname
 		p = d_path(&curlun->filp->f_path, buf, PAGE_SIZE - 1);
 		if (IS_ERR(p))
@@ -2816,7 +2824,7 @@ static ssize_t msf_show_file(struct device *dev, struct device_attribute *attr,
 		*buf = 0;
 		rc = 0;
 	}
-	up_read(&msf->filesem);
+	up_read(&msf->common->filesem);
 	return rc;
 }

@@ -2834,7 +2842,7 @@ static ssize_t msf_store_ro(struct device *dev, struct device_attribute *attr,

 	/* Allow the write-enable status to change only while the backing file
 	 * is closed. */
-	down_read(&msf->filesem);
+	down_read(&msf->common->filesem);
 	if (stor_lun_is_open(curlun)) {
 		LDBG(curlun, "read-only status change prevented\n");
 		rc = -EBUSY;
@@ -2842,7 +2850,7 @@ static ssize_t msf_store_ro(struct device *dev, struct device_attribute *attr,
 		curlun->ro = !!i;
 		LDBG(curlun, "read-only status set to %d\n", curlun->ro);
 	}
-	up_read(&msf->filesem);
+	up_read(&msf->common->filesem);
 	return rc;
 }

@@ -2863,7 +2871,7 @@ static ssize_t msf_store_file(struct device *dev, struct device_attribute *attr,
 		((char *) buf)[count-1] = 0;		// Ugh!

 	/* Eject current medium */
-	down_write(&msf->filesem);
+	down_write(&msf->common->filesem);
 	if (stor_lun_is_open(curlun)) {
 		stor_lun_close(curlun);
 		curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT;
@@ -2876,7 +2884,7 @@ static ssize_t msf_store_file(struct device *dev, struct device_attribute *attr,
 			curlun->unit_attention_data =
 					SS_NOT_READY_TO_READY_TRANSITION;
 	}
-	up_write(&msf->filesem);
+	up_write(&msf->common->filesem);
 	return (rc < 0 ? rc : count);
 }

@@ -2892,7 +2900,7 @@ static void msf_release(struct kref *ref)
 {
 	struct msf	*msf = container_of(ref, struct msf, ref);

-	kfree(msf->luns);
+	kfree(msf->common->luns);
 	kfree(msf);
 }

@@ -2914,8 +2922,8 @@ static void /* __init_or_exit */ msf_unbind(struct usb_gadget *gadget)
 	clear_bit(REGISTERED, &msf->atomic_bitflags);

 	/* Unregister the sysfs attribute files and the LUNs */
-	for (i = 0; i < msf->nluns; ++i) {
-		curlun = &msf->luns[i];
+	for (i = 0; i < msf->common->nluns; ++i) {
+		curlun = &msf->common->luns[i];
 		if (curlun->registered) {
 			device_remove_file(&curlun->dev, &dev_attr_ro);
 			device_remove_file(&curlun->dev, &dev_attr_file);
@@ -2936,7 +2944,7 @@ static void /* __init_or_exit */ msf_unbind(struct usb_gadget *gadget)

 	/* Free the data buffers */
 	for (i = 0; i < STORAGE_NUM_BUFFERS; ++i)
-		kfree(msf->buffhds[i].buf);
+		kfree(msf->common->buffhds[i].buf);

 	/* Free the request and buffer for endpoint 0 */
 	if (req) {
@@ -3017,15 +3025,15 @@ static int __init msf_bind(struct usb_gadget *gadget)

 	/* Create the LUNs, open their backing files, and register the
 	 * LUN devices in sysfs. */
-	msf->luns = kzalloc(i * sizeof(struct storage_lun), GFP_KERNEL);
-	if (!msf->luns) {
+	msf->common->luns = kzalloc(i * sizeof(struct storage_lun), GFP_KERNEL);
+	if (!msf->common->luns) {
 		rc = -ENOMEM;
 		goto out;
 	}
-	msf->nluns = i;
+	msf->common->nluns = i;

-	for (i = 0; i < msf->nluns; ++i) {
-		curlun = &msf->luns[i];
+	for (i = 0; i < msf->common->nluns; ++i) {
+		curlun = &msf->common->luns[i];
 		curlun->cdrom     = mod_data.cdrom;
 		curlun->ro        = mod_data.cdrom || mod_data.ro[i];
 		curlun->removable = mod_data.removable;
@@ -3108,7 +3116,7 @@ static int __init msf_bind(struct usb_gadget *gadget)

 	/* Allocate the data buffers */
 	for (i = 0; i < STORAGE_NUM_BUFFERS; ++i) {
-		struct stor_buffhd	*bh = &msf->buffhds[i];
+		struct stor_buffhd	*bh = &msf->common->buffhds[i];

 		/* Allocate for the bulk-in endpoint.  We assume that
 		 * the buffer will also work with the bulk-out (and
@@ -3118,7 +3126,7 @@ static int __init msf_bind(struct usb_gadget *gadget)
 			goto out;
 		bh->next = bh + 1;
 	}
-	msf->buffhds[STORAGE_NUM_BUFFERS - 1].next = &msf->buffhds[0];
+	msf->common->buffhds[STORAGE_NUM_BUFFERS - 1].next = &msf->common->buffhds[0];

 	/* This should reflect the actual gadget power source */
 	usb_gadget_set_selfpowered(gadget);
@@ -3146,11 +3154,11 @@ static int __init msf_bind(struct usb_gadget *gadget)
 	}

 	SINFO(msf, DRIVER_DESC ", version: " DRIVER_VERSION "\n");
-	SINFO(msf, "Number of LUNs=%d\n", msf->nluns);
+	SINFO(msf, "Number of LUNs=%d\n", msf->common->nluns);

 	pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
-	for (i = 0; i < msf->nluns; ++i) {
-		curlun = &msf->luns[i];
+	for (i = 0; i < msf->common->nluns; ++i) {
+		curlun = &msf->common->luns[i];
 		if (stor_lun_is_open(curlun)) {
 			p = NULL;
 			if (pathbuf) {
@@ -3221,8 +3229,15 @@ static int __init msf_alloc(void)
 	msf = kzalloc(sizeof *msf, GFP_KERNEL);
 	if (!msf)
 		return -ENOMEM;
+
+	msf->common = kzalloc(sizeof *msf->common, GFP_KERNEL);
+	if (!msf->common) {
+		kfree(msf);
+		return -ENOMEM;
+	}
+
 	spin_lock_init(&msf->lock);
-	init_rwsem(&msf->filesem);
+	init_rwsem(&msf->common->filesem);
 	kref_init(&msf->ref);
 	init_completion(&msf->thread_notifier);


--
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