aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/bas-gigaset.c
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2008-02-06 04:38:24 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 13:41:11 -0500
commitc652cbd8ee114307baab072e4e560dce5c5fb12a (patch)
tree093a7933798841060bbb2f7c847f31d1ee1d906d /drivers/isdn/gigaset/bas-gigaset.c
parentdbd9823121b4e369bc414be75e12b4f6c84c52c0 (diff)
gigaset: code cleanups
Some cleanups to the bas-gigaset and usb-gigaset USB ISDN drivers: - simplified error handling - improved debug messages - readability improvements - removal of obsolete defines and comments Signed-off-by: Tilman 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/isdn/gigaset/bas-gigaset.c')
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 0302c40a27ea..d60a6510e92b 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -938,15 +938,15 @@ static int starturbs(struct bc_state *bcs)
938 ubc->isoouturbs[k].limit = -1; 938 ubc->isoouturbs[k].limit = -1;
939 } 939 }
940 940
941 /* submit two URBs, keep third one */ 941 /* keep one URB free, submit the others */
942 for (k = 0; k < 2; ++k) { 942 for (k = 0; k < BAS_OUTURBS-1; ++k) {
943 dump_urb(DEBUG_ISO, "Initial isoc write", urb); 943 dump_urb(DEBUG_ISO, "Initial isoc write", urb);
944 rc = usb_submit_urb(ubc->isoouturbs[k].urb, GFP_ATOMIC); 944 rc = usb_submit_urb(ubc->isoouturbs[k].urb, GFP_ATOMIC);
945 if (rc != 0) 945 if (rc != 0)
946 goto error; 946 goto error;
947 } 947 }
948 dump_urb(DEBUG_ISO, "Initial isoc write (free)", urb); 948 dump_urb(DEBUG_ISO, "Initial isoc write (free)", urb);
949 ubc->isooutfree = &ubc->isoouturbs[2]; 949 ubc->isooutfree = &ubc->isoouturbs[BAS_OUTURBS-1];
950 ubc->isooutdone = ubc->isooutovfl = NULL; 950 ubc->isooutdone = ubc->isooutovfl = NULL;
951 return 0; 951 return 0;
952 error: 952 error:
@@ -1559,37 +1559,38 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
1559 */ 1559 */
1560static int gigaset_init_bchannel(struct bc_state *bcs) 1560static int gigaset_init_bchannel(struct bc_state *bcs)
1561{ 1561{
1562 struct cardstate *cs = bcs->cs;
1562 int req, ret; 1563 int req, ret;
1563 unsigned long flags; 1564 unsigned long flags;
1564 1565
1565 spin_lock_irqsave(&bcs->cs->lock, flags); 1566 spin_lock_irqsave(&cs->lock, flags);
1566 if (unlikely(!bcs->cs->connected)) { 1567 if (unlikely(!cs->connected)) {
1567 gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__); 1568 gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__);
1568 spin_unlock_irqrestore(&bcs->cs->lock, flags); 1569 spin_unlock_irqrestore(&cs->lock, flags);
1569 return -ENODEV; 1570 return -ENODEV;
1570 } 1571 }
1571 1572
1572 if ((ret = starturbs(bcs)) < 0) { 1573 if ((ret = starturbs(bcs)) < 0) {
1573 dev_err(bcs->cs->dev, 1574 dev_err(cs->dev,
1574 "could not start isochronous I/O for channel B%d: %s\n", 1575 "could not start isochronous I/O for channel B%d: %s\n",
1575 bcs->channel + 1, 1576 bcs->channel + 1,
1576 ret == -EFAULT ? "null URB" : get_usb_rcmsg(ret)); 1577 ret == -EFAULT ? "null URB" : get_usb_rcmsg(ret));
1577 if (ret != -ENODEV) 1578 if (ret != -ENODEV)
1578 error_hangup(bcs); 1579 error_hangup(bcs);
1579 spin_unlock_irqrestore(&bcs->cs->lock, flags); 1580 spin_unlock_irqrestore(&cs->lock, flags);
1580 return ret; 1581 return ret;
1581 } 1582 }
1582 1583
1583 req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL; 1584 req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL;
1584 if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) { 1585 if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) {
1585 dev_err(bcs->cs->dev, "could not open channel B%d\n", 1586 dev_err(cs->dev, "could not open channel B%d\n",
1586 bcs->channel + 1); 1587 bcs->channel + 1);
1587 stopurbs(bcs->hw.bas); 1588 stopurbs(bcs->hw.bas);
1588 if (ret != -ENODEV) 1589 if (ret != -ENODEV)
1589 error_hangup(bcs); 1590 error_hangup(bcs);
1590 } 1591 }
1591 1592
1592 spin_unlock_irqrestore(&bcs->cs->lock, flags); 1593 spin_unlock_irqrestore(&cs->lock, flags);
1593 return ret; 1594 return ret;
1594} 1595}
1595 1596
@@ -1605,20 +1606,21 @@ static int gigaset_init_bchannel(struct bc_state *bcs)
1605 */ 1606 */
1606static int gigaset_close_bchannel(struct bc_state *bcs) 1607static int gigaset_close_bchannel(struct bc_state *bcs)
1607{ 1608{
1609 struct cardstate *cs = bcs->cs;
1608 int req, ret; 1610 int req, ret;
1609 unsigned long flags; 1611 unsigned long flags;
1610 1612
1611 spin_lock_irqsave(&bcs->cs->lock, flags); 1613 spin_lock_irqsave(&cs->lock, flags);
1612 if (unlikely(!bcs->cs->connected)) { 1614 if (unlikely(!cs->connected)) {
1613 spin_unlock_irqrestore(&bcs->cs->lock, flags); 1615 spin_unlock_irqrestore(&cs->lock, flags);
1614 gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__); 1616 gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__);
1615 return -ENODEV; 1617 return -ENODEV;
1616 } 1618 }
1617 1619
1618 if (!(atomic_read(&bcs->cs->hw.bas->basstate) & 1620 if (!(atomic_read(&cs->hw.bas->basstate) &
1619 (bcs->channel ? BS_B2OPEN : BS_B1OPEN))) { 1621 (bcs->channel ? BS_B2OPEN : BS_B1OPEN))) {
1620 /* channel not running: just signal common.c */ 1622 /* channel not running: just signal common.c */
1621 spin_unlock_irqrestore(&bcs->cs->lock, flags); 1623 spin_unlock_irqrestore(&cs->lock, flags);
1622 gigaset_bchannel_down(bcs); 1624 gigaset_bchannel_down(bcs);
1623 return 0; 1625 return 0;
1624 } 1626 }
@@ -1626,10 +1628,10 @@ static int gigaset_close_bchannel(struct bc_state *bcs)
1626 /* channel running: tell device to close it */ 1628 /* channel running: tell device to close it */
1627 req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL; 1629 req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL;
1628 if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) 1630 if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0)
1629 dev_err(bcs->cs->dev, "closing channel B%d failed\n", 1631 dev_err(cs->dev, "closing channel B%d failed\n",
1630 bcs->channel + 1); 1632 bcs->channel + 1);
1631 1633
1632 spin_unlock_irqrestore(&bcs->cs->lock, flags); 1634 spin_unlock_irqrestore(&cs->lock, flags);
1633 return ret; 1635 return ret;
1634} 1636}
1635 1637
@@ -2114,7 +2116,7 @@ static void freeurbs(struct cardstate *cs)
2114 int i, j; 2116 int i, j;
2115 2117
2116 gig_dbg(DEBUG_INIT, "%s: killing URBs", __func__); 2118 gig_dbg(DEBUG_INIT, "%s: killing URBs", __func__);
2117 for (j = 0; j < 2; ++j) { 2119 for (j = 0; j < BAS_CHANNELS; ++j) {
2118 ubc = cs->bcs[j].hw.bas; 2120 ubc = cs->bcs[j].hw.bas;
2119 for (i = 0; i < BAS_OUTURBS; ++i) { 2121 for (i = 0; i < BAS_OUTURBS; ++i) {
2120 usb_kill_urb(ubc->isoouturbs[i].urb); 2122 usb_kill_urb(ubc->isoouturbs[i].urb);
@@ -2215,7 +2217,7 @@ static int gigaset_probe(struct usb_interface *interface,
2215 !(ucs->urb_ctrl = usb_alloc_urb(0, GFP_KERNEL))) 2217 !(ucs->urb_ctrl = usb_alloc_urb(0, GFP_KERNEL)))
2216 goto allocerr; 2218 goto allocerr;
2217 2219
2218 for (j = 0; j < 2; ++j) { 2220 for (j = 0; j < BAS_CHANNELS; ++j) {
2219 ubc = cs->bcs[j].hw.bas; 2221 ubc = cs->bcs[j].hw.bas;
2220 for (i = 0; i < BAS_OUTURBS; ++i) 2222 for (i = 0; i < BAS_OUTURBS; ++i)
2221 if (!(ubc->isoouturbs[i].urb = 2223 if (!(ubc->isoouturbs[i].urb =
@@ -2287,8 +2289,7 @@ static void gigaset_disconnect(struct usb_interface *interface)
2287 atomic_set(&ucs->basstate, 0); 2289 atomic_set(&ucs->basstate, 0);
2288 2290
2289 /* tell LL all channels are down */ 2291 /* tell LL all channels are down */
2290 //FIXME shouldn't gigaset_stop() do this? 2292 for (j = 0; j < BAS_CHANNELS; ++j)
2291 for (j = 0; j < 2; ++j)
2292 gigaset_bchannel_down(cs->bcs + j); 2293 gigaset_bchannel_down(cs->bcs + j);
2293 2294
2294 /* stop driver (common part) */ 2295 /* stop driver (common part) */
@@ -2343,7 +2344,7 @@ static int __init bas_gigaset_init(void)
2343 goto error; 2344 goto error;
2344 2345
2345 /* allocate memory for our device state and intialize it */ 2346 /* allocate memory for our device state and intialize it */
2346 cardstate = gigaset_initcs(driver, 2, 0, 0, cidmode, 2347 cardstate = gigaset_initcs(driver, BAS_CHANNELS, 0, 0, cidmode,
2347 GIGASET_MODULENAME); 2348 GIGASET_MODULENAME);
2348 if (!cardstate) 2349 if (!cardstate)
2349 goto error; 2350 goto error;