diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-18 13:58:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-19 20:46:06 -0400 |
commit | 3fc3e8269fa5c1f35b518dbe18dc48acef3c7684 (patch) | |
tree | 2883b8ee8ef15352f80639bde5ab80bdd93d2c80 /drivers/usb | |
parent | b44cd112a0400d5eb381f3c1a1e7a6925911c835 (diff) |
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: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/core/message.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 530e854961ce..25f63f1096b4 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -34,13 +34,14 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) | |||
34 | { | 34 | { |
35 | struct completion done; | 35 | struct completion done; |
36 | unsigned long expire; | 36 | unsigned long expire; |
37 | int status; | 37 | int retval; |
38 | int status = urb->status; | ||
38 | 39 | ||
39 | init_completion(&done); | 40 | init_completion(&done); |
40 | urb->context = &done; | 41 | urb->context = &done; |
41 | urb->actual_length = 0; | 42 | urb->actual_length = 0; |
42 | status = usb_submit_urb(urb, GFP_NOIO); | 43 | retval = usb_submit_urb(urb, GFP_NOIO); |
43 | if (unlikely(status)) | 44 | if (unlikely(retval)) |
44 | goto out; | 45 | goto out; |
45 | 46 | ||
46 | expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT; | 47 | 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 | urb->transfer_buffer_length); | 56 | urb->transfer_buffer_length); |
56 | 57 | ||
57 | usb_kill_urb(urb); | 58 | usb_kill_urb(urb); |
58 | status = urb->status == -ENOENT ? -ETIMEDOUT : urb->status; | 59 | retval = status == -ENOENT ? -ETIMEDOUT : status; |
59 | } else | 60 | } else |
60 | status = urb->status; | 61 | retval = status; |
61 | out: | 62 | out: |
62 | if (actual_length) | 63 | if (actual_length) |
63 | *actual_length = urb->actual_length; | 64 | *actual_length = urb->actual_length; |
64 | 65 | ||
65 | usb_free_urb(urb); | 66 | usb_free_urb(urb); |
66 | return status; | 67 | return retval; |
67 | } | 68 | } |
68 | 69 | ||
69 | /*-------------------------------------------------------------------*/ | 70 | /*-------------------------------------------------------------------*/ |
@@ -250,6 +251,7 @@ static void sg_clean (struct usb_sg_request *io) | |||
250 | static void sg_complete (struct urb *urb) | 251 | static void sg_complete (struct urb *urb) |
251 | { | 252 | { |
252 | struct usb_sg_request *io = urb->context; | 253 | struct usb_sg_request *io = urb->context; |
254 | int status = urb->status; | ||
253 | 255 | ||
254 | spin_lock (&io->lock); | 256 | spin_lock (&io->lock); |
255 | 257 | ||
@@ -265,21 +267,21 @@ static void sg_complete (struct urb *urb) | |||
265 | */ | 267 | */ |
266 | if (io->status | 268 | if (io->status |
267 | && (io->status != -ECONNRESET | 269 | && (io->status != -ECONNRESET |
268 | || urb->status != -ECONNRESET) | 270 | || status != -ECONNRESET) |
269 | && urb->actual_length) { | 271 | && urb->actual_length) { |
270 | dev_err (io->dev->bus->controller, | 272 | dev_err (io->dev->bus->controller, |
271 | "dev %s ep%d%s scatterlist error %d/%d\n", | 273 | "dev %s ep%d%s scatterlist error %d/%d\n", |
272 | io->dev->devpath, | 274 | io->dev->devpath, |
273 | usb_pipeendpoint (urb->pipe), | 275 | usb_pipeendpoint (urb->pipe), |
274 | usb_pipein (urb->pipe) ? "in" : "out", | 276 | usb_pipein (urb->pipe) ? "in" : "out", |
275 | urb->status, io->status); | 277 | status, io->status); |
276 | // BUG (); | 278 | // BUG (); |
277 | } | 279 | } |
278 | 280 | ||
279 | if (io->status == 0 && urb->status && urb->status != -ECONNRESET) { | 281 | if (io->status == 0 && status && status != -ECONNRESET) { |
280 | int i, found, status; | 282 | int i, found, retval; |
281 | 283 | ||
282 | io->status = urb->status; | 284 | io->status = status; |
283 | 285 | ||
284 | /* the previous urbs, and this one, completed already. | 286 | /* the previous urbs, and this one, completed already. |
285 | * unlink pending urbs so they won't rx/tx bad data. | 287 | * unlink pending urbs so they won't rx/tx bad data. |
@@ -290,13 +292,13 @@ static void sg_complete (struct urb *urb) | |||
290 | if (!io->urbs [i] || !io->urbs [i]->dev) | 292 | if (!io->urbs [i] || !io->urbs [i]->dev) |
291 | continue; | 293 | continue; |
292 | if (found) { | 294 | if (found) { |
293 | status = usb_unlink_urb (io->urbs [i]); | 295 | retval = usb_unlink_urb (io->urbs [i]); |
294 | if (status != -EINPROGRESS | 296 | if (retval != -EINPROGRESS && |
295 | && status != -ENODEV | 297 | retval != -ENODEV && |
296 | && status != -EBUSY) | 298 | retval != -EBUSY) |
297 | dev_err (&io->dev->dev, | 299 | dev_err (&io->dev->dev, |
298 | "%s, unlink --> %d\n", | 300 | "%s, unlink --> %d\n", |
299 | __FUNCTION__, status); | 301 | __FUNCTION__, retval); |
300 | } else if (urb == io->urbs [i]) | 302 | } else if (urb == io->urbs [i]) |
301 | found = 1; | 303 | found = 1; |
302 | } | 304 | } |