Commit 32bf9fd5 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

usb-storage: make use of srb local variable

Commit 8b52291a ("usb-storage: fix deadlock involving host lock
and scsi_done") added a local variable to usb_stor_control_thread() in
the usb-storage driver.  This local variable holds the value of
us->srb, for use after the host lock has been released.

But as long as we have the value in a local variable, we may as well
use it instead of dereferencing the us pointer all over the place.
This patch makes no functional change; it just makes the code a little
shorter and a little neater.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f93de0c2
...@@ -332,7 +332,7 @@ static int usb_stor_control_thread(void * __us) ...@@ -332,7 +332,7 @@ static int usb_stor_control_thread(void * __us)
/* When we are called with no command pending, we're done */ /* When we are called with no command pending, we're done */
srb = us->srb; srb = us->srb;
if (us->srb == NULL) { if (srb == NULL) {
scsi_unlock(host); scsi_unlock(host);
mutex_unlock(&us->dev_mutex); mutex_unlock(&us->dev_mutex);
usb_stor_dbg(us, "-- exiting\n"); usb_stor_dbg(us, "-- exiting\n");
...@@ -341,7 +341,7 @@ static int usb_stor_control_thread(void * __us) ...@@ -341,7 +341,7 @@ static int usb_stor_control_thread(void * __us)
/* has the command timed out *already* ? */ /* has the command timed out *already* ? */
if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
us->srb->result = DID_ABORT << 16; srb->result = DID_ABORT << 16;
goto SkipForAbort; goto SkipForAbort;
} }
...@@ -351,35 +351,35 @@ static int usb_stor_control_thread(void * __us) ...@@ -351,35 +351,35 @@ static int usb_stor_control_thread(void * __us)
* reject the command if the direction indicator * reject the command if the direction indicator
* is UNKNOWN * is UNKNOWN
*/ */
if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) { if (srb->sc_data_direction == DMA_BIDIRECTIONAL) {
usb_stor_dbg(us, "UNKNOWN data direction\n"); usb_stor_dbg(us, "UNKNOWN data direction\n");
us->srb->result = DID_ERROR << 16; srb->result = DID_ERROR << 16;
} }
/* /*
* reject if target != 0 or if LUN is higher than * reject if target != 0 or if LUN is higher than
* the maximum known LUN * the maximum known LUN
*/ */
else if (us->srb->device->id && else if (srb->device->id &&
!(us->fflags & US_FL_SCM_MULT_TARG)) { !(us->fflags & US_FL_SCM_MULT_TARG)) {
usb_stor_dbg(us, "Bad target number (%d:%llu)\n", usb_stor_dbg(us, "Bad target number (%d:%llu)\n",
us->srb->device->id, srb->device->id,
us->srb->device->lun); srb->device->lun);
us->srb->result = DID_BAD_TARGET << 16; srb->result = DID_BAD_TARGET << 16;
} }
else if (us->srb->device->lun > us->max_lun) { else if (srb->device->lun > us->max_lun) {
usb_stor_dbg(us, "Bad LUN (%d:%llu)\n", usb_stor_dbg(us, "Bad LUN (%d:%llu)\n",
us->srb->device->id, srb->device->id,
us->srb->device->lun); srb->device->lun);
us->srb->result = DID_BAD_TARGET << 16; srb->result = DID_BAD_TARGET << 16;
} }
/* /*
* Handle those devices which need us to fake * Handle those devices which need us to fake
* their inquiry data * their inquiry data
*/ */
else if ((us->srb->cmnd[0] == INQUIRY) && else if ((srb->cmnd[0] == INQUIRY) &&
(us->fflags & US_FL_FIX_INQUIRY)) { (us->fflags & US_FL_FIX_INQUIRY)) {
unsigned char data_ptr[36] = { unsigned char data_ptr[36] = {
0x00, 0x80, 0x02, 0x02, 0x00, 0x80, 0x02, 0x02,
...@@ -387,13 +387,13 @@ static int usb_stor_control_thread(void * __us) ...@@ -387,13 +387,13 @@ static int usb_stor_control_thread(void * __us)
usb_stor_dbg(us, "Faking INQUIRY command\n"); usb_stor_dbg(us, "Faking INQUIRY command\n");
fill_inquiry_response(us, data_ptr, 36); fill_inquiry_response(us, data_ptr, 36);
us->srb->result = SAM_STAT_GOOD; srb->result = SAM_STAT_GOOD;
} }
/* we've got a command, let's do it! */ /* we've got a command, let's do it! */
else { else {
US_DEBUG(usb_stor_show_command(us, us->srb)); US_DEBUG(usb_stor_show_command(us, srb));
us->proto_handler(us->srb, us); us->proto_handler(srb, us);
usb_mark_last_busy(us->pusb_dev); usb_mark_last_busy(us->pusb_dev);
} }
...@@ -401,7 +401,7 @@ static int usb_stor_control_thread(void * __us) ...@@ -401,7 +401,7 @@ static int usb_stor_control_thread(void * __us)
scsi_lock(host); scsi_lock(host);
/* was the command aborted? */ /* was the command aborted? */
if (us->srb->result == DID_ABORT << 16) { if (srb->result == DID_ABORT << 16) {
SkipForAbort: SkipForAbort:
usb_stor_dbg(us, "scsi command aborted\n"); usb_stor_dbg(us, "scsi command aborted\n");
srb = NULL; /* Don't call srb->scsi_done() */ srb = NULL; /* Don't call srb->scsi_done() */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment