[PATCH 05/11] [Storage] Uses msf prefix throughout the file

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

 



All the fsg prefixes have been replaced with msf.  Moreover, functions
which lacked prefix gained msf prefix.  This change has been made as
to prevent any possible name collisions when Mass Storage Function
is used with other composite functions.

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

diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 2841e7c..99bf6af 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -148,16 +148,16 @@
  * an EXIT exception.
  *
  * In normal operation the main thread is started during the gadget's
- * fsg_bind() callback and stopped during fsg_unbind().  But it can also
+ * msf_bind() callback and stopped during msf_unbind().  But it can also
  * exit when it receives a signal, and there's no point leaving the
  * gadget running when the thread is dead.  So just before the thread
  * exits, it deregisters the gadget driver.  This makes things a little
  * tricky: The driver is deregistered at two places, and the exiting
- * thread can indirectly call fsg_unbind() which in turn can tell the
+ * thread can indirectly call msf_unbind() which in turn can tell the
  * thread to exit.  The first problem is resolved through the use of the
  * REGISTERED atomic bitflag; the driver will only be deregistered once.
- * The second problem is resolved by having fsg_unbind() check
- * fsg->state; it won't try to stop the thread if the state is already
+ * The second problem is resolved by having msf_unbind() check
+ * msf->state; it won't try to stop the thread if the state is already
  * STOR_STATE_TERMINATED.
  *
  * To provide maximum throughput, the driver uses a circular pipeline of
@@ -171,7 +171,7 @@
  * variables.
  *
  * Use of the pipeline follows a simple protocol.  There is a variable
- * (fsg->next_buffhd_to_fill) that points to the next buffer head to use.
+ * (msf->next_buffhd_to_fill) that points to the next buffer head to use.
  * At any time that buffer head may still be in use from an earlier
  * request, so each buffer head has a state variable indicating whether
  * it is EMPTY, FULL, or BUSY.  Typical use involves waiting for the
@@ -328,7 +328,7 @@ module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO);
 MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk");


-struct fsg_dev {
+struct msf {
 	/* lock protects: state, all the req_busy's, and cbbuf_cmnd */
 	spinlock_t		lock;
 	struct usb_gadget	*gadget;
@@ -387,52 +387,52 @@ struct fsg_dev {
 	struct storage_lun	*curlun;
 };

-typedef void (*fsg_routine_t)(struct fsg_dev *);
+typedef void (*msf_routine_t)(struct msf *);

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

 /* Make bulk-out requests be divisible by the maxpacket size */
-static void set_bulk_out_req_length(struct fsg_dev *fsg,
+static void msf_set_bulk_out_req_length(struct msf *msf,
 		struct stor_buffhd *bh, unsigned int length)
 {
 	unsigned int	rem;

 	bh->bulk_out_intended_length = length;
-	rem = length % fsg->bulk_out_maxpacket;
+	rem = length % msf->bulk_out_maxpacket;
 	if (rem > 0)
-		length += fsg->bulk_out_maxpacket - rem;
+		length += msf->bulk_out_maxpacket - rem;
 	bh->outreq->length = length;
 }

-static struct fsg_dev			*the_fsg;
-static struct usb_gadget_driver		fsg_driver;
+static struct msf			*the_msf;
+static struct usb_gadget_driver		msf_driver;


 /*-------------------------------------------------------------------------*/

-static inline void dump_cdb(struct fsg_dev *fsg)
+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, fsg->cmnd, fsg->cmnd_size, 0);
+			16, 1, msf->cmnd, msf->cmnd_size, 0);
 #endif
 }


-static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
+static int msf_set_halt(struct msf *msf, struct usb_ep *ep)
 {
 	const char	*name;

-	if (ep == fsg->bulk_in)
+	if (ep == msf->bulk_in)
 		name = "bulk-in";
-	else if (ep == fsg->bulk_out)
+	else if (ep == msf->bulk_out)
 		name = "bulk-out";
 	else
 		name = ep->name;
-	SDBG(fsg, "%s set halt\n", name);
+	SDBG(msf, "%s set halt\n", name);
 	return usb_ep_set_halt(ep);
 }

@@ -442,7 +442,7 @@ static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
 /*
  * DESCRIPTORS ... most are static, but strings and (full) configuration
  * descriptors are built on demand.  Also the (static) config and interface
- * descriptors are adjusted during fsg_bind().
+ * descriptors are adjusted during msf_bind().
  */

 /* Some of the descriptors are defined in storage_common.c file. */
@@ -501,7 +501,7 @@ dev_qualifier = {
  * and with code managing interfaces and their altsettings.  They must
  * also handle different speeds and other-speed requests.
  */
-static int populate_config_buf(struct usb_gadget *gadget,
+static int msf_populate_config_buf(struct usb_gadget *gadget,
 		u8 *buf, u8 type, unsigned index)
 {
 	enum usb_device_speed			speed = gadget->speed;
@@ -532,32 +532,32 @@ static int populate_config_buf(struct usb_gadget *gadget,

 /* These routines may be called in process context or in_irq */

-/* Caller must hold fsg->lock */
-static void wakeup_thread(struct fsg_dev *fsg)
+/* Caller must hold msf->lock */
+static void msf_wakeup_thread(struct msf *msf)
 {
 	/* Tell the main thread that something has happened */
-	fsg->thread_wakeup_needed = 1;
-	if (fsg->thread_task)
-		wake_up_process(fsg->thread_task);
+	msf->thread_wakeup_needed = 1;
+	if (msf->thread_task)
+		wake_up_process(msf->thread_task);
 }


-static void raise_exception(struct fsg_dev *fsg, enum stor_state new_state)
+static void msf_raise_exception(struct msf *msf, enum stor_state new_state)
 {
 	unsigned long		flags;

 	/* Do nothing if a higher-priority exception is already in progress.
 	 * If a lower-or-equal priority exception is in progress, preempt it
 	 * and notify the main thread by sending it a signal. */
-	spin_lock_irqsave(&fsg->lock, flags);
-	if (fsg->state <= new_state) {
-		fsg->exception_req_tag = fsg->ep0_req_tag;
-		fsg->state = new_state;
-		if (fsg->thread_task)
+	spin_lock_irqsave(&msf->lock, flags);
+	if (msf->state <= new_state) {
+		msf->exception_req_tag = msf->ep0_req_tag;
+		msf->state = new_state;
+		if (msf->thread_task)
 			send_sig_info(SIGUSR1, SEND_SIG_FORCED,
-					fsg->thread_task);
+					msf->thread_task);
 	}
-	spin_unlock_irqrestore(&fsg->lock, flags);
+	spin_unlock_irqrestore(&msf->lock, flags);
 }


@@ -568,43 +568,43 @@ static void raise_exception(struct fsg_dev *fsg, enum stor_state new_state)
  * completion of various requests: set config, set interface, and
  * Bulk-only device reset. */

-static void fsg_disconnect(struct usb_gadget *gadget)
+static void msf_disconnect(struct usb_gadget *gadget)
 {
-	struct fsg_dev		*fsg = get_gadget_data(gadget);
+	struct msf		*msf = get_gadget_data(gadget);

-	SDBG(fsg, "disconnect or port reset\n");
-	raise_exception(fsg, STOR_STATE_DISCONNECT);
+	SDBG(msf, "disconnect or port reset\n");
+	msf_raise_exception(msf, STOR_STATE_DISCONNECT);
 }


-static int ep0_queue(struct fsg_dev *fsg)
+static int msf_ep0_queue(struct msf *msf)
 {
 	int	rc;

-	rc = usb_ep_queue(fsg->ep0, fsg->ep0req, GFP_ATOMIC);
+	rc = usb_ep_queue(msf->ep0, msf->ep0req, GFP_ATOMIC);
 	if (rc != 0 && rc != -ESHUTDOWN) {

 		/* We can't do much more than wait for a reset */
-		SWARN(fsg, "error in submission: %s --> %d\n",
-		      fsg->ep0->name, rc);
+		SWARN(msf, "error in submission: %s --> %d\n",
+		      msf->ep0->name, rc);
 	}
 	return rc;
 }

-static void ep0_complete(struct usb_ep *ep, struct usb_request *req)
+static void msf_ep0_complete(struct usb_ep *ep, struct usb_request *req)
 {
-	struct fsg_dev		*fsg = ep->driver_data;
+	struct msf		*msf = ep->driver_data;

 	if (req->actual > 0)
-		dump_msg(fsg, fsg->ep0req_name, req->buf, req->actual);
+		dump_msg(msf, msf->ep0req_name, req->buf, req->actual);
 	if (req->status || req->actual != req->length)
-		SDBG(fsg, "%s --> %d, %u/%u\n", __func__,
+		SDBG(msf, "%s --> %d, %u/%u\n", __func__,
 		     req->status, req->actual, req->length);
 	if (req->status == -ECONNRESET)		// Request was cancelled
 		usb_ep_fifo_flush(ep);

 	if (req->status == 0 && req->context)
-		((fsg_routine_t) (req->context))(fsg);
+		((msf_routine_t) (req->context))(msf);
 }


@@ -613,34 +613,34 @@ static void ep0_complete(struct usb_ep *ep, struct usb_request *req)
 /* Bulk and interrupt endpoint completion handlers.
  * These always run in_irq. */

-static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req)
+static void msf_bulk_in_complete(struct usb_ep *ep, struct usb_request *req)
 {
-	struct fsg_dev		*fsg = ep->driver_data;
+	struct msf		*msf = ep->driver_data;
 	struct stor_buffhd	*bh = req->context;

 	if (req->status || req->actual != req->length)
-		SDBG(fsg, "%s --> %d, %u/%u\n", __func__,
+		SDBG(msf, "%s --> %d, %u/%u\n", __func__,
 		     req->status, req->actual, req->length);
 	if (req->status == -ECONNRESET)		// Request was cancelled
 		usb_ep_fifo_flush(ep);

 	/* Hold the lock while we update the request and buffer states */
 	smp_wmb();
-	spin_lock(&fsg->lock);
+	spin_lock(&msf->lock);
 	bh->inreq_busy = 0;
 	bh->state = BUF_STATE_EMPTY;
-	wakeup_thread(fsg);
-	spin_unlock(&fsg->lock);
+	msf_wakeup_thread(msf);
+	spin_unlock(&msf->lock);
 }

-static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
+static void msf_bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
 {
-	struct fsg_dev		*fsg = ep->driver_data;
+	struct msf		*msf = ep->driver_data;
 	struct stor_buffhd	*bh = req->context;

-	dump_msg(fsg, "bulk-out", req->buf, req->actual);
+	dump_msg(msf, "bulk-out", req->buf, req->actual);
 	if (req->status || req->actual != bh->bulk_out_intended_length)
-		SDBG(fsg, "%s --> %d, %u/%u\n", __func__,
+		SDBG(msf, "%s --> %d, %u/%u\n", __func__,
 		     req->status, req->actual,
 		     bh->bulk_out_intended_length);
 	if (req->status == -ECONNRESET)		// Request was cancelled
@@ -648,11 +648,11 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)

 	/* Hold the lock while we update the request and buffer states */
 	smp_wmb();
-	spin_lock(&fsg->lock);
+	spin_lock(&msf->lock);
 	bh->outreq_busy = 0;
 	bh->state = BUF_STATE_FULL;
-	wakeup_thread(fsg);
-	spin_unlock(&fsg->lock);
+	msf_wakeup_thread(msf);
+	spin_unlock(&msf->lock);
 }


@@ -660,16 +660,16 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)

 /* Ep0 class-specific handlers.  These always run in_irq. */

-static int class_setup_req(struct fsg_dev *fsg,
+static int msf_class_setup_req(struct msf *msf,
 			   const struct usb_ctrlrequest *ctrl)
 {
-	struct usb_request	*req = fsg->ep0req;
+	struct usb_request	*req = msf->ep0req;
 	int			value;
 	u16			w_index = le16_to_cpu(ctrl->wIndex);
 	u16			w_value = le16_to_cpu(ctrl->wValue);
 	u16			w_length = le16_to_cpu(ctrl->wLength);

-	if (!fsg->config)
+	if (!msf->config)
 		return -EOPNOTSUPP;

 	/* Handle Bulk-only class-specific requests */
@@ -686,8 +686,8 @@ static int class_setup_req(struct fsg_dev *fsg,

 		/* Raise an exception to stop the current operation
 		 * and reinitialize our state. */
-		SDBG(fsg, "bulk reset request\n");
-		raise_exception(fsg, STOR_STATE_RESET);
+		SDBG(msf, "bulk reset request\n");
+		msf_raise_exception(msf, STOR_STATE_RESET);
 		value = DELAYED_STATUS;
 		break;

@@ -699,14 +699,14 @@ static int class_setup_req(struct fsg_dev *fsg,
 			value = -EDOM;
 			break;
 		}
-		VSDBG(fsg, "get max LUN\n");
-		*(u8 *) req->buf = fsg->nluns - 1;
+		VSDBG(msf, "get max LUN\n");
+		*(u8 *) req->buf = msf->nluns - 1;
 		value = 1;
 		break;

 	default:
 eopnotsupp:
-		VSDBG(fsg,
+		VSDBG(msf,
 		      "unknown class-specific control req "
 		      "%02x.%02x v%04x i%04x l%u\n",
 		      ctrl->bRequestType, ctrl->bRequest,
@@ -722,10 +722,10 @@ eopnotsupp:

 /* Ep0 standard request handlers.  These always run in_irq. */

-static int standard_setup_req(struct fsg_dev *fsg,
+static int msf_standard_setup_req(struct msf *msf,
 		const struct usb_ctrlrequest *ctrl)
 {
-	struct usb_request	*req = fsg->ep0req;
+	struct usb_request	*req = msf->ep0req;
 	int			value = -EOPNOTSUPP;
 	u16			w_index = le16_to_cpu(ctrl->wIndex);
 	u16			w_value = le16_to_cpu(ctrl->wValue);
@@ -741,34 +741,34 @@ static int standard_setup_req(struct fsg_dev *fsg,
 		switch (w_value >> 8) {

 		case USB_DT_DEVICE:
-			VSDBG(fsg, "get device descriptor\n");
+			VSDBG(msf, "get device descriptor\n");
 			value = sizeof device_desc;
 			memcpy(req->buf, &device_desc, value);
 			break;
 		case USB_DT_DEVICE_QUALIFIER:
-			VSDBG(fsg, "get device qualifier\n");
-			if (!gadget_is_dualspeed(fsg->gadget))
+			VSDBG(msf, "get device qualifier\n");
+			if (!gadget_is_dualspeed(msf->gadget))
 				break;
 			value = sizeof dev_qualifier;
 			memcpy(req->buf, &dev_qualifier, value);
 			break;

 		case USB_DT_OTHER_SPEED_CONFIG:
-			VSDBG(fsg, "get other-speed config descriptor\n");
-			if (!gadget_is_dualspeed(fsg->gadget))
+			VSDBG(msf, "get other-speed config descriptor\n");
+			if (!gadget_is_dualspeed(msf->gadget))
 				break;
 			goto get_config;
 		case USB_DT_CONFIG:
-			VSDBG(fsg, "get configuration descriptor\n");
+			VSDBG(msf, "get configuration descriptor\n");
 get_config:
-			value = populate_config_buf(fsg->gadget,
+			value = msf_populate_config_buf(msf->gadget,
 					req->buf,
 					w_value >> 8,
 					w_value & 0xff);
 			break;

 		case USB_DT_STRING:
-			VSDBG(fsg, "get string descriptor\n");
+			VSDBG(msf, "get string descriptor\n");

 			/* wIndex == language code */
 			value = usb_gadget_get_string(&stor_stringtab,
@@ -782,13 +782,13 @@ get_config:
 		if (ctrl->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD |
 				USB_RECIP_DEVICE))
 			break;
-		VSDBG(fsg, "set configuration\n");
+		VSDBG(msf, "set configuration\n");
 		if (w_value == CONFIG_VALUE || w_value == 0) {
-			fsg->new_config = w_value;
+			msf->new_config = w_value;

 			/* Raise an exception to wipe out previous transaction
 			 * state (queued bufs, etc) and set the new config. */
-			raise_exception(fsg, STOR_STATE_CONFIG_CHANGE);
+			msf_raise_exception(msf, STOR_STATE_CONFIG_CHANGE);
 			value = DELAYED_STATUS;
 		}
 		break;
@@ -796,8 +796,8 @@ get_config:
 		if (ctrl->bRequestType != (USB_DIR_IN | USB_TYPE_STANDARD |
 				USB_RECIP_DEVICE))
 			break;
-		VSDBG(fsg, "get configuration\n");
-		*(u8 *) req->buf = fsg->config;
+		VSDBG(msf, "get configuration\n");
+		*(u8 *) req->buf = msf->config;
 		value = 1;
 		break;

@@ -805,12 +805,12 @@ get_config:
 		if (ctrl->bRequestType != (USB_DIR_OUT| USB_TYPE_STANDARD |
 				USB_RECIP_INTERFACE))
 			break;
-		if (fsg->config && w_index == 0) {
+		if (msf->config && w_index == 0) {

 			/* Raise an exception to wipe out previous transaction
 			 * state (queued bufs, etc) and install the new
 			 * interface altsetting. */
-			raise_exception(fsg, STOR_STATE_INTERFACE_CHANGE);
+			msf_raise_exception(msf, STOR_STATE_INTERFACE_CHANGE);
 			value = DELAYED_STATUS;
 		}
 		break;
@@ -818,19 +818,19 @@ get_config:
 		if (ctrl->bRequestType != (USB_DIR_IN | USB_TYPE_STANDARD |
 				USB_RECIP_INTERFACE))
 			break;
-		if (!fsg->config)
+		if (!msf->config)
 			break;
 		if (w_index != 0) {
 			value = -EDOM;
 			break;
 		}
-		VSDBG(fsg, "get interface\n");
+		VSDBG(msf, "get interface\n");
 		*(u8 *) req->buf = 0;
 		value = 1;
 		break;

 	default:
-		VSDBG(fsg,
+		VSDBG(msf,
 			"unknown control req %02x.%02x v%04x i%04x l%u\n",
 			ctrl->bRequestType, ctrl->bRequest,
 			w_value, w_index, le16_to_cpu(ctrl->wLength));
@@ -840,31 +840,31 @@ get_config:
 }


-static int fsg_setup(struct usb_gadget *gadget,
+static int msf_setup(struct usb_gadget *gadget,
 		const struct usb_ctrlrequest *ctrl)
 {
-	struct fsg_dev		*fsg = get_gadget_data(gadget);
+	struct msf		*msf = get_gadget_data(gadget);
 	int			rc;
 	int			w_length = le16_to_cpu(ctrl->wLength);

-	++fsg->ep0_req_tag;		// Record arrival of a new request
-	fsg->ep0req->context = NULL;
-	fsg->ep0req->length = 0;
-	dump_msg(fsg, "ep0-setup", (u8 *) ctrl, sizeof(*ctrl));
+	++msf->ep0_req_tag;		// Record arrival of a new request
+	msf->ep0req->context = NULL;
+	msf->ep0req->length = 0;
+	dump_msg(msf, "ep0-setup", (u8 *) ctrl, sizeof(*ctrl));

 	if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS)
-		rc = class_setup_req(fsg, ctrl);
+		rc = msf_class_setup_req(msf, ctrl);
 	else
-		rc = standard_setup_req(fsg, ctrl);
+		rc = msf_standard_setup_req(msf, ctrl);

 	/* Respond with data/status or defer until later? */
 	if (rc >= 0 && rc != DELAYED_STATUS) {
 		rc = min(rc, w_length);
-		fsg->ep0req->length = rc;
-		fsg->ep0req->zero = rc < w_length;
-		fsg->ep0req_name = (ctrl->bRequestType & USB_DIR_IN ?
+		msf->ep0req->length = rc;
+		msf->ep0req->zero = rc < w_length;
+		msf->ep0req_name = (ctrl->bRequestType & USB_DIR_IN ?
 				"ep0-in" : "ep0-out");
-		rc = ep0_queue(fsg);
+		rc = msf_ep0_queue(msf);
 	}

 	/* Device either stalls (rc < 0) or reports success */
@@ -878,19 +878,19 @@ static int fsg_setup(struct usb_gadget *gadget,


 /* Use this for bulk or interrupt transfers, not ep0 */
-static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
+static void msf_start_transfer(struct msf *msf, struct usb_ep *ep,
 		struct usb_request *req, int *pbusy,
 		enum stor_buffer_state *state)
 {
 	int	rc;

-	if (ep == fsg->bulk_in)
-		dump_msg(fsg, "bulk-in", req->buf, req->length);
+	if (ep == msf->bulk_in)
+		dump_msg(msf, "bulk-in", req->buf, req->length);

-	spin_lock_irq(&fsg->lock);
+	spin_lock_irq(&msf->lock);
 	*pbusy = 1;
 	*state = BUF_STATE_BUSY;
-	spin_unlock_irq(&fsg->lock);
+	spin_unlock_irq(&msf->lock);
 	rc = usb_ep_queue(ep, req, GFP_KERNEL);
 	if (rc != 0) {
 		*pbusy = 0;
@@ -902,13 +902,13 @@ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
 		 * submissions if DMA is enabled. */
 		if (rc != -ESHUTDOWN && !(rc == -EOPNOTSUPP &&
 						req->length == 0))
-			SWARN(fsg, "error in submission: %s --> %d\n",
+			SWARN(msf, "error in submission: %s --> %d\n",
 			      ep->name, rc);
 	}
 }


-static int sleep_thread(struct fsg_dev *fsg)
+static int msf_sleep_thread(struct msf *msf)
 {
 	int	rc = 0;

@@ -920,21 +920,21 @@ static int sleep_thread(struct fsg_dev *fsg)
 			rc = -EINTR;
 			break;
 		}
-		if (fsg->thread_wakeup_needed)
+		if (msf->thread_wakeup_needed)
 			break;
 		schedule();
 	}
 	__set_current_state(TASK_RUNNING);
-	fsg->thread_wakeup_needed = 0;
+	msf->thread_wakeup_needed = 0;
 	return rc;
 }


 /*-------------------------------------------------------------------------*/

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

 	/* Get the starting Logical Block Address and check that it's
 	 * not too big */
-	if (fsg->cmnd[0] == SC_READ_6)
-		lba = get_unaligned_be24(&fsg->cmnd[1]);
+	if (msf->cmnd[0] == SC_READ_6)
+		lba = get_unaligned_be24(&msf->cmnd[1]);
 	else {
-		lba = get_unaligned_be32(&fsg->cmnd[2]);
+		lba = get_unaligned_be32(&msf->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 ((fsg->cmnd[1] & ~0x18) != 0) {
+		if ((msf->cmnd[1] & ~0x18) != 0) {
 			curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 			return -EINVAL;
 		}
@@ -966,7 +966,7 @@ static int do_read(struct fsg_dev *fsg)
 	file_offset = ((loff_t) lba) << 9;

 	/* Carry out the file reads */
-	amount_left = fsg->data_size_from_cmnd;
+	amount_left = msf->data_size_from_cmnd;
 	if (unlikely(amount_left == 0))
 		return -EIO;		// No default reply

@@ -989,9 +989,9 @@ static int do_read(struct fsg_dev *fsg)
 					partial_page);

 		/* Wait for the next buffer to become available */
-		bh = fsg->next_buffhd_to_fill;
+		bh = msf->next_buffhd_to_fill;
 		while (bh->state != BUF_STATE_EMPTY) {
-			rc = sleep_thread(fsg);
+			rc = msf_sleep_thread(msf);
 			if (rc)
 				return rc;
 		}
@@ -1030,7 +1030,7 @@ static int do_read(struct fsg_dev *fsg)
 		}
 		file_offset  += nread;
 		amount_left  -= nread;
-		fsg->residue -= nread;
+		msf->residue -= nread;
 		bh->inreq->length = nread;
 		bh->state = BUF_STATE_FULL;

@@ -1047,9 +1047,9 @@ static int do_read(struct fsg_dev *fsg)

 		/* Send this buffer and go read some more */
 		bh->inreq->zero = 0;
-		start_transfer(fsg, fsg->bulk_in, bh->inreq,
+		msf_start_transfer(msf, msf->bulk_in, bh->inreq,
 				&bh->inreq_busy, &bh->state);
-		fsg->next_buffhd_to_fill = bh->next;
+		msf->next_buffhd_to_fill = bh->next;
 	}

 	return -EIO;		// No default reply
@@ -1058,9 +1058,9 @@ static int do_read(struct fsg_dev *fsg)

 /*-------------------------------------------------------------------------*/

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

 	/* Get the starting Logical Block Address and check that it's
 	 * not too big */
-	if (fsg->cmnd[0] == SC_WRITE_6)
-		lba = get_unaligned_be24(&fsg->cmnd[1]);
+	if (msf->cmnd[0] == SC_WRITE_6)
+		lba = get_unaligned_be24(&msf->cmnd[1]);
 	else {
-		lba = get_unaligned_be32(&fsg->cmnd[2]);
+		lba = get_unaligned_be32(&msf->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 ((fsg->cmnd[1] & ~0x18) != 0) {
+		if ((msf->cmnd[1] & ~0x18) != 0) {
 			curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 			return -EINVAL;
 		}
-		if (fsg->cmnd[1] & 0x08) {	// FUA
+		if (msf->cmnd[1] & 0x08) {	// FUA
 			spin_lock(&curlun->filp->f_lock);
 			curlun->filp->f_flags |= O_SYNC;
 			spin_unlock(&curlun->filp->f_lock);
@@ -1108,12 +1108,12 @@ static int do_write(struct fsg_dev *fsg)
 	/* Carry out the file writes */
 	get_some_more = 1;
 	file_offset = usb_offset = ((loff_t) lba) << 9;
-	amount_left_to_req = amount_left_to_write = fsg->data_size_from_cmnd;
+	amount_left_to_req = amount_left_to_write = msf->data_size_from_cmnd;

 	while (amount_left_to_write > 0) {

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

 			/* Figure out how much we want to get:
@@ -1152,7 +1152,7 @@ static int do_write(struct fsg_dev *fsg)

 			/* Get the next buffer */
 			usb_offset += amount;
-			fsg->usb_amount_left -= amount;
+			msf->usb_amount_left -= amount;
 			amount_left_to_req -= amount;
 			if (amount_left_to_req == 0)
 				get_some_more = 0;
@@ -1162,19 +1162,19 @@ static int do_write(struct fsg_dev *fsg)
 			bh->outreq->length = bh->bulk_out_intended_length =
 					amount;
 			bh->outreq->short_not_ok = 1;
-			start_transfer(fsg, fsg->bulk_out, bh->outreq,
+			msf_start_transfer(msf, msf->bulk_out, bh->outreq,
 					&bh->outreq_busy, &bh->state);
-			fsg->next_buffhd_to_fill = bh->next;
+			msf->next_buffhd_to_fill = bh->next;
 			continue;
 		}

 		/* Write the received data to the backing file */
-		bh = fsg->next_buffhd_to_drain;
+		bh = msf->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();
-			fsg->next_buffhd_to_drain = bh->next;
+			msf->next_buffhd_to_drain = bh->next;
 			bh->state = BUF_STATE_EMPTY;

 			/* Did something go wrong with the transfer? */
@@ -1217,7 +1217,7 @@ static int do_write(struct fsg_dev *fsg)
 			}
 			file_offset += nwritten;
 			amount_left_to_write -= nwritten;
-			fsg->residue -= nwritten;
+			msf->residue -= nwritten;

 			/* If an error occurred, report it and its position */
 			if (nwritten < amount) {
@@ -1229,14 +1229,14 @@ static int do_write(struct fsg_dev *fsg)

 			/* Did the host decide to stop early? */
 			if (bh->outreq->actual != bh->outreq->length) {
-				fsg->short_packet_received = 1;
+				msf->short_packet_received = 1;
 				break;
 			}
 			continue;
 		}

 		/* Wait for something to happen */
-		rc = sleep_thread(fsg);
+		rc = msf_sleep_thread(msf);
 		if (rc)
 			return rc;
 	}
@@ -1247,9 +1247,9 @@ static int do_write(struct fsg_dev *fsg)

 /*-------------------------------------------------------------------------*/

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

 	/* We ignore the requested LBA and write out all file's
@@ -1263,7 +1263,7 @@ static int do_synchronize_cache(struct fsg_dev *fsg)

 /*-------------------------------------------------------------------------*/

-static void invalidate_sub(struct storage_lun *curlun)
+static void msf_invalidate_sub(struct storage_lun *curlun)
 {
 	struct file	*filp = curlun->filp;
 	struct inode	*inode = filp->f_path.dentry->d_inode;
@@ -1273,12 +1273,12 @@ static void invalidate_sub(struct storage_lun *curlun)
 	VLDBG(curlun, "invalidate_inode_pages -> %ld\n", rc);
 }

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

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

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

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

@@ -1312,7 +1312,7 @@ static int do_verify(struct fsg_dev *fsg)
 	if (signal_pending(current))
 		return -EINTR;

-	invalidate_sub(curlun);
+	msf_invalidate_sub(curlun);
 	if (signal_pending(current))
 		return -EINTR;

@@ -1371,7 +1371,7 @@ static int do_verify(struct fsg_dev *fsg)

 /*-------------------------------------------------------------------------*/

-static int do_inquiry(struct fsg_dev *fsg, struct stor_buffhd *bh)
+static int msf_do_inquiry(struct msf *msf, struct stor_buffhd *bh)
 {
 	u8	*buf = (u8 *) bh->buf;

@@ -1379,8 +1379,8 @@ static int do_inquiry(struct fsg_dev *fsg, struct stor_buffhd *bh)
 	static char product_disk_id[] = "File-Stor Gadget";
 	static char product_cdrom_id[] = "File-CD Gadget  ";

-	if (!fsg->curlun) {		// Unsupported LUNs are okay
-		fsg->bad_lun_okay = 1;
+	if (!msf->curlun) {		// Unsupported LUNs are okay
+		msf->bad_lun_okay = 1;
 		memset(buf, 0, 36);
 		buf[0] = 0x7f;		// Unsupported, no device-type
 		buf[4] = 31;		// Additional length
@@ -1403,9 +1403,9 @@ static int do_inquiry(struct fsg_dev *fsg, struct stor_buffhd *bh)
 }


-static int do_request_sense(struct fsg_dev *fsg, struct stor_buffhd *bh)
+static int msf_do_request_sense(struct msf *msf, struct stor_buffhd *bh)
 {
-	struct storage_lun	*curlun = fsg->curlun;
+	struct storage_lun	*curlun = msf->curlun;
 	u8		*buf = (u8 *) bh->buf;
 	u32		sd, sdinfo;
 	int		valid;
@@ -1423,7 +1423,7 @@ static int do_request_sense(struct fsg_dev *fsg, struct stor_buffhd *bh)
 	 *	pending sense data, and clear the unit attention
 	 *	condition on the logical unit for that initiator.
 	 *
-	 * FSG normally uses option a); enable this code to use option b).
+	 * MSF normally uses option a); enable this code to use option b).
 	 */
 #if 0
 	if (curlun && curlun->unit_attention_data != SS_NO_SENSE) {
@@ -1433,7 +1433,7 @@ static int do_request_sense(struct fsg_dev *fsg, struct stor_buffhd *bh)
 #endif

 	if (!curlun) {		// Unsupported LUNs are okay
-		fsg->bad_lun_okay = 1;
+		msf->bad_lun_okay = 1;
 		sd = SS_LOGICAL_UNIT_NOT_SUPPORTED;
 		sdinfo = 0;
 		valid = 0;
@@ -1457,11 +1457,11 @@ static int do_request_sense(struct fsg_dev *fsg, struct stor_buffhd *bh)
 }


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

 	/* Check the PMI and LBA fields */
@@ -1477,14 +1477,13 @@ static int do_read_capacity(struct fsg_dev *fsg, struct stor_buffhd *bh)
 }


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

-	if ((fsg->cmnd[1] & ~0x02) != 0) {		/* Mask away MSF */
+	if ((msf->cmnd[1] & ~0x02) != 0) {		/* Mask away MSF */
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
 	}
@@ -1495,19 +1494,18 @@ static int do_read_header(struct fsg_dev *fsg, 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, lba);
+	store_cdrom_address(&buf[4], msf->cmnd[1] & 0x02 /* MSF */, lba);
 	return 8;
 }


-static int do_read_toc(struct fsg_dev *fsg, struct stor_buffhd *bh)
+static int msf_do_read_toc(struct msf *msf, struct stor_buffhd *bh)
 {
-	struct storage_lun	*curlun = fsg->curlun;
-	int		msf = fsg->cmnd[1] & 0x02;
-	int		start_track = fsg->cmnd[6];
+	struct storage_lun	*curlun = msf->curlun;
+	int		start_track = msf->cmnd[6];
 	u8		*buf = (u8 *) bh->buf;

-	if ((fsg->cmnd[1] & ~0x02) != 0 ||		/* Mask away MSF */
+	if ((msf->cmnd[1] & ~0x02) != 0 ||		/* Mask away MSF */
 			start_track > 1) {
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
@@ -1519,19 +1517,20 @@ static int do_read_toc(struct fsg_dev *fsg, 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, 0);
+	store_cdrom_address(&buf[8], msf->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, curlun->num_sectors);
+	store_cdrom_address(&buf[16], msf->cmnd[1] & 0x02 /* MSF */,
+			    curlun->num_sectors);
 	return 20;
 }


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

-	if ((fsg->cmnd[1] & ~0x08) != 0) {		// Mask away DBD
+	if ((msf->cmnd[1] & ~0x08) != 0) {		// Mask away DBD
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
 	}
-	pc = fsg->cmnd[2] >> 6;
-	page_code = fsg->cmnd[2] & 0x3f;
+	pc = msf->cmnd[2] >> 6;
+	page_code = msf->cmnd[2] & 0x3f;
 	if (pc == 3) {
 		curlun->sense_data = SS_SAVING_PARAMETERS_NOT_SUPPORTED;
 		return -EINVAL;
@@ -1609,19 +1608,19 @@ static int do_mode_sense(struct fsg_dev *fsg, struct stor_buffhd *bh)
 }


-static int do_start_stop(struct fsg_dev *fsg)
+static int msf_do_start_stop(struct msf *msf)
 {
 	if (!mod_data.removable) {
-		fsg->curlun->sense_data = SS_INVALID_COMMAND;
+		msf->curlun->sense_data = SS_INVALID_COMMAND;
 		return -EINVAL;
 	}
 	return 0;
 }


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

 	if (!mod_data.removable) {
@@ -1629,8 +1628,8 @@ static int do_prevent_allow(struct fsg_dev *fsg)
 		return -EINVAL;
 	}

-	prevent = fsg->cmnd[4] & 0x01;
-	if ((fsg->cmnd[4] & ~0x01) != 0) {		// Mask away Prevent
+	prevent = msf->cmnd[4] & 0x01;
+	if ((msf->cmnd[4] & ~0x01) != 0) {		// Mask away Prevent
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
 	}
@@ -1642,10 +1641,10 @@ static int do_prevent_allow(struct fsg_dev *fsg)
 }


-static int do_read_format_capacities(struct fsg_dev *fsg,
+static int msf_do_read_format_capacities(struct msf *msf,
 			struct stor_buffhd *bh)
 {
-	struct storage_lun	*curlun = fsg->curlun;
+	struct storage_lun	*curlun = msf->curlun;
 	u8		*buf = (u8 *) bh->buf;

 	buf[0] = buf[1] = buf[2] = 0;
@@ -1660,9 +1659,9 @@ static int do_read_format_capacities(struct fsg_dev *fsg,
 }


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

 	/* We don't support MODE SELECT */
 	curlun->sense_data = SS_INVALID_COMMAND;
@@ -1672,16 +1671,16 @@ static int do_mode_select(struct fsg_dev *fsg, struct stor_buffhd *bh)

 /*-------------------------------------------------------------------------*/

-static int halt_bulk_in_endpoint(struct fsg_dev *fsg)
+static int msf_halt_bulk_in_endpoint(struct msf *msf)
 {
 	int	rc;

-	rc = fsg_set_halt(fsg, fsg->bulk_in);
+	rc = msf_set_halt(msf, msf->bulk_in);
 	if (rc == -EAGAIN)
-		VSDBG(fsg, "delayed bulk-in endpoint halt\n");
+		VSDBG(msf, "delayed bulk-in endpoint halt\n");
 	while (rc != 0) {
 		if (rc != -EAGAIN) {
-			SWARN(fsg, "usb_ep_set_halt -> %d\n", rc);
+			SWARN(msf, "usb_ep_set_halt -> %d\n", rc);
 			rc = 0;
 			break;
 		}
@@ -1689,22 +1688,22 @@ static int halt_bulk_in_endpoint(struct fsg_dev *fsg)
 		/* Wait for a short time and then try again */
 		if (msleep_interruptible(100) != 0)
 			return -EINTR;
-		rc = usb_ep_set_halt(fsg->bulk_in);
+		rc = usb_ep_set_halt(msf->bulk_in);
 	}
 	return rc;
 }

-static int wedge_bulk_in_endpoint(struct fsg_dev *fsg)
+static int msf_wedge_bulk_in_endpoint(struct msf *msf)
 {
 	int	rc;

-	SDBG(fsg, "bulk-in set wedge\n");
-	rc = usb_ep_set_wedge(fsg->bulk_in);
+	SDBG(msf, "bulk-in set wedge\n");
+	rc = usb_ep_set_wedge(msf->bulk_in);
 	if (rc == -EAGAIN)
-		VSDBG(fsg, "delayed bulk-in endpoint wedge\n");
+		VSDBG(msf, "delayed bulk-in endpoint wedge\n");
 	while (rc != 0) {
 		if (rc != -EAGAIN) {
-			SWARN(fsg, "usb_ep_set_wedge -> %d\n", rc);
+			SWARN(msf, "usb_ep_set_wedge -> %d\n", rc);
 			rc = 0;
 			break;
 		}
@@ -1712,85 +1711,85 @@ static int wedge_bulk_in_endpoint(struct fsg_dev *fsg)
 		/* Wait for a short time and then try again */
 		if (msleep_interruptible(100) != 0)
 			return -EINTR;
-		rc = usb_ep_set_wedge(fsg->bulk_in);
+		rc = usb_ep_set_wedge(msf->bulk_in);
 	}
 	return rc;
 }

-static int pad_with_zeros(struct fsg_dev *fsg)
+static int msf_pad_with_zeros(struct msf *msf)
 {
-	struct stor_buffhd	*bh = fsg->next_buffhd_to_fill;
+	struct stor_buffhd	*bh = msf->next_buffhd_to_fill;
 	u32			nkeep = bh->inreq->length;
 	u32			nsend;
 	int			rc;

 	bh->state = BUF_STATE_EMPTY;		// For the first iteration
-	fsg->usb_amount_left = nkeep + fsg->residue;
-	while (fsg->usb_amount_left > 0) {
+	msf->usb_amount_left = nkeep + msf->residue;
+	while (msf->usb_amount_left > 0) {

 		/* Wait for the next buffer to be free */
 		while (bh->state != BUF_STATE_EMPTY) {
-			rc = sleep_thread(fsg);
+			rc = msf_sleep_thread(msf);
 			if (rc)
 				return rc;
 		}

-		nsend = min(fsg->usb_amount_left, STORAGE_BUFLEN);
+		nsend = min(msf->usb_amount_left, STORAGE_BUFLEN);
 		memset(bh->buf + nkeep, 0, nsend - nkeep);
 		bh->inreq->length = nsend;
 		bh->inreq->zero = 0;
-		start_transfer(fsg, fsg->bulk_in, bh->inreq,
+		msf_start_transfer(msf, msf->bulk_in, bh->inreq,
 				&bh->inreq_busy, &bh->state);
-		bh = fsg->next_buffhd_to_fill = bh->next;
-		fsg->usb_amount_left -= nsend;
+		bh = msf->next_buffhd_to_fill = bh->next;
+		msf->usb_amount_left -= nsend;
 		nkeep = 0;
 	}
 	return 0;
 }

-static int throw_away_data(struct fsg_dev *fsg)
+static int msf_throw_away_data(struct msf *msf)
 {
 	struct stor_buffhd	*bh;
 	u32			amount;
 	int			rc;

-	while ((bh = fsg->next_buffhd_to_drain)->state != BUF_STATE_EMPTY ||
-			fsg->usb_amount_left > 0) {
+	while ((bh = msf->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;
-			fsg->next_buffhd_to_drain = bh->next;
+			msf->next_buffhd_to_drain = bh->next;

 			/* A short packet or an error ends everything */
 			if (bh->outreq->actual != bh->outreq->length ||
 					bh->outreq->status != 0) {
-				raise_exception(fsg, STOR_STATE_ABORT_BULK_OUT);
+				msf_raise_exception(msf, STOR_STATE_ABORT_BULK_OUT);
 				return -EINTR;
 			}
 			continue;
 		}

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

 			/* amount is always divisible by 512, hence by
 			 * the bulk-out maxpacket size */
 			bh->outreq->length = bh->bulk_out_intended_length =
 					amount;
 			bh->outreq->short_not_ok = 1;
-			start_transfer(fsg, fsg->bulk_out, bh->outreq,
+			msf_start_transfer(msf, msf->bulk_out, bh->outreq,
 					&bh->outreq_busy, &bh->state);
-			fsg->next_buffhd_to_fill = bh->next;
-			fsg->usb_amount_left -= amount;
+			msf->next_buffhd_to_fill = bh->next;
+			msf->usb_amount_left -= amount;
 			continue;
 		}

 		/* Otherwise wait for something to happen */
-		rc = sleep_thread(fsg);
+		rc = msf_sleep_thread(msf);
 		if (rc)
 			return rc;
 	}
@@ -1798,12 +1797,12 @@ static int throw_away_data(struct fsg_dev *fsg)
 }


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

-	switch (fsg->data_dir) {
+	switch (msf->data_dir) {
 	case DATA_DIR_NONE:
 		break;			// Nothing to send

@@ -1813,22 +1812,22 @@ static int finish_reply(struct fsg_dev *fsg)
 	 * if we can and wait for a reset. */
 	case DATA_DIR_UNKNOWN:
 		if (mod_data.can_stall) {
-			fsg_set_halt(fsg, fsg->bulk_out);
-			rc = halt_bulk_in_endpoint(fsg);
+			msf_set_halt(msf, msf->bulk_out);
+			rc = msf_halt_bulk_in_endpoint(msf);
 		}
 		break;

 	/* All but the last buffer of data must have already been sent */
 	case DATA_DIR_TO_HOST:
-		if (fsg->data_size == 0)
+		if (msf->data_size == 0)
 			;		// Nothing to send

 		/* If there's no residue, simply send the last buffer */
-		else if (fsg->residue == 0) {
+		else if (msf->residue == 0) {
 			bh->inreq->zero = 0;
-			start_transfer(fsg, fsg->bulk_in, bh->inreq,
+			msf_start_transfer(msf, msf->bulk_in, bh->inreq,
 					&bh->inreq_busy, &bh->state);
-			fsg->next_buffhd_to_fill = bh->next;
+			msf->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
@@ -1842,24 +1841,24 @@ static int finish_reply(struct fsg_dev *fsg)
 		 * stall, pad out the remaining data with 0's. */
 		} else if (mod_data.can_stall) {
 			bh->inreq->zero = 1;
-			start_transfer(fsg, fsg->bulk_in, bh->inreq,
+			msf_start_transfer(msf, msf->bulk_in, bh->inreq,
 				       &bh->inreq_busy, &bh->state);
-			fsg->next_buffhd_to_fill = bh->next;
-			rc = halt_bulk_in_endpoint(fsg);
+			msf->next_buffhd_to_fill = bh->next;
+			rc = msf_halt_bulk_in_endpoint(msf);
 		} else {
-			rc = pad_with_zeros(fsg);
+			rc = msf_pad_with_zeros(msf);
 		}
 		break;

 	/* We have processed all we want from the data the host has sent.
 	 * There may still be outstanding bulk-out requests. */
 	case DATA_DIR_FROM_HOST:
-		if (fsg->residue == 0)
+		if (msf->residue == 0)
 			;		// Nothing to receive

 		/* Did the host stop sending unexpectedly early? */
-		else if (fsg->short_packet_received) {
-			raise_exception(fsg, STOR_STATE_ABORT_BULK_OUT);
+		else if (msf->short_packet_received) {
+			msf_raise_exception(msf, STOR_STATE_ABORT_BULK_OUT);
 			rc = -EINTR;
 		}

@@ -1871,8 +1870,8 @@ static int finish_reply(struct fsg_dev *fsg)
 		 * clear the halt -- leading to problems later on. */
 #if 0
 		else if (mod_data.can_stall) {
-			fsg_set_halt(fsg, fsg->bulk_out);
-			raise_exception(fsg, STOR_STATE_ABORT_BULK_OUT);
+			msf_set_halt(msf, msf->bulk_out);
+			msf_raise_exception(msf, STOR_STATE_ABORT_BULK_OUT);
 			rc = -EINTR;
 		}
 #endif
@@ -1880,16 +1879,16 @@ static int finish_reply(struct fsg_dev *fsg)
 		/* We can't stall.  Read in the excess data and throw it
 		 * all away. */
 		else
-			rc = throw_away_data(fsg);
+			rc = msf_throw_away_data(msf);
 		break;
 	}
 	return rc;
 }


-static int send_status(struct fsg_dev *fsg)
+static int msf_send_status(struct msf *msf)
 {
-	struct storage_lun		*curlun = fsg->curlun;
+	struct storage_lun		*curlun = msf->curlun;
 	struct stor_bulk_cs_wrap	*csw;
 	struct stor_buffhd	*bh;
 	int			rc;
@@ -1897,9 +1896,9 @@ static int send_status(struct fsg_dev *fsg)
 	u32			sd, sdinfo = 0;

 	/* Wait for the next buffer to become available */
-	bh = fsg->next_buffhd_to_fill;
+	bh = msf->next_buffhd_to_fill;
 	while (bh->state != BUF_STATE_EMPTY) {
-		rc = sleep_thread(fsg);
+		rc = msf_sleep_thread(msf);
 		if (rc)
 			return rc;
 	}
@@ -1907,19 +1906,19 @@ static int send_status(struct fsg_dev *fsg)
 	if (curlun) {
 		sd = curlun->sense_data;
 		sdinfo = curlun->sense_data_info;
-	} else if (fsg->bad_lun_okay)
+	} else if (msf->bad_lun_okay)
 		sd = SS_NO_SENSE;
 	else
 		sd = SS_LOGICAL_UNIT_NOT_SUPPORTED;

-	if (fsg->phase_error) {
-		SDBG(fsg, "sending phase-error status\n");
+	if (msf->phase_error) {
+		SDBG(msf, "sending phase-error status\n");
 		status = USB_STATUS_PHASE_ERROR;
 		sd = SS_INVALID_COMMAND;
 	} else if (sd != SS_NO_SENSE) {
-		SDBG(fsg, "sending command-failure status\n");
+		SDBG(msf, "sending command-failure status\n");
 		status = USB_STATUS_FAIL;
-		VSDBG(fsg, "  sense data: SK x%02x, ASC x%02x, ASCQ x%02x;"
+		VSDBG(msf, "  sense data: SK x%02x, ASC x%02x, ASCQ x%02x;"
 		      "  info x%x\n",
 		      SK(sd), ASC(sd), ASCQ(sd), sdinfo);
 	}
@@ -1928,16 +1927,16 @@ static int send_status(struct fsg_dev *fsg)

 	/* Store and send the Bulk-only CSW */
 	csw->Signature = cpu_to_le32(USB_BULK_CS_SIG);
-	csw->Tag = fsg->tag;
-	csw->Residue = cpu_to_le32(fsg->residue);
+	csw->Tag = msf->tag;
+	csw->Residue = cpu_to_le32(msf->residue);
 	csw->Status = status;

 	bh->inreq->length = USB_BULK_CS_WRAP_LEN;
 	bh->inreq->zero = 0;
-	start_transfer(fsg, fsg->bulk_in, bh->inreq,
+	msf_start_transfer(msf, msf->bulk_in, bh->inreq,
 		       &bh->inreq_busy, &bh->state);

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

@@ -1946,52 +1945,52 @@ static int send_status(struct fsg_dev *fsg)

 /* Check whether the command is properly formed and whether its data size
  * and direction agree with the values we already have. */
-static int check_command(struct fsg_dev *fsg, int cmnd_size,
+static int msf_check_command(struct msf *msf, int cmnd_size,
 		enum stor_data_direction data_dir, unsigned int mask,
 		int needs_medium, const char *name)
 {
 	int			i;
-	int			lun = fsg->cmnd[1] >> 5;
+	int			lun = msf->cmnd[1] >> 5;
 	static const char	dirletter[4] = {'u', 'o', 'i', 'n'};
 	char			hdlen[20];
 	struct storage_lun		*curlun;

 	hdlen[0] = 0;
-	if (fsg->data_dir != DATA_DIR_UNKNOWN)
-		sprintf(hdlen, ", H%c=%u", dirletter[(int) fsg->data_dir],
-			fsg->data_size);
-	VSDBG(fsg, "SCSI command: %s;  Dc=%d, D%c=%u;  Hc=%d%s\n",
+	if (msf->data_dir != DATA_DIR_UNKNOWN)
+		sprintf(hdlen, ", H%c=%u", dirletter[(int) msf->data_dir],
+			msf->data_size);
+	VSDBG(msf, "SCSI command: %s;  Dc=%d, D%c=%u;  Hc=%d%s\n",
 	      name, cmnd_size, dirletter[(int) data_dir],
-	      fsg->data_size_from_cmnd, fsg->cmnd_size, hdlen);
+	      msf->data_size_from_cmnd, msf->cmnd_size, hdlen);

 	/* We can't reply at all until we know the correct data direction
 	 * and size. */
-	if (fsg->data_size_from_cmnd == 0)
+	if (msf->data_size_from_cmnd == 0)
 		data_dir = DATA_DIR_NONE;
-	if (fsg->data_dir == DATA_DIR_UNKNOWN) {	// CB or CBI
-		fsg->data_dir = data_dir;
-		fsg->data_size = fsg->data_size_from_cmnd;
+	if (msf->data_dir == DATA_DIR_UNKNOWN) {	// CB or CBI
+		msf->data_dir = data_dir;
+		msf->data_size = msf->data_size_from_cmnd;

 	} else {					// Bulk-only
-		if (fsg->data_size < fsg->data_size_from_cmnd) {
+		if (msf->data_size < msf->data_size_from_cmnd) {

 			/* Host data size < Device data size is a phase error.
 			 * Carry out the command, but only transfer as much
 			 * as we are allowed. */
-			fsg->data_size_from_cmnd = fsg->data_size;
-			fsg->phase_error = 1;
+			msf->data_size_from_cmnd = msf->data_size;
+			msf->phase_error = 1;
 		}
 	}
-	fsg->residue = fsg->usb_amount_left = fsg->data_size;
+	msf->residue = msf->usb_amount_left = msf->data_size;

 	/* Conflicting data directions is a phase error */
-	if (fsg->data_dir != data_dir && fsg->data_size_from_cmnd > 0) {
-		fsg->phase_error = 1;
+	if (msf->data_dir != data_dir && msf->data_size_from_cmnd > 0) {
+		msf->phase_error = 1;
 		return -EINVAL;
 	}

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

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

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

 	/* Check the LUN */
-	if (fsg->lun >= 0 && fsg->lun < fsg->nluns) {
-		fsg->curlun = curlun = &fsg->luns[fsg->lun];
-		if (fsg->cmnd[0] != SC_REQUEST_SENSE) {
+	if (msf->lun >= 0 && msf->lun < msf->nluns) {
+		msf->curlun = curlun = &msf->luns[msf->lun];
+		if (msf->cmnd[0] != SC_REQUEST_SENSE) {
 			curlun->sense_data = SS_NO_SENSE;
 			curlun->sense_data_info = 0;
 			curlun->info_valid = 0;
 		}
 	} else {
-		fsg->curlun = curlun = NULL;
-		fsg->bad_lun_okay = 0;
+		msf->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 (fsg->cmnd[0] != SC_INQUIRY &&
-		    fsg->cmnd[0] != SC_REQUEST_SENSE) {
-			SDBG(fsg, "unsupported LUN %d\n", fsg->lun);
+		if (msf->cmnd[0] != SC_INQUIRY &&
+		    msf->cmnd[0] != SC_REQUEST_SENSE) {
+			SDBG(msf, "unsupported LUN %d\n", msf->lun);
 			return -EINVAL;
 		}
 	}
@@ -2045,17 +2044,17 @@ static int check_command(struct fsg_dev *fsg, 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 &&
-			fsg->cmnd[0] != SC_INQUIRY &&
-			fsg->cmnd[0] != SC_REQUEST_SENSE) {
+			msf->cmnd[0] != SC_INQUIRY &&
+			msf->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 */
-	fsg->cmnd[1] &= 0x1f;			// Mask away the LUN
+	msf->cmnd[1] &= 0x1f;			// Mask away the LUN
 	for (i = 1; i < cmnd_size; ++i) {
-		if (fsg->cmnd[i] && !(mask & (1 << i))) {
+		if (msf->cmnd[i] && !(mask & (1 << i))) {
 			if (curlun)
 				curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 			return -EINVAL;
@@ -2073,7 +2072,7 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size,
 }


-static int do_scsi_command(struct fsg_dev *fsg)
+static int msf_do_scsi_command(struct msf *msf)
 {
 	struct stor_buffhd	*bh;
 	int			rc;
@@ -2081,159 +2080,159 @@ static int do_scsi_command(struct fsg_dev *fsg)
 	int			i;
 	static char		unknown[16];

-	dump_cdb(fsg);
+	dump_cdb(msf);

 	/* Wait for the next buffer to become available for data or status */
-	bh = fsg->next_buffhd_to_drain = fsg->next_buffhd_to_fill;
+	bh = msf->next_buffhd_to_drain = msf->next_buffhd_to_fill;
 	while (bh->state != BUF_STATE_EMPTY) {
-		rc = sleep_thread(fsg);
+		rc = msf_sleep_thread(msf);
 		if (rc)
 			return rc;
 	}
-	fsg->phase_error = 0;
-	fsg->short_packet_received = 0;
+	msf->phase_error = 0;
+	msf->short_packet_received = 0;

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

 	case SC_INQUIRY:
-		fsg->data_size_from_cmnd = fsg->cmnd[4];
-		if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
+		msf->data_size_from_cmnd = msf->cmnd[4];
+		if ((reply = msf_check_command(msf, 6, DATA_DIR_TO_HOST,
 				(1<<4), 0,
 				"INQUIRY")) == 0)
-			reply = do_inquiry(fsg, bh);
+			reply = msf_do_inquiry(msf, bh);
 		break;

 	case SC_MODE_SELECT_6:
-		fsg->data_size_from_cmnd = fsg->cmnd[4];
-		if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST,
+		msf->data_size_from_cmnd = msf->cmnd[4];
+		if ((reply = msf_check_command(msf, 6, DATA_DIR_FROM_HOST,
 				(1<<1) | (1<<4), 0,
 				"MODE SELECT(6)")) == 0)
-			reply = do_mode_select(fsg, bh);
+			reply = msf_do_mode_select(msf, bh);
 		break;

 	case SC_MODE_SELECT_10:
-		fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
-		if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST,
+		msf->data_size_from_cmnd = get_unaligned_be16(&msf->cmnd[7]);
+		if ((reply = msf_check_command(msf, 10, DATA_DIR_FROM_HOST,
 				(1<<1) | (3<<7), 0,
 				"MODE SELECT(10)")) == 0)
-			reply = do_mode_select(fsg, bh);
+			reply = msf_do_mode_select(msf, bh);
 		break;

 	case SC_MODE_SENSE_6:
-		fsg->data_size_from_cmnd = fsg->cmnd[4];
-		if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
+		msf->data_size_from_cmnd = msf->cmnd[4];
+		if ((reply = msf_check_command(msf, 6, DATA_DIR_TO_HOST,
 				(1<<1) | (1<<2) | (1<<4), 0,
 				"MODE SENSE(6)")) == 0)
-			reply = do_mode_sense(fsg, bh);
+			reply = msf_do_mode_sense(msf, bh);
 		break;

 	case SC_MODE_SENSE_10:
-		fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
-		if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
+		msf->data_size_from_cmnd = get_unaligned_be16(&msf->cmnd[7]);
+		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(1<<1) | (1<<2) | (3<<7), 0,
 				"MODE SENSE(10)")) == 0)
-			reply = do_mode_sense(fsg, bh);
+			reply = msf_do_mode_sense(msf, bh);
 		break;

 	case SC_PREVENT_ALLOW_MEDIUM_REMOVAL:
-		fsg->data_size_from_cmnd = 0;
-		if ((reply = check_command(fsg, 6, DATA_DIR_NONE,
+		msf->data_size_from_cmnd = 0;
+		if ((reply = msf_check_command(msf, 6, DATA_DIR_NONE,
 				(1<<4), 0,
 				"PREVENT-ALLOW MEDIUM REMOVAL")) == 0)
-			reply = do_prevent_allow(fsg);
+			reply = msf_do_prevent_allow(msf);
 		break;

 	case SC_READ_6:
-		i = fsg->cmnd[4];
-		fsg->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
-		if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
+		i = msf->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,
 				"READ(6)")) == 0)
-			reply = do_read(fsg);
+			reply = msf_do_read(msf);
 		break;

 	case SC_READ_10:
-		fsg->data_size_from_cmnd =
-				get_unaligned_be16(&fsg->cmnd[7]) << 9;
-		if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
+		msf->data_size_from_cmnd =
+				get_unaligned_be16(&msf->cmnd[7]) << 9;
+		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(1<<1) | (0xf<<2) | (3<<7), 1,
 				"READ(10)")) == 0)
-			reply = do_read(fsg);
+			reply = msf_do_read(msf);
 		break;

 	case SC_READ_12:
-		fsg->data_size_from_cmnd =
-				get_unaligned_be32(&fsg->cmnd[6]) << 9;
-		if ((reply = check_command(fsg, 12, DATA_DIR_TO_HOST,
+		msf->data_size_from_cmnd =
+				get_unaligned_be32(&msf->cmnd[6]) << 9;
+		if ((reply = msf_check_command(msf, 12, DATA_DIR_TO_HOST,
 				(1<<1) | (0xf<<2) | (0xf<<6), 1,
 				"READ(12)")) == 0)
-			reply = do_read(fsg);
+			reply = msf_do_read(msf);
 		break;

 	case SC_READ_CAPACITY:
-		fsg->data_size_from_cmnd = 8;
-		if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
+		msf->data_size_from_cmnd = 8;
+		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(0xf<<2) | (1<<8), 1,
 				"READ CAPACITY")) == 0)
-			reply = do_read_capacity(fsg, bh);
+			reply = msf_do_read_capacity(msf, bh);
 		break;

 	case SC_READ_HEADER:
 		if (!mod_data.cdrom)
 			goto unknown_cmnd;
-		fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
-		if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
+		msf->data_size_from_cmnd = get_unaligned_be16(&msf->cmnd[7]);
+		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(3<<7) | (0x1f<<1), 1,
 				"READ HEADER")) == 0)
-			reply = do_read_header(fsg, bh);
+			reply = msf_do_read_header(msf, bh);
 		break;

 	case SC_READ_TOC:
 		if (!mod_data.cdrom)
 			goto unknown_cmnd;
-		fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
-		if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
+		msf->data_size_from_cmnd = get_unaligned_be16(&msf->cmnd[7]);
+		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(7<<6) | (1<<1), 1,
 				"READ TOC")) == 0)
-			reply = do_read_toc(fsg, bh);
+			reply = msf_do_read_toc(msf, bh);
 		break;

 	case SC_READ_FORMAT_CAPACITIES:
-		fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
-		if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
+		msf->data_size_from_cmnd = get_unaligned_be16(&msf->cmnd[7]);
+		if ((reply = msf_check_command(msf, 10, DATA_DIR_TO_HOST,
 				(3<<7), 1,
 				"READ FORMAT CAPACITIES")) == 0)
-			reply = do_read_format_capacities(fsg, bh);
+			reply = msf_do_read_format_capacities(msf, bh);
 		break;

 	case SC_REQUEST_SENSE:
-		fsg->data_size_from_cmnd = fsg->cmnd[4];
-		if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
+		msf->data_size_from_cmnd = msf->cmnd[4];
+		if ((reply = msf_check_command(msf, 6, DATA_DIR_TO_HOST,
 				(1<<4), 0,
 				"REQUEST SENSE")) == 0)
-			reply = do_request_sense(fsg, bh);
+			reply = msf_do_request_sense(msf, bh);
 		break;

 	case SC_START_STOP_UNIT:
-		fsg->data_size_from_cmnd = 0;
-		if ((reply = check_command(fsg, 6, DATA_DIR_NONE,
+		msf->data_size_from_cmnd = 0;
+		if ((reply = msf_check_command(msf, 6, DATA_DIR_NONE,
 				(1<<1) | (1<<4), 0,
 				"START-STOP UNIT")) == 0)
-			reply = do_start_stop(fsg);
+			reply = msf_do_start_stop(msf);
 		break;

 	case SC_SYNCHRONIZE_CACHE:
-		fsg->data_size_from_cmnd = 0;
-		if ((reply = check_command(fsg, 10, DATA_DIR_NONE,
+		msf->data_size_from_cmnd = 0;
+		if ((reply = msf_check_command(msf, 10, DATA_DIR_NONE,
 				(0xf<<2) | (3<<7), 1,
 				"SYNCHRONIZE CACHE")) == 0)
-			reply = do_synchronize_cache(fsg);
+			reply = msf_do_synchronize_cache(msf);
 		break;

 	case SC_TEST_UNIT_READY:
-		fsg->data_size_from_cmnd = 0;
-		reply = check_command(fsg, 6, DATA_DIR_NONE,
+		msf->data_size_from_cmnd = 0;
+		reply = msf_check_command(msf, 6, DATA_DIR_NONE,
 				0, 1,
 				"TEST UNIT READY");
 		break;
@@ -2241,38 +2240,38 @@ static int do_scsi_command(struct fsg_dev *fsg)
 	/* Although optional, this command is used by MS-Windows.  We
 	 * support a minimal version: BytChk must be 0. */
 	case SC_VERIFY:
-		fsg->data_size_from_cmnd = 0;
-		if ((reply = check_command(fsg, 10, DATA_DIR_NONE,
+		msf->data_size_from_cmnd = 0;
+		if ((reply = msf_check_command(msf, 10, DATA_DIR_NONE,
 				(1<<1) | (0xf<<2) | (3<<7), 1,
 				"VERIFY")) == 0)
-			reply = do_verify(fsg);
+			reply = msf_do_verify(msf);
 		break;

 	case SC_WRITE_6:
-		i = fsg->cmnd[4];
-		fsg->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
-		if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST,
+		i = msf->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,
 				"WRITE(6)")) == 0)
-			reply = do_write(fsg);
+			reply = msf_do_write(msf);
 		break;

 	case SC_WRITE_10:
-		fsg->data_size_from_cmnd =
-				get_unaligned_be16(&fsg->cmnd[7]) << 9;
-		if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST,
+		msf->data_size_from_cmnd =
+				get_unaligned_be16(&msf->cmnd[7]) << 9;
+		if ((reply = msf_check_command(msf, 10, DATA_DIR_FROM_HOST,
 				(1<<1) | (0xf<<2) | (3<<7), 1,
 				"WRITE(10)")) == 0)
-			reply = do_write(fsg);
+			reply = msf_do_write(msf);
 		break;

 	case SC_WRITE_12:
-		fsg->data_size_from_cmnd =
-				get_unaligned_be32(&fsg->cmnd[6]) << 9;
-		if ((reply = check_command(fsg, 12, DATA_DIR_FROM_HOST,
+		msf->data_size_from_cmnd =
+				get_unaligned_be32(&msf->cmnd[6]) << 9;
+		if ((reply = msf_check_command(msf, 12, DATA_DIR_FROM_HOST,
 				(1<<1) | (0xf<<2) | (0xf<<6), 1,
 				"WRITE(12)")) == 0)
-			reply = do_write(fsg);
+			reply = msf_do_write(msf);
 		break;

 	/* Some mandatory commands that we recognize but don't implement.
@@ -2287,28 +2286,28 @@ static int do_scsi_command(struct fsg_dev *fsg)

 	default:
  unknown_cmnd:
-		fsg->data_size_from_cmnd = 0;
-		sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]);
-		if ((reply = check_command(fsg, fsg->cmnd_size,
+		msf->data_size_from_cmnd = 0;
+		sprintf(unknown, "Unknown x%02x", msf->cmnd[0]);
+		if ((reply = msf_check_command(msf, msf->cmnd_size,
 				DATA_DIR_UNKNOWN, 0xff, 0, unknown)) == 0) {
-			fsg->curlun->sense_data = SS_INVALID_COMMAND;
+			msf->curlun->sense_data = SS_INVALID_COMMAND;
 			reply = -EINVAL;
 		}
 		break;
 	}
-	up_read(&fsg->filesem);
+	up_read(&msf->filesem);

 	if (reply == -EINTR || signal_pending(current))
 		return -EINTR;

-	/* Set up the single reply buffer for finish_reply() */
+	/* Set up the single reply buffer for msf_finish_reply() */
 	if (reply == -EINVAL)
 		reply = 0;		// Error reply length
-	if (reply >= 0 && fsg->data_dir == DATA_DIR_TO_HOST) {
-		reply = min((u32) reply, fsg->data_size_from_cmnd);
+	if (reply >= 0 && msf->data_dir == DATA_DIR_TO_HOST) {
+		reply = min((u32) reply, msf->data_size_from_cmnd);
 		bh->inreq->length = reply;
 		bh->state = BUF_STATE_FULL;
-		fsg->residue -= reply;
+		msf->residue -= reply;
 	}				// Otherwise it's already set

 	return 0;
@@ -2317,20 +2316,20 @@ static int do_scsi_command(struct fsg_dev *fsg)

 /*-------------------------------------------------------------------------*/

-static int received_cbw(struct fsg_dev *fsg, struct stor_buffhd *bh)
+static int msf_received_cbw(struct msf *msf, struct stor_buffhd *bh)
 {
 	struct usb_request	*req = bh->outreq;
 	struct stor_bulk_cb_wrap	*cbw = req->buf;

 	/* Was this a real packet?  Should it be ignored? */
-	if (req->status || test_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags))
+	if (req->status || test_bit(IGNORE_BULK_OUT, &msf->atomic_bitflags))
 		return -EINVAL;

 	/* Is the CBW valid? */
 	if (req->actual != USB_BULK_CB_WRAP_LEN ||
 			cbw->Signature != cpu_to_le32(
 				USB_BULK_CB_SIG)) {
-		SDBG(fsg, "invalid CBW: len %u sig 0x%x\n",
+		SDBG(msf, "invalid CBW: len %u sig 0x%x\n",
 		     req->actual,
 		     le32_to_cpu(cbw->Signature));

@@ -2343,60 +2342,60 @@ static int received_cbw(struct fsg_dev *fsg, struct stor_buffhd *bh)
 		 * We aren't required to halt the OUT endpoint; instead
 		 * we can simply accept and discard any data received
 		 * until the next reset. */
-		wedge_bulk_in_endpoint(fsg);
-		set_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
+		msf_wedge_bulk_in_endpoint(msf);
+		set_bit(IGNORE_BULK_OUT, &msf->atomic_bitflags);
 		return -EINVAL;
 	}

 	/* Is the CBW meaningful? */
 	if (cbw->Lun >= STORAGE_MAX_LUNS || cbw->Flags & ~USB_BULK_IN_FLAG ||
 			cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) {
-		SDBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, "
+		SDBG(msf, "non-meaningful CBW: lun = %u, flags = 0x%x, "
 		     "cmdlen %u\n",
 		     cbw->Lun, cbw->Flags, cbw->Length);

 		/* We can do anything we want here, so let's stall the
 		 * bulk pipes if we are allowed to. */
 		if (mod_data.can_stall) {
-			fsg_set_halt(fsg, fsg->bulk_out);
-			halt_bulk_in_endpoint(fsg);
+			msf_set_halt(msf, msf->bulk_out);
+			msf_halt_bulk_in_endpoint(msf);
 		}
 		return -EINVAL;
 	}

 	/* Save the command for later */
-	fsg->cmnd_size = cbw->Length;
-	memcpy(fsg->cmnd, cbw->CDB, fsg->cmnd_size);
+	msf->cmnd_size = cbw->Length;
+	memcpy(msf->cmnd, cbw->CDB, msf->cmnd_size);
 	if (cbw->Flags & USB_BULK_IN_FLAG)
-		fsg->data_dir = DATA_DIR_TO_HOST;
+		msf->data_dir = DATA_DIR_TO_HOST;
 	else
-		fsg->data_dir = DATA_DIR_FROM_HOST;
-	fsg->data_size = le32_to_cpu(cbw->DataTransferLength);
-	if (fsg->data_size == 0)
-		fsg->data_dir = DATA_DIR_NONE;
-	fsg->lun = cbw->Lun;
-	fsg->tag = cbw->Tag;
+		msf->data_dir = DATA_DIR_FROM_HOST;
+	msf->data_size = le32_to_cpu(cbw->DataTransferLength);
+	if (msf->data_size == 0)
+		msf->data_dir = DATA_DIR_NONE;
+	msf->lun = cbw->Lun;
+	msf->tag = cbw->Tag;
 	return 0;
 }


-static int get_next_command(struct fsg_dev *fsg)
+static int msf_get_next_command(struct msf *msf)
 {
 	struct stor_buffhd	*bh;
 	int			rc = 0;

 	/* Wait for the next buffer to become available */
-	bh = fsg->next_buffhd_to_fill;
+	bh = msf->next_buffhd_to_fill;
 	while (bh->state != BUF_STATE_EMPTY) {
-		rc = sleep_thread(fsg);
+		rc = msf_sleep_thread(msf);
 		if (rc)
 			return rc;
 	}

 	/* Queue a request to read a Bulk-only CBW */
-	set_bulk_out_req_length(fsg, bh, USB_BULK_CB_WRAP_LEN);
+	msf_set_bulk_out_req_length(msf, bh, USB_BULK_CB_WRAP_LEN);
 	bh->outreq->short_not_ok = 1;
-	start_transfer(fsg, fsg->bulk_out, bh->outreq,
+	msf_start_transfer(msf, msf->bulk_out, bh->outreq,
 		       &bh->outreq_busy, &bh->state);

 	/* We will drain the buffer in software, which means we
@@ -2405,12 +2404,12 @@ static int get_next_command(struct fsg_dev *fsg)

 	/* Wait for the CBW to arrive */
 	while (bh->state != BUF_STATE_FULL) {
-		rc = sleep_thread(fsg);
+		rc = msf_sleep_thread(msf);
 		if (rc)
 			return rc;
 	}
 	smp_rmb();
-	rc = received_cbw(fsg, bh);
+	rc = msf_received_cbw(msf, bh);
 	bh->state = BUF_STATE_EMPTY;

 	return rc;
@@ -2419,25 +2418,25 @@ static int get_next_command(struct fsg_dev *fsg)

 /*-------------------------------------------------------------------------*/

-static int enable_endpoint(struct fsg_dev *fsg, struct usb_ep *ep,
+static int msf_enable_endpoint(struct msf *msf, struct usb_ep *ep,
 		const struct usb_endpoint_descriptor *d)
 {
 	int	rc;

-	ep->driver_data = fsg;
+	ep->driver_data = msf;
 	rc = usb_ep_enable(ep, d);
 	if (rc)
-		SERROR(fsg, "can't enable %s, result %d\n", ep->name, rc);
+		SERROR(msf, "can't enable %s, result %d\n", ep->name, rc);
 	return rc;
 }

-static int alloc_request(struct fsg_dev *fsg, struct usb_ep *ep,
+static int msf_alloc_request(struct msf *msf, struct usb_ep *ep,
 		struct usb_request **preq)
 {
 	*preq = usb_ep_alloc_request(ep, GFP_ATOMIC);
 	if (*preq)
 		return 0;
-	SERROR(fsg, "can't allocate request for %s\n", ep->name);
+	SERROR(msf, "can't allocate request for %s\n", ep->name);
 	return -ENOMEM;
 }

@@ -2446,77 +2445,77 @@ static int alloc_request(struct fsg_dev *fsg, struct usb_ep *ep,
  * Call with altsetting < 0 to disable the interface.  The only other
  * available altsetting is 0, which enables the interface.
  */
-static int do_set_interface(struct fsg_dev *fsg, int altsetting)
+static int msf_do_set_interface(struct msf *msf, int altsetting)
 {
 	int	rc = 0;
 	int	i;
 	const struct usb_endpoint_descriptor	*d;

-	if (fsg->running)
-		SDBG(fsg, "reset interface\n");
+	if (msf->running)
+		SDBG(msf, "reset interface\n");

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

 		if (bh->inreq) {
-			usb_ep_free_request(fsg->bulk_in, bh->inreq);
+			usb_ep_free_request(msf->bulk_in, bh->inreq);
 			bh->inreq = NULL;
 		}
 		if (bh->outreq) {
-			usb_ep_free_request(fsg->bulk_out, bh->outreq);
+			usb_ep_free_request(msf->bulk_out, bh->outreq);
 			bh->outreq = NULL;
 		}
 	}

 	/* Disable the endpoints */
-	if (fsg->bulk_in_enabled) {
-		usb_ep_disable(fsg->bulk_in);
-		fsg->bulk_in_enabled = 0;
+	if (msf->bulk_in_enabled) {
+		usb_ep_disable(msf->bulk_in);
+		msf->bulk_in_enabled = 0;
 	}
-	if (fsg->bulk_out_enabled) {
-		usb_ep_disable(fsg->bulk_out);
-		fsg->bulk_out_enabled = 0;
+	if (msf->bulk_out_enabled) {
+		usb_ep_disable(msf->bulk_out);
+		msf->bulk_out_enabled = 0;
 	}

-	fsg->running = 0;
+	msf->running = 0;
 	if (altsetting < 0 || rc != 0)
 		return rc;

-	SDBG(fsg, "set interface %d\n", altsetting);
+	SDBG(msf, "set interface %d\n", altsetting);

 	/* Enable the endpoints */
-	d = ep_desc(fsg->gadget, &stor_fs_bulk_in_desc, &stor_hs_bulk_in_desc);
-	if ((rc = enable_endpoint(fsg, fsg->bulk_in, d)) != 0)
+	d = ep_desc(msf->gadget, &stor_fs_bulk_in_desc, &stor_hs_bulk_in_desc);
+	if ((rc = msf_enable_endpoint(msf, msf->bulk_in, d)) != 0)
 		goto reset;
-	fsg->bulk_in_enabled = 1;
+	msf->bulk_in_enabled = 1;

-	d = ep_desc(fsg->gadget,
+	d = ep_desc(msf->gadget,
 		    &stor_fs_bulk_out_desc, &stor_hs_bulk_out_desc);
-	if ((rc = enable_endpoint(fsg, fsg->bulk_out, d)) != 0)
+	if ((rc = msf_enable_endpoint(msf, msf->bulk_out, d)) != 0)
 		goto reset;
-	fsg->bulk_out_enabled = 1;
-	fsg->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize);
-	clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
+	msf->bulk_out_enabled = 1;
+	msf->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize);
+	clear_bit(IGNORE_BULK_OUT, &msf->atomic_bitflags);

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

-		if ((rc = alloc_request(fsg, fsg->bulk_in, &bh->inreq)) != 0)
+		if ((rc = msf_alloc_request(msf, msf->bulk_in, &bh->inreq)) != 0)
 			goto reset;
-		if ((rc = alloc_request(fsg, fsg->bulk_out, &bh->outreq)) != 0)
+		if ((rc = msf_alloc_request(msf, msf->bulk_out, &bh->outreq)) != 0)
 			goto reset;
 		bh->inreq->buf = bh->outreq->buf = bh->buf;
 		bh->inreq->context = bh->outreq->context = bh;
-		bh->inreq->complete = bulk_in_complete;
-		bh->outreq->complete = bulk_out_complete;
+		bh->inreq->complete = msf_bulk_in_complete;
+		bh->outreq->complete = msf_bulk_out_complete;
 	}

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

@@ -2529,32 +2528,32 @@ reset:
  * configurations might not work with our current power sources.
  * For now we just assume the gadget is always self-powered.
  */
-static int do_set_config(struct fsg_dev *fsg, u8 new_config)
+static int msf_do_set_config(struct msf *msf, u8 new_config)
 {
 	int	rc = 0;

 	/* Disable the single interface */
-	if (fsg->config != 0) {
-		SDBG(fsg, "reset config\n");
-		fsg->config = 0;
-		rc = do_set_interface(fsg, -1);
+	if (msf->config != 0) {
+		SDBG(msf, "reset config\n");
+		msf->config = 0;
+		rc = msf_do_set_interface(msf, -1);
 	}

 	/* Enable the interface */
 	if (new_config != 0) {
-		fsg->config = new_config;
-		if ((rc = do_set_interface(fsg, 0)) != 0)
-			fsg->config = 0;	// Reset on errors
+		msf->config = new_config;
+		if ((rc = msf_do_set_interface(msf, 0)) != 0)
+			msf->config = 0;	// Reset on errors
 		else {
 			char *speed;

-			switch (fsg->gadget->speed) {
+			switch (msf->gadget->speed) {
 			case USB_SPEED_LOW:	speed = "low";	break;
 			case USB_SPEED_FULL:	speed = "full";	break;
 			case USB_SPEED_HIGH:	speed = "high";	break;
 			default: 		speed = "?";	break;
 			}
-			SINFO(fsg, "%s speed config #%d\n", speed, fsg->config);
+			SINFO(msf, "%s speed config #%d\n", speed, msf->config);
 		}
 	}
 	return rc;
@@ -2563,7 +2562,7 @@ static int do_set_config(struct fsg_dev *fsg, u8 new_config)

 /*-------------------------------------------------------------------------*/

-static void handle_exception(struct fsg_dev *fsg)
+static void msf_handle_exception(struct msf *msf)
 {
 	siginfo_t		info;
 	int			sig;
@@ -2582,69 +2581,69 @@ static void handle_exception(struct fsg_dev *fsg)
 		if (!sig)
 			break;
 		if (sig != SIGUSR1) {
-			if (fsg->state < STOR_STATE_EXIT)
-				SDBG(fsg, "Main thread exiting on signal\n");
-			raise_exception(fsg, STOR_STATE_EXIT);
+			if (msf->state < STOR_STATE_EXIT)
+				SDBG(msf, "Main thread exiting on signal\n");
+			msf_raise_exception(msf, STOR_STATE_EXIT);
 		}
 	}

 	/* Cancel all the pending transfers */
 	for (i = 0; i < STORAGE_NUM_BUFFERS; ++i) {
-		bh = &fsg->buffhds[i];
+		bh = &msf->buffhds[i];
 		if (bh->inreq_busy)
-			usb_ep_dequeue(fsg->bulk_in, bh->inreq);
+			usb_ep_dequeue(msf->bulk_in, bh->inreq);
 		if (bh->outreq_busy)
-			usb_ep_dequeue(fsg->bulk_out, bh->outreq);
+			usb_ep_dequeue(msf->bulk_out, bh->outreq);
 	}

 	/* Wait until everything is idle */
 	for (;;) {
 		int num_active = 0;
 		for (i = 0; i < STORAGE_NUM_BUFFERS; ++i) {
-			bh = &fsg->buffhds[i];
+			bh = &msf->buffhds[i];
 			num_active += bh->inreq_busy + bh->outreq_busy;
 		}
 		if (num_active == 0)
 			break;
-		if (sleep_thread(fsg))
+		if (msf_sleep_thread(msf))
 			return;
 	}

 	/* Clear out the controller's fifos */
-	if (fsg->bulk_in_enabled)
-		usb_ep_fifo_flush(fsg->bulk_in);
-	if (fsg->bulk_out_enabled)
-		usb_ep_fifo_flush(fsg->bulk_out);
+	if (msf->bulk_in_enabled)
+		usb_ep_fifo_flush(msf->bulk_in);
+	if (msf->bulk_out_enabled)
+		usb_ep_fifo_flush(msf->bulk_out);

 	/* Reset the I/O buffer states and pointers, the SCSI
 	 * state, and the exception.  Then invoke the handler. */
-	spin_lock_irq(&fsg->lock);
+	spin_lock_irq(&msf->lock);

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

-	exception_req_tag = fsg->exception_req_tag;
-	new_config = fsg->new_config;
-	old_state = fsg->state;
+	exception_req_tag = msf->exception_req_tag;
+	new_config = msf->new_config;
+	old_state = msf->state;

 	if (old_state == STOR_STATE_ABORT_BULK_OUT)
-		fsg->state = STOR_STATE_STATUS_PHASE;
+		msf->state = STOR_STATE_STATUS_PHASE;
 	else {
-		for (i = 0; i < fsg->nluns; ++i) {
-			curlun = &fsg->luns[i];
+		for (i = 0; i < msf->nluns; ++i) {
+			curlun = &msf->luns[i];
 			curlun->prevent_medium_removal = 0;
 			curlun->sense_data = curlun->unit_attention_data =
 					SS_NO_SENSE;
 			curlun->sense_data_info = 0;
 			curlun->info_valid = 0;
 		}
-		fsg->state = STOR_STATE_IDLE;
+		msf->state = STOR_STATE_IDLE;
 	}
-	spin_unlock_irq(&fsg->lock);
+	spin_unlock_irq(&msf->lock);

 	/* Carry out any extra actions required for the exception */
 	switch (old_state) {
@@ -2652,62 +2651,62 @@ static void handle_exception(struct fsg_dev *fsg)
 		break;

 	case STOR_STATE_ABORT_BULK_OUT:
-		send_status(fsg);
-		spin_lock_irq(&fsg->lock);
-		if (fsg->state == STOR_STATE_STATUS_PHASE)
-			fsg->state = STOR_STATE_IDLE;
-		spin_unlock_irq(&fsg->lock);
+		msf_send_status(msf);
+		spin_lock_irq(&msf->lock);
+		if (msf->state == STOR_STATE_STATUS_PHASE)
+			msf->state = STOR_STATE_IDLE;
+		spin_unlock_irq(&msf->lock);
 		break;

 	case STOR_STATE_RESET:
 		/* In case we were forced against our will to halt a
 		 * bulk endpoint, clear the halt now.  (The SuperH UDC
 		 * requires this.) */
-		if (test_and_clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags))
-			usb_ep_clear_halt(fsg->bulk_in);
+		if (test_and_clear_bit(IGNORE_BULK_OUT, &msf->atomic_bitflags))
+			usb_ep_clear_halt(msf->bulk_in);

-		if (fsg->ep0_req_tag == exception_req_tag)
-			ep0_queue(fsg);	// Complete the status stage
+		if (msf->ep0_req_tag == exception_req_tag)
+			msf_ep0_queue(msf);	// Complete the status stage

 		/* 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 < fsg->nluns; ++i)
-		//	fsg->luns[i].unit_attention_data = SS_RESET_OCCURRED;
+		// for (i = 0; i < msf->nluns; ++i)
+		//	msf->luns[i].unit_attention_data = SS_RESET_OCCURRED;
 		break;

 	case STOR_STATE_INTERFACE_CHANGE:
-		rc = do_set_interface(fsg, 0);
-		if (fsg->ep0_req_tag != exception_req_tag)
+		rc = msf_do_set_interface(msf, 0);
+		if (msf->ep0_req_tag != exception_req_tag)
 			break;
 		if (rc != 0)			// STALL on errors
-			fsg_set_halt(fsg, fsg->ep0);
+			msf_set_halt(msf, msf->ep0);
 		else				// Complete the status stage
-			ep0_queue(fsg);
+			msf_ep0_queue(msf);
 		break;

 	case STOR_STATE_CONFIG_CHANGE:
-		rc = do_set_config(fsg, new_config);
-		if (fsg->ep0_req_tag != exception_req_tag)
+		rc = msf_do_set_config(msf, new_config);
+		if (msf->ep0_req_tag != exception_req_tag)
 			break;
 		if (rc != 0)			// STALL on errors
-			fsg_set_halt(fsg, fsg->ep0);
+			msf_set_halt(msf, msf->ep0);
 		else				// Complete the status stage
-			ep0_queue(fsg);
+			msf_ep0_queue(msf);
 		break;

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

 	case STOR_STATE_EXIT:
 	case STOR_STATE_TERMINATED:
-		do_set_config(fsg, 0);			// Free resources
-		spin_lock_irq(&fsg->lock);
-		fsg->state = STOR_STATE_TERMINATED;	// Stop the thread
-		spin_unlock_irq(&fsg->lock);
+		msf_do_set_config(msf, 0);			// Free resources
+		spin_lock_irq(&msf->lock);
+		msf->state = STOR_STATE_TERMINATED;	// Stop the thread
+		spin_unlock_irq(&msf->lock);
 		break;
 	}
 }
@@ -2715,9 +2714,9 @@ static void handle_exception(struct fsg_dev *fsg)

 /*-------------------------------------------------------------------------*/

-static int fsg_main_thread(void *fsg_)
+static int msf_main_thread(void *msf_)
 {
-	struct fsg_dev		*fsg = fsg_;
+	struct msf		*msf = msf_;

 	/* Allow the thread to be killed by a signal, but set the signal mask
 	 * to block everything but INT, TERM, KILL, and USR1. */
@@ -2735,74 +2734,74 @@ static int fsg_main_thread(void *fsg_)
 	set_fs(get_ds());

 	/* The main loop */
-	while (fsg->state != STOR_STATE_TERMINATED) {
-		if (exception_in_progress(fsg) || signal_pending(current)) {
-			handle_exception(fsg);
+	while (msf->state != STOR_STATE_TERMINATED) {
+		if (msf_exception_in_progress(msf) || signal_pending(current)) {
+			msf_handle_exception(msf);
 			continue;
 		}

-		if (!fsg->running) {
-			sleep_thread(fsg);
+		if (!msf->running) {
+			msf_sleep_thread(msf);
 			continue;
 		}

-		if (get_next_command(fsg))
+		if (msf_get_next_command(msf))
 			continue;

-		spin_lock_irq(&fsg->lock);
-		if (!exception_in_progress(fsg))
-			fsg->state = STOR_STATE_DATA_PHASE;
-		spin_unlock_irq(&fsg->lock);
+		spin_lock_irq(&msf->lock);
+		if (!msf_exception_in_progress(msf))
+			msf->state = STOR_STATE_DATA_PHASE;
+		spin_unlock_irq(&msf->lock);

-		if (do_scsi_command(fsg) || finish_reply(fsg))
+		if (msf_do_scsi_command(msf) || msf_finish_reply(msf))
 			continue;

-		spin_lock_irq(&fsg->lock);
-		if (!exception_in_progress(fsg))
-			fsg->state = STOR_STATE_STATUS_PHASE;
-		spin_unlock_irq(&fsg->lock);
+		spin_lock_irq(&msf->lock);
+		if (!msf_exception_in_progress(msf))
+			msf->state = STOR_STATE_STATUS_PHASE;
+		spin_unlock_irq(&msf->lock);

-		if (send_status(fsg))
+		if (msf_send_status(msf))
 			continue;

-		spin_lock_irq(&fsg->lock);
-		if (!exception_in_progress(fsg))
-			fsg->state = STOR_STATE_IDLE;
-		spin_unlock_irq(&fsg->lock);
+		spin_lock_irq(&msf->lock);
+		if (!msf_exception_in_progress(msf))
+			msf->state = STOR_STATE_IDLE;
+		spin_unlock_irq(&msf->lock);
 		}

-	spin_lock_irq(&fsg->lock);
-	fsg->thread_task = NULL;
-	spin_unlock_irq(&fsg->lock);
+	spin_lock_irq(&msf->lock);
+	msf->thread_task = NULL;
+	spin_unlock_irq(&msf->lock);

 	/* If we are exiting because of a signal, unregister the
 	 * gadget driver. */
-	if (test_and_clear_bit(REGISTERED, &fsg->atomic_bitflags))
-		usb_gadget_unregister_driver(&fsg_driver);
+	if (test_and_clear_bit(REGISTERED, &msf->atomic_bitflags))
+		usb_gadget_unregister_driver(&msf_driver);

 	/* Let the unbind and cleanup routines know the thread has exited */
-	complete_and_exit(&fsg->thread_notifier, 0);
+	complete_and_exit(&msf->thread_notifier, 0);
 }


 /*-------------------------------------------------------------------------*/

-static ssize_t show_ro(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t msf_show_ro(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct storage_lun	*curlun = stor_lun_from_dev(dev);

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

-static ssize_t show_file(struct device *dev, struct device_attribute *attr,
+static ssize_t msf_show_file(struct device *dev, struct device_attribute *attr,
 		char *buf)
 {
 	struct storage_lun	*curlun = stor_lun_from_dev(dev);
-	struct fsg_dev	*fsg = dev_get_drvdata(dev);
+	struct msf	*msf = dev_get_drvdata(dev);
 	char		*p;
 	ssize_t		rc;

-	down_read(&fsg->filesem);
+	down_read(&msf->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))
@@ -2817,17 +2816,17 @@ static ssize_t show_file(struct device *dev, struct device_attribute *attr,
 		*buf = 0;
 		rc = 0;
 	}
-	up_read(&fsg->filesem);
+	up_read(&msf->filesem);
 	return rc;
 }


-static ssize_t store_ro(struct device *dev, struct device_attribute *attr,
+static ssize_t msf_store_ro(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t count)
 {
 	ssize_t		rc = count;
 	struct storage_lun	*curlun = stor_lun_from_dev(dev);
-	struct fsg_dev	*fsg = dev_get_drvdata(dev);
+	struct msf	*msf = dev_get_drvdata(dev);
 	int		i;

 	if (sscanf(buf, "%d", &i) != 1)
@@ -2835,7 +2834,7 @@ static ssize_t 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(&fsg->filesem);
+	down_read(&msf->filesem);
 	if (stor_lun_is_open(curlun)) {
 		LDBG(curlun, "read-only status change prevented\n");
 		rc = -EBUSY;
@@ -2843,15 +2842,15 @@ static ssize_t 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(&fsg->filesem);
+	up_read(&msf->filesem);
 	return rc;
 }

-static ssize_t store_file(struct device *dev, struct device_attribute *attr,
+static ssize_t msf_store_file(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t count)
 {
 	struct storage_lun	*curlun = stor_lun_from_dev(dev);
-	struct fsg_dev	*fsg = dev_get_drvdata(dev);
+	struct msf	*msf = dev_get_drvdata(dev);
 	int		rc = 0;

 	if (curlun->prevent_medium_removal && stor_lun_is_open(curlun)) {
@@ -2864,7 +2863,7 @@ static ssize_t store_file(struct device *dev, struct device_attribute *attr,
 		((char *) buf)[count-1] = 0;		// Ugh!

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


-/* The write permissions and store_xxx pointers are set in fsg_bind() */
-static DEVICE_ATTR(ro, 0444, show_ro, NULL);
-static DEVICE_ATTR(file, 0444, show_file, NULL);
+/* The write permissions and msf_store_xxx pointers are set in msf_bind() */
+static DEVICE_ATTR(ro, 0444, msf_show_ro, NULL);
+static DEVICE_ATTR(file, 0444, msf_show_file, NULL);


 /*-------------------------------------------------------------------------*/

-static void fsg_release(struct kref *ref)
+static void msf_release(struct kref *ref)
 {
-	struct fsg_dev	*fsg = container_of(ref, struct fsg_dev, ref);
+	struct msf	*msf = container_of(ref, struct msf, ref);

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

-static void lun_release(struct device *dev)
+static void stor_lun_release(struct device *dev)
 {
-	struct fsg_dev	*fsg = dev_get_drvdata(dev);
+	struct msf	*msf = dev_get_drvdata(dev);

-	kref_put(&fsg->ref, fsg_release);
+	kref_put(&msf->ref, msf_release);
 }

-static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget)
+static void /* __init_or_exit */ msf_unbind(struct usb_gadget *gadget)
 {
-	struct fsg_dev		*fsg = get_gadget_data(gadget);
+	struct msf		*msf = get_gadget_data(gadget);
 	int			i;
 	struct storage_lun		*curlun;
-	struct usb_request	*req = fsg->ep0req;
+	struct usb_request	*req = msf->ep0req;

-	SDBG(fsg, "unbind\n");
-	clear_bit(REGISTERED, &fsg->atomic_bitflags);
+	SDBG(msf, "unbind\n");
+	clear_bit(REGISTERED, &msf->atomic_bitflags);

 	/* Unregister the sysfs attribute files and the LUNs */
-	for (i = 0; i < fsg->nluns; ++i) {
-		curlun = &fsg->luns[i];
+	for (i = 0; i < msf->nluns; ++i) {
+		curlun = &msf->luns[i];
 		if (curlun->registered) {
 			device_remove_file(&curlun->dev, &dev_attr_ro);
 			device_remove_file(&curlun->dev, &dev_attr_file);
@@ -2927,50 +2926,50 @@ static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget)
 	}

 	/* If the thread isn't already dead, tell it to exit now */
-	if (fsg->state != STOR_STATE_TERMINATED) {
-		raise_exception(fsg, STOR_STATE_EXIT);
-		wait_for_completion(&fsg->thread_notifier);
+	if (msf->state != STOR_STATE_TERMINATED) {
+		msf_raise_exception(msf, STOR_STATE_EXIT);
+		wait_for_completion(&msf->thread_notifier);

 		/* The cleanup routine waits for this completion also */
-		complete(&fsg->thread_notifier);
+		complete(&msf->thread_notifier);
 	}

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

 	/* Free the request and buffer for endpoint 0 */
 	if (req) {
 		kfree(req->buf);
-		usb_ep_free_request(fsg->ep0, req);
+		usb_ep_free_request(msf->ep0, req);
 	}

 	set_gadget_data(gadget, NULL);
 }


-static int __init check_parameters(struct fsg_dev *fsg)
+static int __init msf_check_parameters(struct msf *msf)
 {
 	/* Some peripheral controllers are known not to be able to
 	 * halt bulk endpoints correctly.  If one of them is present,
 	 * disable stalls.
 	 */
-	if (gadget_is_sh(fsg->gadget) || gadget_is_at91(fsg->gadget))
+	if (gadget_is_sh(msf->gadget) || gadget_is_at91(msf->gadget))
 		mod_data.can_stall = 0;

 	if (mod_data.release == 0xffff) {	// Parameter wasn't set
 		int	gcnum;

 		/* The sa1100 controller is not supported */
-		if (gadget_is_sa1100(fsg->gadget))
+		if (gadget_is_sa1100(msf->gadget))
 			gcnum = -1;
 		else
-			gcnum = usb_gadget_controller_number(fsg->gadget);
+			gcnum = usb_gadget_controller_number(msf->gadget);
 		if (gcnum >= 0)
 			mod_data.release = 0x0300 + gcnum;
 		else {
-			SWARN(fsg, "controller '%s' not recognized\n",
-			      fsg->gadget->name);
+			SWARN(msf, "controller '%s' not recognized\n",
+			      msf->gadget->name);
 			mod_data.release = 0x0399;
 		}
 	}
@@ -2979,9 +2978,9 @@ static int __init check_parameters(struct fsg_dev *fsg)
 }


-static int __init fsg_bind(struct usb_gadget *gadget)
+static int __init msf_bind(struct usb_gadget *gadget)
 {
-	struct fsg_dev		*fsg = the_fsg;
+	struct msf		*msf = the_msf;
 	int			rc;
 	int			i;
 	struct storage_lun		*curlun;
@@ -2989,20 +2988,20 @@ static int __init fsg_bind(struct usb_gadget *gadget)
 	struct usb_request	*req;
 	char			*pathbuf, *p;

-	fsg->gadget = gadget;
-	set_gadget_data(gadget, fsg);
-	fsg->ep0 = gadget->ep0;
-	fsg->ep0->driver_data = fsg;
+	msf->gadget = gadget;
+	set_gadget_data(gadget, msf);
+	msf->ep0 = gadget->ep0;
+	msf->ep0->driver_data = msf;

-	if ((rc = check_parameters(fsg)) != 0)
+	if ((rc = msf_check_parameters(msf)) != 0)
 		goto out;

-	if (mod_data.removable) {	// Enable the store_xxx attributes
+	if (mod_data.removable) {	// Enable the msf_store_xxx attributes
 		dev_attr_file.attr.mode = 0644;
-		dev_attr_file.store = store_file;
+		dev_attr_file.store = msf_store_file;
 		if (!mod_data.cdrom) {
 			dev_attr_ro.attr.mode = 0644;
-			dev_attr_ro.store = store_ro;
+			dev_attr_ro.store = msf_store_ro;
 		}
 	}

@@ -3011,34 +3010,34 @@ static int __init fsg_bind(struct usb_gadget *gadget)
 	if (i == 0)
 		i = max(mod_data.num_filenames, 1u);
 	if (i > STORAGE_MAX_LUNS) {
-		SERROR(fsg, "invalid number of LUNs: %d\n", i);
+		SERROR(msf, "invalid number of LUNs: %d\n", i);
 		rc = -EINVAL;
 		goto out;
 	}

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

-	for (i = 0; i < fsg->nluns; ++i) {
-		curlun = &fsg->luns[i];
+	for (i = 0; i < msf->nluns; ++i) {
+		curlun = &msf->luns[i];
 		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.release = stor_lun_release;
 		curlun->dev.parent = &gadget->dev;
-		curlun->dev.driver = &fsg_driver.driver;
-		dev_set_drvdata(&curlun->dev, fsg);
+		curlun->dev.driver = &msf_driver.driver;
+		dev_set_drvdata(&curlun->dev, msf);
 		dev_set_name(&curlun->dev,"%s-lun%d",
 			     dev_name(&gadget->dev), i);

 		if ((rc = device_register(&curlun->dev)) != 0) {
-			SINFO(fsg, "failed to register LUN%d: %d\n", i, rc);
+			SINFO(msf, "failed to register LUN%d: %d\n", i, rc);
 			goto out;
 		}
 		if ((rc = device_create_file(&curlun->dev,
@@ -3049,14 +3048,14 @@ static int __init fsg_bind(struct usb_gadget *gadget)
 			goto out;
 		}
 		curlun->registered = 1;
-		kref_get(&fsg->ref);
+		kref_get(&msf->ref);

 		if (mod_data.file[i] && *mod_data.file[i]) {
 			if ((rc = stor_lun_open(curlun,
 					mod_data.file[i])) != 0)
 				goto out;
 		} else if (!mod_data.removable) {
-			SERROR(fsg, "no file given for LUN%d\n", i);
+			SERROR(msf, "no file given for LUN%d\n", i);
 			rc = -EINVAL;
 			goto out;
 		}
@@ -3067,24 +3066,24 @@ static int __init fsg_bind(struct usb_gadget *gadget)
 	ep = usb_ep_autoconfig(gadget, &stor_fs_bulk_in_desc);
 	if (!ep)
 		goto autoconf_fail;
-	ep->driver_data = fsg;		// claim the endpoint
-	fsg->bulk_in = ep;
+	ep->driver_data = msf;		// claim the endpoint
+	msf->bulk_in = ep;

 	ep = usb_ep_autoconfig(gadget, &stor_fs_bulk_out_desc);
 	if (!ep)
 		goto autoconf_fail;
-	ep->driver_data = fsg;		// claim the endpoint
-	fsg->bulk_out = ep;
+	ep->driver_data = msf;		// claim the endpoint
+	msf->bulk_out = ep;

 	/* Fix up the descriptors */
-	device_desc.bMaxPacketSize0 = fsg->ep0->maxpacket;
+	device_desc.bMaxPacketSize0 = msf->ep0->maxpacket;
 	/* device_desc.idVendor = cpu_to_le16(mod_data.vendor); */
 	/* device_desc.idProduct = cpu_to_le16(mod_data.product); */
 	device_desc.bcdDevice = cpu_to_le16(mod_data.release);

 	if (gadget_is_dualspeed(gadget)) {
 		/* Assume ep0 uses the same maxpacket value for both speeds */
-		dev_qualifier.bMaxPacketSize0 = fsg->ep0->maxpacket;
+		dev_qualifier.bMaxPacketSize0 = msf->ep0->maxpacket;

 		/* Assume endpoint addresses are the same for both speeds */
 		stor_hs_bulk_in_desc.bEndpointAddress =
@@ -3099,17 +3098,17 @@ static int __init fsg_bind(struct usb_gadget *gadget)
 	rc = -ENOMEM;

 	/* Allocate the request and buffer for endpoint 0 */
-	fsg->ep0req = req = usb_ep_alloc_request(fsg->ep0, GFP_KERNEL);
+	msf->ep0req = req = usb_ep_alloc_request(msf->ep0, GFP_KERNEL);
 	if (!req)
 		goto out;
 	req->buf = kmalloc(EP0_BUFSIZE, GFP_KERNEL);
 	if (!req->buf)
 		goto out;
-	req->complete = ep0_complete;
+	req->complete = msf_ep0_complete;

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

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

 	/* This should reflect the actual gadget power source */
 	usb_gadget_set_selfpowered(gadget);
@@ -3139,19 +3138,19 @@ static int __init fsg_bind(struct usb_gadget *gadget)
 		sprintf(&stor_string_serial[i], "%02X", c);
 	}

-	fsg->thread_task = kthread_create(fsg_main_thread, fsg,
+	msf->thread_task = kthread_create(msf_main_thread, msf,
 			"file-storage-gadget");
-	if (IS_ERR(fsg->thread_task)) {
-		rc = PTR_ERR(fsg->thread_task);
+	if (IS_ERR(msf->thread_task)) {
+		rc = PTR_ERR(msf->thread_task);
 		goto out;
 	}

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

 	pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
-	for (i = 0; i < fsg->nluns; ++i) {
-		curlun = &fsg->luns[i];
+	for (i = 0; i < msf->nluns; ++i) {
+		curlun = &msf->luns[i];
 		if (stor_lun_is_open(curlun)) {
 			p = NULL;
 			if (pathbuf) {
@@ -3166,44 +3165,44 @@ static int __init fsg_bind(struct usb_gadget *gadget)
 	}
 	kfree(pathbuf);

-	/* SDBG(fsg, "VendorID=x%04x, ProductID=x%04x, Release=x%04x\n", */
+	/* SDBG(msf, "VendorID=x%04x, ProductID=x%04x, Release=x%04x\n", */
 	/*      mod_data.vendor, mod_data.product, mod_data.release); */
-	SDBG(fsg, "removable=%d, stall=%d, cdrom=%d, buflen=%u\n",
+	SDBG(msf, "removable=%d, stall=%d, cdrom=%d, buflen=%u\n",
 	     mod_data.removable, mod_data.can_stall,
 	     mod_data.cdrom, STORAGE_BUFLEN);
-	SDBG(fsg, "I/O thread pid: %d\n", task_pid_nr(fsg->thread_task));
+	SDBG(msf, "I/O thread pid: %d\n", task_pid_nr(msf->thread_task));

-	set_bit(REGISTERED, &fsg->atomic_bitflags);
+	set_bit(REGISTERED, &msf->atomic_bitflags);

 	/* Tell the thread to start working */
-	wake_up_process(fsg->thread_task);
+	wake_up_process(msf->thread_task);
 	return 0;

 autoconf_fail:
-	SERROR(fsg, "unable to autoconfigure all endpoints\n");
+	SERROR(msf, "unable to autoconfigure all endpoints\n");
 	rc = -ENOTSUPP;

 out:
-	fsg->state = STOR_STATE_TERMINATED;	// The thread is dead
-	fsg_unbind(gadget);
-	complete(&fsg->thread_notifier);
+	msf->state = STOR_STATE_TERMINATED;	// The thread is dead
+	msf_unbind(gadget);
+	complete(&msf->thread_notifier);
 	return rc;
 }


 /*-------------------------------------------------------------------------*/

-static struct usb_gadget_driver		fsg_driver = {
+static struct usb_gadget_driver		msf_driver = {
 #ifdef CONFIG_USB_GADGET_DUALSPEED
 	.speed		= USB_SPEED_HIGH,
 #else
 	.speed		= USB_SPEED_FULL,
 #endif
 	.function	= (char *)stor_string_product,
-	.bind		= fsg_bind,
-	.unbind		= fsg_unbind,
-	.disconnect	= fsg_disconnect,
-	.setup		= fsg_setup,
+	.bind		= msf_bind,
+	.unbind		= msf_unbind,
+	.disconnect	= msf_disconnect,
+	.setup		= msf_setup,

 	.driver		= {
 		.name		= (char *) DRIVER_NAME,
@@ -3215,49 +3214,49 @@ static struct usb_gadget_driver		fsg_driver = {
 };


-static int __init fsg_alloc(void)
+static int __init msf_alloc(void)
 {
-	struct fsg_dev		*fsg;
+	struct msf		*msf;

-	fsg = kzalloc(sizeof *fsg, GFP_KERNEL);
-	if (!fsg)
+	msf = kzalloc(sizeof *msf, GFP_KERNEL);
+	if (!msf)
 		return -ENOMEM;
-	spin_lock_init(&fsg->lock);
-	init_rwsem(&fsg->filesem);
-	kref_init(&fsg->ref);
-	init_completion(&fsg->thread_notifier);
+	spin_lock_init(&msf->lock);
+	init_rwsem(&msf->filesem);
+	kref_init(&msf->ref);
+	init_completion(&msf->thread_notifier);

-	the_fsg = fsg;
+	the_msf = msf;
 	return 0;
 }


-static int __init fsg_init(void)
+static int __init msf_init(void)
 {
 	int		rc;
-	struct fsg_dev	*fsg;
+	struct msf	*msf;

-	if ((rc = fsg_alloc()) != 0)
+	if ((rc = msf_alloc()) != 0)
 		return rc;
-	fsg = the_fsg;
-	if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0)
-		kref_put(&fsg->ref, fsg_release);
+	msf = the_msf;
+	if ((rc = usb_gadget_register_driver(&msf_driver)) != 0)
+		kref_put(&msf->ref, msf_release);
 	return rc;
 }
-module_init(fsg_init);
+module_init(msf_init);


-static void __exit fsg_cleanup(void)
+static void __exit msf_cleanup(void)
 {
-	struct fsg_dev	*fsg = the_fsg;
+	struct msf	*msf = the_msf;

 	/* Unregister the driver iff the thread hasn't already done so */
-	if (test_and_clear_bit(REGISTERED, &fsg->atomic_bitflags))
-		usb_gadget_unregister_driver(&fsg_driver);
+	if (test_and_clear_bit(REGISTERED, &msf->atomic_bitflags))
+		usb_gadget_unregister_driver(&msf_driver);

 	/* Wait for the thread to finish up */
-	wait_for_completion(&fsg->thread_notifier);
+	wait_for_completion(&msf->thread_notifier);

-	kref_put(&fsg->ref, fsg_release);
+	kref_put(&msf->ref, msf_release);
 }
-module_exit(fsg_cleanup);
+module_exit(msf_cleanup);

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