Commit dbd98231 authored by Tilman Schmidt's avatar Tilman Schmidt Committed by Linus Torvalds

gigaset: clean up urb->status usage

Make there only be one reference to urb->status per URB callback, and none
outside, in preparation for removal of that field.
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Cc: Greg KH <gregkh@suse.de>
Cc: Hansjoerg Lipp <hjlipp@web.de>
Cc: Karsten Keil <kkeil@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f47cd9b5
...@@ -248,12 +248,12 @@ static inline void dump_urb(enum debuglevel level, const char *tag, ...@@ -248,12 +248,12 @@ static inline void dump_urb(enum debuglevel level, const char *tag,
if (urb) { if (urb) {
gig_dbg(level, gig_dbg(level,
" dev=0x%08lx, pipe=%s:EP%d/DV%d:%s, " " dev=0x%08lx, pipe=%s:EP%d/DV%d:%s, "
"status=%d, hcpriv=0x%08lx, transfer_flags=0x%x,", "hcpriv=0x%08lx, transfer_flags=0x%x,",
(unsigned long) urb->dev, (unsigned long) urb->dev,
usb_pipetype_str(urb->pipe), usb_pipetype_str(urb->pipe),
usb_pipeendpoint(urb->pipe), usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe), usb_pipedevice(urb->pipe),
usb_pipein(urb->pipe) ? "in" : "out", usb_pipein(urb->pipe) ? "in" : "out",
urb->status, (unsigned long) urb->hcpriv, (unsigned long) urb->hcpriv,
urb->transfer_flags); urb->transfer_flags);
gig_dbg(level, gig_dbg(level,
" transfer_buffer=0x%08lx[%d], actual_length=%d, " " transfer_buffer=0x%08lx[%d], actual_length=%d, "
...@@ -459,6 +459,7 @@ static void read_ctrl_callback(struct urb *urb) ...@@ -459,6 +459,7 @@ static void read_ctrl_callback(struct urb *urb)
struct inbuf_t *inbuf = urb->context; struct inbuf_t *inbuf = urb->context;
struct cardstate *cs = inbuf->cs; struct cardstate *cs = inbuf->cs;
struct bas_cardstate *ucs = cs->hw.bas; struct bas_cardstate *ucs = cs->hw.bas;
int status = urb->status;
int have_data = 0; int have_data = 0;
unsigned numbytes; unsigned numbytes;
int rc; int rc;
...@@ -472,7 +473,7 @@ static void read_ctrl_callback(struct urb *urb) ...@@ -472,7 +473,7 @@ static void read_ctrl_callback(struct urb *urb)
del_timer(&ucs->timer_cmd_in); del_timer(&ucs->timer_cmd_in);
switch (urb->status) { switch (status) {
case 0: /* normal completion */ case 0: /* normal completion */
numbytes = urb->actual_length; numbytes = urb->actual_length;
if (unlikely(numbytes != ucs->rcvbuf_size)) { if (unlikely(numbytes != ucs->rcvbuf_size)) {
...@@ -506,12 +507,12 @@ static void read_ctrl_callback(struct urb *urb) ...@@ -506,12 +507,12 @@ static void read_ctrl_callback(struct urb *urb)
case -ESHUTDOWN: /* device shut down */ case -ESHUTDOWN: /* device shut down */
/* no action necessary */ /* no action necessary */
gig_dbg(DEBUG_USBREQ, "%s: %s", gig_dbg(DEBUG_USBREQ, "%s: %s",
__func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(status));
break; break;
default: /* severe trouble */ default: /* severe trouble */
dev_warn(cs->dev, "control read: %s\n", dev_warn(cs->dev, "control read: %s\n",
get_usb_statmsg(urb->status)); get_usb_statmsg(status));
if (ucs->retry_cmd_in++ < BAS_RETRY) { if (ucs->retry_cmd_in++ < BAS_RETRY) {
dev_notice(cs->dev, "control read: retry %d\n", dev_notice(cs->dev, "control read: retry %d\n",
ucs->retry_cmd_in); ucs->retry_cmd_in);
...@@ -601,12 +602,13 @@ static void read_int_callback(struct urb *urb) ...@@ -601,12 +602,13 @@ static void read_int_callback(struct urb *urb)
struct cardstate *cs = urb->context; struct cardstate *cs = urb->context;
struct bas_cardstate *ucs = cs->hw.bas; struct bas_cardstate *ucs = cs->hw.bas;
struct bc_state *bcs; struct bc_state *bcs;
int status = urb->status;
unsigned long flags; unsigned long flags;
int rc; int rc;
unsigned l; unsigned l;
int channel; int channel;
switch (urb->status) { switch (status) {
case 0: /* success */ case 0: /* success */
break; break;
case -ENOENT: /* cancelled */ case -ENOENT: /* cancelled */
...@@ -614,7 +616,7 @@ static void read_int_callback(struct urb *urb) ...@@ -614,7 +616,7 @@ static void read_int_callback(struct urb *urb)
case -EINPROGRESS: /* pending */ case -EINPROGRESS: /* pending */
/* ignore silently */ /* ignore silently */
gig_dbg(DEBUG_USBREQ, "%s: %s", gig_dbg(DEBUG_USBREQ, "%s: %s",
__func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(status));
return; return;
case -ENODEV: /* device removed */ case -ENODEV: /* device removed */
case -ESHUTDOWN: /* device shut down */ case -ESHUTDOWN: /* device shut down */
...@@ -623,7 +625,7 @@ static void read_int_callback(struct urb *urb) ...@@ -623,7 +625,7 @@ static void read_int_callback(struct urb *urb)
return; return;
default: /* severe trouble */ default: /* severe trouble */
dev_warn(cs->dev, "interrupt read: %s\n", dev_warn(cs->dev, "interrupt read: %s\n",
get_usb_statmsg(urb->status)); get_usb_statmsg(status));
//FIXME corrective action? resubmission always ok? //FIXME corrective action? resubmission always ok?
goto resubmit; goto resubmit;
} }
...@@ -766,17 +768,18 @@ static void read_iso_callback(struct urb *urb) ...@@ -766,17 +768,18 @@ static void read_iso_callback(struct urb *urb)
{ {
struct bc_state *bcs; struct bc_state *bcs;
struct bas_bc_state *ubc; struct bas_bc_state *ubc;
int status = urb->status;
unsigned long flags; unsigned long flags;
int i, rc; int i, rc;
/* status codes not worth bothering the tasklet with */ /* status codes not worth bothering the tasklet with */
if (unlikely(urb->status == -ENOENT || if (unlikely(status == -ENOENT ||
urb->status == -ECONNRESET || status == -ECONNRESET ||
urb->status == -EINPROGRESS || status == -EINPROGRESS ||
urb->status == -ENODEV || status == -ENODEV ||
urb->status == -ESHUTDOWN)) { status == -ESHUTDOWN)) {
gig_dbg(DEBUG_ISO, "%s: %s", gig_dbg(DEBUG_ISO, "%s: %s",
__func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(status));
return; return;
} }
...@@ -787,10 +790,11 @@ static void read_iso_callback(struct urb *urb) ...@@ -787,10 +790,11 @@ static void read_iso_callback(struct urb *urb)
if (likely(ubc->isoindone == NULL)) { if (likely(ubc->isoindone == NULL)) {
/* pass URB to tasklet */ /* pass URB to tasklet */
ubc->isoindone = urb; ubc->isoindone = urb;
ubc->isoinstatus = status;
tasklet_schedule(&ubc->rcvd_tasklet); tasklet_schedule(&ubc->rcvd_tasklet);
} else { } else {
/* tasklet still busy, drop data and resubmit URB */ /* tasklet still busy, drop data and resubmit URB */
ubc->loststatus = urb->status; ubc->loststatus = status;
for (i = 0; i < BAS_NUMFRAMES; i++) { for (i = 0; i < BAS_NUMFRAMES; i++) {
ubc->isoinlost += urb->iso_frame_desc[i].actual_length; ubc->isoinlost += urb->iso_frame_desc[i].actual_length;
if (unlikely(urb->iso_frame_desc[i].status != 0 && if (unlikely(urb->iso_frame_desc[i].status != 0 &&
...@@ -831,22 +835,24 @@ static void write_iso_callback(struct urb *urb) ...@@ -831,22 +835,24 @@ static void write_iso_callback(struct urb *urb)
{ {
struct isow_urbctx_t *ucx; struct isow_urbctx_t *ucx;
struct bas_bc_state *ubc; struct bas_bc_state *ubc;
int status = urb->status;
unsigned long flags; unsigned long flags;
/* status codes not worth bothering the tasklet with */ /* status codes not worth bothering the tasklet with */
if (unlikely(urb->status == -ENOENT || if (unlikely(status == -ENOENT ||
urb->status == -ECONNRESET || status == -ECONNRESET ||
urb->status == -EINPROGRESS || status == -EINPROGRESS ||
urb->status == -ENODEV || status == -ENODEV ||
urb->status == -ESHUTDOWN)) { status == -ESHUTDOWN)) {
gig_dbg(DEBUG_ISO, "%s: %s", gig_dbg(DEBUG_ISO, "%s: %s",
__func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(status));
return; return;
} }
/* pass URB context to tasklet */ /* pass URB context to tasklet */
ucx = urb->context; ucx = urb->context;
ubc = ucx->bcs->hw.bas; ubc = ucx->bcs->hw.bas;
ucx->status = status;
spin_lock_irqsave(&ubc->isooutlock, flags); spin_lock_irqsave(&ubc->isooutlock, flags);
ubc->isooutovfl = ubc->isooutdone; ubc->isooutovfl = ubc->isooutdone;
...@@ -1070,6 +1076,7 @@ static void write_iso_tasklet(unsigned long data) ...@@ -1070,6 +1076,7 @@ static void write_iso_tasklet(unsigned long data)
struct cardstate *cs = bcs->cs; struct cardstate *cs = bcs->cs;
struct isow_urbctx_t *done, *next, *ovfl; struct isow_urbctx_t *done, *next, *ovfl;
struct urb *urb; struct urb *urb;
int status;
struct usb_iso_packet_descriptor *ifd; struct usb_iso_packet_descriptor *ifd;
int offset; int offset;
unsigned long flags; unsigned long flags;
...@@ -1126,7 +1133,8 @@ static void write_iso_tasklet(unsigned long data) ...@@ -1126,7 +1133,8 @@ static void write_iso_tasklet(unsigned long data)
/* process completed URB */ /* process completed URB */
urb = done->urb; urb = done->urb;
switch (urb->status) { status = done->status;
switch (status) {
case -EXDEV: /* partial completion */ case -EXDEV: /* partial completion */
gig_dbg(DEBUG_ISO, "%s: URB partially completed", gig_dbg(DEBUG_ISO, "%s: URB partially completed",
__func__); __func__);
...@@ -1179,7 +1187,7 @@ static void write_iso_tasklet(unsigned long data) ...@@ -1179,7 +1187,7 @@ static void write_iso_tasklet(unsigned long data)
break; break;
default: /* severe trouble */ default: /* severe trouble */
dev_warn(cs->dev, "isochronous write: %s\n", dev_warn(cs->dev, "isochronous write: %s\n",
get_usb_statmsg(urb->status)); get_usb_statmsg(status));
} }
/* mark the write buffer area covered by this URB as free */ /* mark the write buffer area covered by this URB as free */
...@@ -1233,6 +1241,7 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1233,6 +1241,7 @@ static void read_iso_tasklet(unsigned long data)
struct bas_bc_state *ubc = bcs->hw.bas; struct bas_bc_state *ubc = bcs->hw.bas;
struct cardstate *cs = bcs->cs; struct cardstate *cs = bcs->cs;
struct urb *urb; struct urb *urb;
int status;
char *rcvbuf; char *rcvbuf;
unsigned long flags; unsigned long flags;
int totleft, numbytes, offset, frame, rc; int totleft, numbytes, offset, frame, rc;
...@@ -1245,6 +1254,7 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1245,6 +1254,7 @@ static void read_iso_tasklet(unsigned long data)
spin_unlock_irqrestore(&ubc->isoinlock, flags); spin_unlock_irqrestore(&ubc->isoinlock, flags);
return; return;
} }
status = ubc->isoinstatus;
ubc->isoindone = NULL; ubc->isoindone = NULL;
if (unlikely(ubc->loststatus != -EINPROGRESS)) { if (unlikely(ubc->loststatus != -EINPROGRESS)) {
dev_warn(cs->dev, dev_warn(cs->dev,
...@@ -1260,11 +1270,11 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1260,11 +1270,11 @@ static void read_iso_tasklet(unsigned long data)
gig_dbg(DEBUG_ISO, gig_dbg(DEBUG_ISO,
"%s: channel not running, " "%s: channel not running, "
"dropped URB with status: %s", "dropped URB with status: %s",
__func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(status));
return; return;
} }
switch (urb->status) { switch (status) {
case 0: /* normal completion */ case 0: /* normal completion */
break; break;
case -EXDEV: /* inspect individual frames case -EXDEV: /* inspect individual frames
...@@ -1276,7 +1286,7 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1276,7 +1286,7 @@ static void read_iso_tasklet(unsigned long data)
case -ECONNRESET: case -ECONNRESET:
case -EINPROGRESS: case -EINPROGRESS:
gig_dbg(DEBUG_ISO, "%s: %s", gig_dbg(DEBUG_ISO, "%s: %s",
__func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(status));
continue; /* -> skip */ continue; /* -> skip */
case -EPIPE: case -EPIPE:
dev_err(cs->dev, "isochronous read stalled\n"); dev_err(cs->dev, "isochronous read stalled\n");
...@@ -1284,7 +1294,7 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1284,7 +1294,7 @@ static void read_iso_tasklet(unsigned long data)
continue; /* -> skip */ continue; /* -> skip */
default: /* severe trouble */ default: /* severe trouble */
dev_warn(cs->dev, "isochronous read: %s\n", dev_warn(cs->dev, "isochronous read: %s\n",
get_usb_statmsg(urb->status)); get_usb_statmsg(status));
goto error; goto error;
} }
...@@ -1418,11 +1428,12 @@ static void req_timeout(unsigned long data) ...@@ -1418,11 +1428,12 @@ static void req_timeout(unsigned long data)
static void write_ctrl_callback(struct urb *urb) static void write_ctrl_callback(struct urb *urb)
{ {
struct bas_cardstate *ucs = urb->context; struct bas_cardstate *ucs = urb->context;
int status = urb->status;
int rc; int rc;
unsigned long flags; unsigned long flags;
/* check status */ /* check status */
switch (urb->status) { switch (status) {
case 0: /* normal completion */ case 0: /* normal completion */
spin_lock_irqsave(&ucs->lock, flags); spin_lock_irqsave(&ucs->lock, flags);
switch (ucs->pending) { switch (ucs->pending) {
...@@ -1441,7 +1452,7 @@ static void write_ctrl_callback(struct urb *urb) ...@@ -1441,7 +1452,7 @@ static void write_ctrl_callback(struct urb *urb)
case -ESHUTDOWN: /* device shut down */ case -ESHUTDOWN: /* device shut down */
/* ignore silently */ /* ignore silently */
gig_dbg(DEBUG_USBREQ, "%s: %s", gig_dbg(DEBUG_USBREQ, "%s: %s",
__func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(status));
break; break;
default: /* any failure */ default: /* any failure */
...@@ -1449,12 +1460,12 @@ static void write_ctrl_callback(struct urb *urb) ...@@ -1449,12 +1460,12 @@ static void write_ctrl_callback(struct urb *urb)
dev_err(&ucs->interface->dev, dev_err(&ucs->interface->dev,
"control request 0x%02x failed: %s\n", "control request 0x%02x failed: %s\n",
ucs->dr_ctrl.bRequest, ucs->dr_ctrl.bRequest,
get_usb_statmsg(urb->status)); get_usb_statmsg(status));
break; /* give up */ break; /* give up */
} }
dev_notice(&ucs->interface->dev, dev_notice(&ucs->interface->dev,
"control request 0x%02x: %s, retry %d\n", "control request 0x%02x: %s, retry %d\n",
ucs->dr_ctrl.bRequest, get_usb_statmsg(urb->status), ucs->dr_ctrl.bRequest, get_usb_statmsg(status),
ucs->retry_ctrl); ucs->retry_ctrl);
/* urb->dev is clobbered by USB subsystem */ /* urb->dev is clobbered by USB subsystem */
urb->dev = ucs->udev; urb->dev = ucs->udev;
...@@ -1665,12 +1676,13 @@ static void write_command_callback(struct urb *urb) ...@@ -1665,12 +1676,13 @@ static void write_command_callback(struct urb *urb)
{ {
struct cardstate *cs = urb->context; struct cardstate *cs = urb->context;
struct bas_cardstate *ucs = cs->hw.bas; struct bas_cardstate *ucs = cs->hw.bas;
int status = urb->status;
unsigned long flags; unsigned long flags;
update_basstate(ucs, 0, BS_ATWRPEND); update_basstate(ucs, 0, BS_ATWRPEND);
/* check status */ /* check status */
switch (urb->status) { switch (status) {
case 0: /* normal completion */ case 0: /* normal completion */
break; break;
case -ENOENT: /* cancelled */ case -ENOENT: /* cancelled */
...@@ -1680,14 +1692,14 @@ static void write_command_callback(struct urb *urb) ...@@ -1680,14 +1692,14 @@ static void write_command_callback(struct urb *urb)
case -ESHUTDOWN: /* device shut down */ case -ESHUTDOWN: /* device shut down */
/* ignore silently */ /* ignore silently */
gig_dbg(DEBUG_USBREQ, "%s: %s", gig_dbg(DEBUG_USBREQ, "%s: %s",
__func__, get_usb_statmsg(urb->status)); __func__, get_usb_statmsg(status));
return; return;
default: /* any failure */ default: /* any failure */
if (++ucs->retry_cmd_out > BAS_RETRY) { if (++ucs->retry_cmd_out > BAS_RETRY) {
dev_warn(cs->dev, dev_warn(cs->dev,
"command write: %s, " "command write: %s, "
"giving up after %d retries\n", "giving up after %d retries\n",
get_usb_statmsg(urb->status), get_usb_statmsg(status),
ucs->retry_cmd_out); ucs->retry_cmd_out);
break; break;
} }
...@@ -1695,11 +1707,11 @@ static void write_command_callback(struct urb *urb) ...@@ -1695,11 +1707,11 @@ static void write_command_callback(struct urb *urb)
dev_warn(cs->dev, dev_warn(cs->dev,
"command write: %s, " "command write: %s, "
"cannot retry - cmdbuf gone\n", "cannot retry - cmdbuf gone\n",
get_usb_statmsg(urb->status)); get_usb_statmsg(status));
break; break;
} }
dev_notice(cs->dev, "command write: %s, retry %d\n", dev_notice(cs->dev, "command write: %s, retry %d\n",
get_usb_statmsg(urb->status), ucs->retry_cmd_out); get_usb_statmsg(status), ucs->retry_cmd_out);
if (atwrite_submit(cs, cs->cmdbuf->buf, cs->cmdbuf->len) >= 0) if (atwrite_submit(cs, cs->cmdbuf->buf, cs->cmdbuf->len) >= 0)
/* resubmitted - bypass regular exit block */ /* resubmitted - bypass regular exit block */
return; return;
......
...@@ -350,11 +350,13 @@ struct isowbuf_t { ...@@ -350,11 +350,13 @@ struct isowbuf_t {
* - urb: pointer to the URB itself * - urb: pointer to the URB itself
* - bcs: pointer to the B Channel control structure * - bcs: pointer to the B Channel control structure
* - limit: end of write buffer area covered by this URB * - limit: end of write buffer area covered by this URB
* - status: URB completion status
*/ */
struct isow_urbctx_t { struct isow_urbctx_t {
struct urb *urb; struct urb *urb;
struct bc_state *bcs; struct bc_state *bcs;
int limit; int limit;
int status;
}; };
/* AT state structure /* AT state structure
...@@ -574,6 +576,7 @@ struct bas_bc_state { ...@@ -574,6 +576,7 @@ struct bas_bc_state {
struct urb *isoinurbs[BAS_INURBS]; struct urb *isoinurbs[BAS_INURBS];
unsigned char isoinbuf[BAS_INBUFSIZE * BAS_INURBS]; unsigned char isoinbuf[BAS_INBUFSIZE * BAS_INURBS];
struct urb *isoindone; /* completed isoc read URB */ struct urb *isoindone; /* completed isoc read URB */
int isoinstatus; /* status of completed URB */
int loststatus; /* status of dropped URB */ int loststatus; /* status of dropped URB */
unsigned isoinlost; /* number of bytes lost */ unsigned isoinlost; /* number of bytes lost */
/* state of bit unstuffing algorithm /* state of bit unstuffing algorithm
......
...@@ -361,13 +361,14 @@ static void gigaset_read_int_callback(struct urb *urb) ...@@ -361,13 +361,14 @@ static void gigaset_read_int_callback(struct urb *urb)
{ {
struct inbuf_t *inbuf = urb->context; struct inbuf_t *inbuf = urb->context;
struct cardstate *cs = inbuf->cs; struct cardstate *cs = inbuf->cs;
int status = urb->status;
int resubmit = 0; int resubmit = 0;
int r; int r;
unsigned numbytes; unsigned numbytes;
unsigned char *src; unsigned char *src;
unsigned long flags; unsigned long flags;
if (!urb->status) { if (!status) {
if (!cs->connected) { if (!cs->connected) {
err("%s: disconnected", __func__); /* should never happen */ err("%s: disconnected", __func__); /* should never happen */
return; return;
...@@ -393,8 +394,8 @@ static void gigaset_read_int_callback(struct urb *urb) ...@@ -393,8 +394,8 @@ static void gigaset_read_int_callback(struct urb *urb)
} else { } else {
/* The urb might have been killed. */ /* The urb might have been killed. */
gig_dbg(DEBUG_ANY, "%s - nonzero read bulk status received: %d", gig_dbg(DEBUG_ANY, "%s - nonzero read bulk status received: %d",
__func__, urb->status); __func__, status);
if (urb->status != -ENOENT) { /* not killed */ if (status != -ENOENT) { /* not killed */
if (!cs->connected) { if (!cs->connected) {
err("%s: disconnected", __func__); /* should never happen */ err("%s: disconnected", __func__); /* should never happen */
return; return;
...@@ -418,11 +419,12 @@ static void gigaset_read_int_callback(struct urb *urb) ...@@ -418,11 +419,12 @@ static void gigaset_read_int_callback(struct urb *urb)
static void gigaset_write_bulk_callback(struct urb *urb) static void gigaset_write_bulk_callback(struct urb *urb)
{ {
struct cardstate *cs = urb->context; struct cardstate *cs = urb->context;
int status = urb->status;
unsigned long flags; unsigned long flags;
if (urb->status) if (status)
dev_err(cs->dev, "bulk transfer failed (status %d)\n", dev_err(cs->dev, "bulk transfer failed (status %d)\n",
-urb->status); -status);
/* That's all we can do. Communication problems /* That's all we can do. Communication problems
are handled by timeouts or network protocols. */ are handled by timeouts or network protocols. */
......
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