提交 3fc3e826 编写于 作者: G Greg Kroah-Hartman

USB: core: message: clean up urb->status usage

This done in anticipation of removal of urb->status, which will make
that patch easier to review and apply in the future.
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 b44cd112
...@@ -34,13 +34,14 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) ...@@ -34,13 +34,14 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
{ {
struct completion done; struct completion done;
unsigned long expire; unsigned long expire;
int status; int retval;
int status = urb->status;
init_completion(&done); init_completion(&done);
urb->context = &done; urb->context = &done;
urb->actual_length = 0; urb->actual_length = 0;
status = usb_submit_urb(urb, GFP_NOIO); retval = usb_submit_urb(urb, GFP_NOIO);
if (unlikely(status)) if (unlikely(retval))
goto out; goto out;
expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT; expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT;
...@@ -55,15 +56,15 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) ...@@ -55,15 +56,15 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
urb->transfer_buffer_length); urb->transfer_buffer_length);
usb_kill_urb(urb); usb_kill_urb(urb);
status = urb->status == -ENOENT ? -ETIMEDOUT : urb->status; retval = status == -ENOENT ? -ETIMEDOUT : status;
} else } else
status = urb->status; retval = status;
out: out:
if (actual_length) if (actual_length)
*actual_length = urb->actual_length; *actual_length = urb->actual_length;
usb_free_urb(urb); usb_free_urb(urb);
return status; return retval;
} }
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
...@@ -250,6 +251,7 @@ static void sg_clean (struct usb_sg_request *io) ...@@ -250,6 +251,7 @@ static void sg_clean (struct usb_sg_request *io)
static void sg_complete (struct urb *urb) static void sg_complete (struct urb *urb)
{ {
struct usb_sg_request *io = urb->context; struct usb_sg_request *io = urb->context;
int status = urb->status;
spin_lock (&io->lock); spin_lock (&io->lock);
...@@ -265,21 +267,21 @@ static void sg_complete (struct urb *urb) ...@@ -265,21 +267,21 @@ static void sg_complete (struct urb *urb)
*/ */
if (io->status if (io->status
&& (io->status != -ECONNRESET && (io->status != -ECONNRESET
|| urb->status != -ECONNRESET) || status != -ECONNRESET)
&& urb->actual_length) { && urb->actual_length) {
dev_err (io->dev->bus->controller, dev_err (io->dev->bus->controller,
"dev %s ep%d%s scatterlist error %d/%d\n", "dev %s ep%d%s scatterlist error %d/%d\n",
io->dev->devpath, io->dev->devpath,
usb_pipeendpoint (urb->pipe), usb_pipeendpoint (urb->pipe),
usb_pipein (urb->pipe) ? "in" : "out", usb_pipein (urb->pipe) ? "in" : "out",
urb->status, io->status); status, io->status);
// BUG (); // BUG ();
} }
if (io->status == 0 && urb->status && urb->status != -ECONNRESET) { if (io->status == 0 && status && status != -ECONNRESET) {
int i, found, status; int i, found, retval;
io->status = urb->status; io->status = status;
/* the previous urbs, and this one, completed already. /* the previous urbs, and this one, completed already.
* unlink pending urbs so they won't rx/tx bad data. * unlink pending urbs so they won't rx/tx bad data.
...@@ -290,13 +292,13 @@ static void sg_complete (struct urb *urb) ...@@ -290,13 +292,13 @@ static void sg_complete (struct urb *urb)
if (!io->urbs [i] || !io->urbs [i]->dev) if (!io->urbs [i] || !io->urbs [i]->dev)
continue; continue;
if (found) { if (found) {
status = usb_unlink_urb (io->urbs [i]); retval = usb_unlink_urb (io->urbs [i]);
if (status != -EINPROGRESS if (retval != -EINPROGRESS &&
&& status != -ENODEV retval != -ENODEV &&
&& status != -EBUSY) retval != -EBUSY)
dev_err (&io->dev->dev, dev_err (&io->dev->dev,
"%s, unlink --> %d\n", "%s, unlink --> %d\n",
__FUNCTION__, status); __FUNCTION__, retval);
} else if (urb == io->urbs [i]) } else if (urb == io->urbs [i])
found = 1; found = 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册