Revert "USB: gadget: android: mass_storage: Use spin_lock_irqsave/spin_unlock_irqrestore"
author黄涛 <huangtao@rock-chips.com>
Sat, 30 Jul 2011 14:16:52 +0000 (22:16 +0800)
committer黄涛 <huangtao@rock-chips.com>
Sat, 30 Jul 2011 14:16:52 +0000 (22:16 +0800)
This reverts commit 3274abc33ec2c170acd6fd2732c271ad9dd0b17f.

drivers/usb/gadget/f_mass_storage.c

index f4622b36baf702f1a3db1f54447ed1cb96f9b7e9..6fccd710217bcce61c0400a9287c3138098edaf6 100755 (executable)
@@ -601,7 +601,6 @@ static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req)
 {
        struct fsg_dev          *fsg = ep->driver_data;
        struct fsg_buffhd       *bh = req->context;
-       unsigned long           flags;
 
        if (req->status || req->actual != req->length)
                DBG(fsg, "%s --> %d, %u/%u\n", __func__,
@@ -609,18 +608,17 @@ static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req)
 
        /* Hold the lock while we update the request and buffer states */
        smp_wmb();
-       spin_lock_irqsave(&fsg->lock, flags);
+       spin_lock(&fsg->lock);
        bh->inreq_busy = 0;
        bh->state = BUF_STATE_EMPTY;
        wakeup_thread(fsg);
-       spin_unlock_irqrestore(&fsg->lock, flags);
+       spin_unlock(&fsg->lock);
 }
 
 static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
 {
        struct fsg_dev          *fsg = ep->driver_data;
        struct fsg_buffhd       *bh = req->context;
-       unsigned long           flags;
 
        dump_msg(fsg, "bulk-out", req->buf, req->actual);
        if (req->status || req->actual != bh->bulk_out_intended_length)
@@ -630,11 +628,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_irqsave(&fsg->lock, flags);
+       spin_lock(&fsg->lock);
        bh->outreq_busy = 0;
        bh->state = BUF_STATE_FULL;
        wakeup_thread(fsg);
-       spin_unlock_irqrestore(&fsg->lock, flags);
+       spin_unlock(&fsg->lock);
 }
 
 static int fsg_function_setup(struct usb_function *f,
@@ -713,16 +711,15 @@ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
                enum fsg_buffer_state *state)
 {
        int     rc;
-       unsigned long           flags;
 
        DBG(fsg, "start_transfer req: %p, req->buf: %p\n", req, req->buf);
        if (ep == fsg->bulk_in)
                dump_msg(fsg, "bulk-in", req->buf, req->length);
 
-       spin_lock_irqsave(&fsg->lock, flags);
+       spin_lock_irq(&fsg->lock);
        *pbusy = 1;
        *state = BUF_STATE_BUSY;
-       spin_unlock_irqrestore(&fsg->lock, flags);
+       spin_unlock_irq(&fsg->lock);
        rc = usb_ep_queue(ep, req, GFP_KERNEL);
        if (rc != 0) {
                *pbusy = 0;
@@ -2230,9 +2227,8 @@ static void adjust_wake_lock(struct fsg_dev *fsg)
 {
        int ums_active = 0;
        int i;
-       unsigned long           flags;
 
-       spin_lock_irqsave(&fsg->lock, flags);
+       spin_lock_irq(&fsg->lock);
 
        if (fsg->config) {
                for (i = 0; i < fsg->nluns; ++i) {
@@ -2246,7 +2242,7 @@ static void adjust_wake_lock(struct fsg_dev *fsg)
        else
                wake_unlock(&fsg->wake_lock);
 
-       spin_unlock_irqrestore(&fsg->lock, flags);
+       spin_unlock_irq(&fsg->lock);
 }
 
 /*
@@ -2292,7 +2288,6 @@ static void handle_exception(struct fsg_dev *fsg)
        u8                      new_config;
        struct lun              *curlun;
        int                     rc;
-       unsigned long           flags;
 
        DBG(fsg, "handle_exception state: %d\n", (int)fsg->state);
        /* Clear the existing signals.  Anything but SIGUSR1 is converted
@@ -2322,7 +2317,7 @@ static void handle_exception(struct fsg_dev *fsg)
        }
        /* Reset the I/O buffer states and pointers, the SCSI
         * state, and the exception.  Then invoke the handler. */
-       spin_lock_irqsave(&fsg->lock, flags);
+       spin_lock_irq(&fsg->lock);
 
        for (i = 0; i < NUM_BUFFERS; ++i) {
                bh = &fsg->buffhds[i];
@@ -2347,7 +2342,7 @@ static void handle_exception(struct fsg_dev *fsg)
                }
                fsg->state = FSG_STATE_IDLE;
        }
-       spin_unlock_irqrestore(&fsg->lock, flags);
+       spin_unlock_irq(&fsg->lock);
 
        /* Carry out any extra actions required for the exception */
        switch (old_state) {
@@ -2356,10 +2351,10 @@ static void handle_exception(struct fsg_dev *fsg)
 
        case FSG_STATE_ABORT_BULK_OUT:
                DBG(fsg, "FSG_STATE_ABORT_BULK_OUT\n");
-               spin_lock_irqsave(&fsg->lock, flags);
+               spin_lock_irq(&fsg->lock);
                if (fsg->state == FSG_STATE_STATUS_PHASE)
                        fsg->state = FSG_STATE_IDLE;
-               spin_unlock_irqrestore(&fsg->lock, flags);
+               spin_unlock_irq(&fsg->lock);
                break;
 
        case FSG_STATE_RESET:
@@ -2383,9 +2378,9 @@ static void handle_exception(struct fsg_dev *fsg)
                        do_set_interface(fsg, -1);
                }
                do_set_config(fsg, 0);                  /* Free resources */
-               spin_lock_irqsave(&fsg->lock, flags);
+               spin_lock_irq(&fsg->lock);
                fsg->state = FSG_STATE_TERMINATED;      /* Stop the thread */
-               spin_unlock_irqrestore(&fsg->lock, flags);
+               spin_unlock_irq(&fsg->lock);
                break;
        }
 }
@@ -2396,7 +2391,6 @@ static void handle_exception(struct fsg_dev *fsg)
 static int fsg_main_thread(void *fsg_)
 {
        struct fsg_dev          *fsg = fsg_;
-       unsigned long           flags;
 
        /* Allow the thread to be killed by a signal, but set the signal mask
         * to block everything but INT, TERM, KILL, and USR1. */
@@ -2428,31 +2422,31 @@ static int fsg_main_thread(void *fsg_)
                if (get_next_command(fsg))
                        continue;
 
-               spin_lock_irqsave(&fsg->lock, flags);
+               spin_lock_irq(&fsg->lock);
                if (!exception_in_progress(fsg))
                        fsg->state = FSG_STATE_DATA_PHASE;
-               spin_unlock_irqrestore(&fsg->lock, flags);
+               spin_unlock_irq(&fsg->lock);
 
                if (do_scsi_command(fsg) || finish_reply(fsg))
                        continue;
 
-               spin_lock_irqsave(&fsg->lock, flags);
+               spin_lock_irq(&fsg->lock);
                if (!exception_in_progress(fsg))
                        fsg->state = FSG_STATE_STATUS_PHASE;
-               spin_unlock_irqrestore(&fsg->lock, flags);
+               spin_unlock_irq(&fsg->lock);
 
                if (send_status(fsg))
                        continue;
 
-               spin_lock_irqsave(&fsg->lock, flags);
+               spin_lock_irq(&fsg->lock);
                if (!exception_in_progress(fsg))
                        fsg->state = FSG_STATE_IDLE;
-               spin_unlock_irqrestore(&fsg->lock, flags);
-       }
+               spin_unlock_irq(&fsg->lock);
+               }
 
-       spin_lock_irqsave(&fsg->lock, flags);
+       spin_lock_irq(&fsg->lock);
        fsg->thread_task = NULL;
-       spin_unlock_irqrestore(&fsg->lock, flags);
+       spin_unlock_irq(&fsg->lock);
 
        /* In case we are exiting because of a signal, unregister the
         * gadget driver and close the backing file. */