diff options
author | Tilman Schmidt <tilman@imap.cc> | 2009-10-25 05:30:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-29 04:37:14 -0400 |
commit | 7891adf18ad9658950e532b840f1d84d8ac6cce2 (patch) | |
tree | b26fca6cf86a0af2e29fa24ad816f7bd144c5bbd /drivers/isdn/gigaset | |
parent | ae67d7d81436c7e85104d586562b1a220d3cd94b (diff) |
bas_gigaset: checkpatch cleanup
On the quest for the holy grail of checkpatch.pl silence.
Impact: cosmetic
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/gigaset')
-rw-r--r-- | drivers/isdn/gigaset/bas-gigaset.c | 68 | ||||
-rw-r--r-- | drivers/isdn/gigaset/isocdata.c | 107 |
2 files changed, 93 insertions, 82 deletions
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c index 388e63a8ae94..9fd19db045fb 100644 --- a/drivers/isdn/gigaset/bas-gigaset.c +++ b/drivers/isdn/gigaset/bas-gigaset.c | |||
@@ -57,7 +57,7 @@ MODULE_PARM_DESC(cidmode, "Call-ID mode"); | |||
57 | #define USB_SX353_PRODUCT_ID 0x0022 | 57 | #define USB_SX353_PRODUCT_ID 0x0022 |
58 | 58 | ||
59 | /* table of devices that work with this driver */ | 59 | /* table of devices that work with this driver */ |
60 | static const struct usb_device_id gigaset_table [] = { | 60 | static const struct usb_device_id gigaset_table[] = { |
61 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3070_PRODUCT_ID) }, | 61 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3070_PRODUCT_ID) }, |
62 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3075_PRODUCT_ID) }, | 62 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3075_PRODUCT_ID) }, |
63 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_SX303_PRODUCT_ID) }, | 63 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_SX303_PRODUCT_ID) }, |
@@ -137,7 +137,7 @@ struct bas_cardstate { | |||
137 | #define BS_RESETTING 0x200 /* waiting for HD_RESET_INTERRUPT_PIPE_ACK */ | 137 | #define BS_RESETTING 0x200 /* waiting for HD_RESET_INTERRUPT_PIPE_ACK */ |
138 | 138 | ||
139 | 139 | ||
140 | static struct gigaset_driver *driver = NULL; | 140 | static struct gigaset_driver *driver; |
141 | 141 | ||
142 | /* usb specific object needed to register this driver with the usb subsystem */ | 142 | /* usb specific object needed to register this driver with the usb subsystem */ |
143 | static struct usb_driver gigaset_usb_driver = { | 143 | static struct usb_driver gigaset_usb_driver = { |
@@ -601,11 +601,12 @@ static int atread_submit(struct cardstate *cs, int timeout) | |||
601 | ucs->dr_cmd_in.wLength = cpu_to_le16(ucs->rcvbuf_size); | 601 | ucs->dr_cmd_in.wLength = cpu_to_le16(ucs->rcvbuf_size); |
602 | usb_fill_control_urb(ucs->urb_cmd_in, ucs->udev, | 602 | usb_fill_control_urb(ucs->urb_cmd_in, ucs->udev, |
603 | usb_rcvctrlpipe(ucs->udev, 0), | 603 | usb_rcvctrlpipe(ucs->udev, 0), |
604 | (unsigned char*) & ucs->dr_cmd_in, | 604 | (unsigned char *) &ucs->dr_cmd_in, |
605 | ucs->rcvbuf, ucs->rcvbuf_size, | 605 | ucs->rcvbuf, ucs->rcvbuf_size, |
606 | read_ctrl_callback, cs->inbuf); | 606 | read_ctrl_callback, cs->inbuf); |
607 | 607 | ||
608 | if ((ret = usb_submit_urb(ucs->urb_cmd_in, GFP_ATOMIC)) != 0) { | 608 | ret = usb_submit_urb(ucs->urb_cmd_in, GFP_ATOMIC); |
609 | if (ret != 0) { | ||
609 | update_basstate(ucs, 0, BS_ATRDPEND); | 610 | update_basstate(ucs, 0, BS_ATRDPEND); |
610 | dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n", | 611 | dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n", |
611 | get_usb_rcmsg(ret)); | 612 | get_usb_rcmsg(ret)); |
@@ -652,13 +653,11 @@ static void read_int_callback(struct urb *urb) | |||
652 | return; | 653 | return; |
653 | case -ENODEV: /* device removed */ | 654 | case -ENODEV: /* device removed */ |
654 | case -ESHUTDOWN: /* device shut down */ | 655 | case -ESHUTDOWN: /* device shut down */ |
655 | //FIXME use this as disconnect indicator? | ||
656 | gig_dbg(DEBUG_USBREQ, "%s: device disconnected", __func__); | 656 | gig_dbg(DEBUG_USBREQ, "%s: device disconnected", __func__); |
657 | return; | 657 | return; |
658 | default: /* severe trouble */ | 658 | default: /* severe trouble */ |
659 | dev_warn(cs->dev, "interrupt read: %s\n", | 659 | dev_warn(cs->dev, "interrupt read: %s\n", |
660 | get_usb_statmsg(status)); | 660 | get_usb_statmsg(status)); |
661 | //FIXME corrective action? resubmission always ok? | ||
662 | goto resubmit; | 661 | goto resubmit; |
663 | } | 662 | } |
664 | 663 | ||
@@ -742,7 +741,8 @@ static void read_int_callback(struct urb *urb) | |||
742 | kfree(ucs->rcvbuf); | 741 | kfree(ucs->rcvbuf); |
743 | ucs->rcvbuf_size = 0; | 742 | ucs->rcvbuf_size = 0; |
744 | } | 743 | } |
745 | if ((ucs->rcvbuf = kmalloc(l, GFP_ATOMIC)) == NULL) { | 744 | ucs->rcvbuf = kmalloc(l, GFP_ATOMIC); |
745 | if (ucs->rcvbuf == NULL) { | ||
746 | spin_unlock_irqrestore(&cs->lock, flags); | 746 | spin_unlock_irqrestore(&cs->lock, flags); |
747 | dev_err(cs->dev, "out of memory receiving AT data\n"); | 747 | dev_err(cs->dev, "out of memory receiving AT data\n"); |
748 | error_reset(cs); | 748 | error_reset(cs); |
@@ -750,12 +750,12 @@ static void read_int_callback(struct urb *urb) | |||
750 | } | 750 | } |
751 | ucs->rcvbuf_size = l; | 751 | ucs->rcvbuf_size = l; |
752 | ucs->retry_cmd_in = 0; | 752 | ucs->retry_cmd_in = 0; |
753 | if ((rc = atread_submit(cs, BAS_TIMEOUT)) < 0) { | 753 | rc = atread_submit(cs, BAS_TIMEOUT); |
754 | if (rc < 0) { | ||
754 | kfree(ucs->rcvbuf); | 755 | kfree(ucs->rcvbuf); |
755 | ucs->rcvbuf = NULL; | 756 | ucs->rcvbuf = NULL; |
756 | ucs->rcvbuf_size = 0; | 757 | ucs->rcvbuf_size = 0; |
757 | if (rc != -ENODEV) { | 758 | if (rc != -ENODEV) { |
758 | //FIXME corrective action? | ||
759 | spin_unlock_irqrestore(&cs->lock, flags); | 759 | spin_unlock_irqrestore(&cs->lock, flags); |
760 | error_reset(cs); | 760 | error_reset(cs); |
761 | break; | 761 | break; |
@@ -940,7 +940,8 @@ static int starturbs(struct bc_state *bcs) | |||
940 | } | 940 | } |
941 | 941 | ||
942 | dump_urb(DEBUG_ISO, "Initial isoc read", urb); | 942 | dump_urb(DEBUG_ISO, "Initial isoc read", urb); |
943 | if ((rc = usb_submit_urb(urb, GFP_ATOMIC)) != 0) | 943 | rc = usb_submit_urb(urb, GFP_ATOMIC); |
944 | if (rc != 0) | ||
944 | goto error; | 945 | goto error; |
945 | } | 946 | } |
946 | 947 | ||
@@ -1045,7 +1046,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) | |||
1045 | 1046 | ||
1046 | /* compute frame length according to flow control */ | 1047 | /* compute frame length according to flow control */ |
1047 | ifd->length = BAS_NORMFRAME; | 1048 | ifd->length = BAS_NORMFRAME; |
1048 | if ((corrbytes = atomic_read(&ubc->corrbytes)) != 0) { | 1049 | corrbytes = atomic_read(&ubc->corrbytes); |
1050 | if (corrbytes != 0) { | ||
1049 | gig_dbg(DEBUG_ISO, "%s: corrbytes=%d", | 1051 | gig_dbg(DEBUG_ISO, "%s: corrbytes=%d", |
1050 | __func__, corrbytes); | 1052 | __func__, corrbytes); |
1051 | if (corrbytes > BAS_HIGHFRAME - BAS_NORMFRAME) | 1053 | if (corrbytes > BAS_HIGHFRAME - BAS_NORMFRAME) |
@@ -1284,7 +1286,8 @@ static void read_iso_tasklet(unsigned long data) | |||
1284 | for (;;) { | 1286 | for (;;) { |
1285 | /* retrieve URB */ | 1287 | /* retrieve URB */ |
1286 | spin_lock_irqsave(&ubc->isoinlock, flags); | 1288 | spin_lock_irqsave(&ubc->isoinlock, flags); |
1287 | if (!(urb = ubc->isoindone)) { | 1289 | urb = ubc->isoindone; |
1290 | if (!urb) { | ||
1288 | spin_unlock_irqrestore(&ubc->isoinlock, flags); | 1291 | spin_unlock_irqrestore(&ubc->isoinlock, flags); |
1289 | return; | 1292 | return; |
1290 | } | 1293 | } |
@@ -1371,7 +1374,7 @@ static void read_iso_tasklet(unsigned long data) | |||
1371 | "isochronous read: %d data bytes missing\n", | 1374 | "isochronous read: %d data bytes missing\n", |
1372 | totleft); | 1375 | totleft); |
1373 | 1376 | ||
1374 | error: | 1377 | error: |
1375 | /* URB processed, resubmit */ | 1378 | /* URB processed, resubmit */ |
1376 | for (frame = 0; frame < BAS_NUMFRAMES; frame++) { | 1379 | for (frame = 0; frame < BAS_NUMFRAMES; frame++) { |
1377 | urb->iso_frame_desc[frame].status = 0; | 1380 | urb->iso_frame_desc[frame].status = 0; |
@@ -1568,7 +1571,7 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout) | |||
1568 | ucs->dr_ctrl.wLength = 0; | 1571 | ucs->dr_ctrl.wLength = 0; |
1569 | usb_fill_control_urb(ucs->urb_ctrl, ucs->udev, | 1572 | usb_fill_control_urb(ucs->urb_ctrl, ucs->udev, |
1570 | usb_sndctrlpipe(ucs->udev, 0), | 1573 | usb_sndctrlpipe(ucs->udev, 0), |
1571 | (unsigned char*) &ucs->dr_ctrl, NULL, 0, | 1574 | (unsigned char *) &ucs->dr_ctrl, NULL, 0, |
1572 | write_ctrl_callback, ucs); | 1575 | write_ctrl_callback, ucs); |
1573 | ucs->retry_ctrl = 0; | 1576 | ucs->retry_ctrl = 0; |
1574 | ret = usb_submit_urb(ucs->urb_ctrl, GFP_ATOMIC); | 1577 | ret = usb_submit_urb(ucs->urb_ctrl, GFP_ATOMIC); |
@@ -1621,7 +1624,8 @@ static int gigaset_init_bchannel(struct bc_state *bcs) | |||
1621 | return -EHOSTUNREACH; | 1624 | return -EHOSTUNREACH; |
1622 | } | 1625 | } |
1623 | 1626 | ||
1624 | if ((ret = starturbs(bcs)) < 0) { | 1627 | ret = starturbs(bcs); |
1628 | if (ret < 0) { | ||
1625 | dev_err(cs->dev, | 1629 | dev_err(cs->dev, |
1626 | "could not start isochronous I/O for channel B%d: %s\n", | 1630 | "could not start isochronous I/O for channel B%d: %s\n", |
1627 | bcs->channel + 1, | 1631 | bcs->channel + 1, |
@@ -1633,7 +1637,8 @@ static int gigaset_init_bchannel(struct bc_state *bcs) | |||
1633 | } | 1637 | } |
1634 | 1638 | ||
1635 | req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL; | 1639 | req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL; |
1636 | if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) { | 1640 | ret = req_submit(bcs, req, 0, BAS_TIMEOUT); |
1641 | if (ret < 0) { | ||
1637 | dev_err(cs->dev, "could not open channel B%d\n", | 1642 | dev_err(cs->dev, "could not open channel B%d\n", |
1638 | bcs->channel + 1); | 1643 | bcs->channel + 1); |
1639 | stopurbs(bcs->hw.bas); | 1644 | stopurbs(bcs->hw.bas); |
@@ -1677,7 +1682,8 @@ static int gigaset_close_bchannel(struct bc_state *bcs) | |||
1677 | 1682 | ||
1678 | /* channel running: tell device to close it */ | 1683 | /* channel running: tell device to close it */ |
1679 | req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL; | 1684 | req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL; |
1680 | if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) | 1685 | ret = req_submit(bcs, req, 0, BAS_TIMEOUT); |
1686 | if (ret < 0) | ||
1681 | dev_err(cs->dev, "closing channel B%d failed\n", | 1687 | dev_err(cs->dev, "closing channel B%d failed\n", |
1682 | bcs->channel + 1); | 1688 | bcs->channel + 1); |
1683 | 1689 | ||
@@ -1703,10 +1709,12 @@ static void complete_cb(struct cardstate *cs) | |||
1703 | gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, | 1709 | gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, |
1704 | "write_command: sent %u bytes, %u left", | 1710 | "write_command: sent %u bytes, %u left", |
1705 | cs->curlen, cs->cmdbytes); | 1711 | cs->curlen, cs->cmdbytes); |
1706 | if ((cs->cmdbuf = cb->next) != NULL) { | 1712 | if (cb->next != NULL) { |
1713 | cs->cmdbuf = cb->next; | ||
1707 | cs->cmdbuf->prev = NULL; | 1714 | cs->cmdbuf->prev = NULL; |
1708 | cs->curlen = cs->cmdbuf->len; | 1715 | cs->curlen = cs->cmdbuf->len; |
1709 | } else { | 1716 | } else { |
1717 | cs->cmdbuf = NULL; | ||
1710 | cs->lastcmdbuf = NULL; | 1718 | cs->lastcmdbuf = NULL; |
1711 | cs->curlen = 0; | 1719 | cs->curlen = 0; |
1712 | } | 1720 | } |
@@ -1833,7 +1841,7 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len) | |||
1833 | ucs->dr_cmd_out.wLength = cpu_to_le16(len); | 1841 | ucs->dr_cmd_out.wLength = cpu_to_le16(len); |
1834 | usb_fill_control_urb(ucs->urb_cmd_out, ucs->udev, | 1842 | usb_fill_control_urb(ucs->urb_cmd_out, ucs->udev, |
1835 | usb_sndctrlpipe(ucs->udev, 0), | 1843 | usb_sndctrlpipe(ucs->udev, 0), |
1836 | (unsigned char*) &ucs->dr_cmd_out, buf, len, | 1844 | (unsigned char *) &ucs->dr_cmd_out, buf, len, |
1837 | write_command_callback, cs); | 1845 | write_command_callback, cs); |
1838 | rc = usb_submit_urb(ucs->urb_cmd_out, GFP_ATOMIC); | 1846 | rc = usb_submit_urb(ucs->urb_cmd_out, GFP_ATOMIC); |
1839 | if (unlikely(rc)) { | 1847 | if (unlikely(rc)) { |
@@ -1953,7 +1961,8 @@ static int gigaset_write_cmd(struct cardstate *cs, | |||
1953 | 1961 | ||
1954 | if (len > IF_WRITEBUF) | 1962 | if (len > IF_WRITEBUF) |
1955 | len = IF_WRITEBUF; | 1963 | len = IF_WRITEBUF; |
1956 | if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { | 1964 | cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC); |
1965 | if (!cb) { | ||
1957 | dev_err(cs->dev, "%s: out of memory\n", __func__); | 1966 | dev_err(cs->dev, "%s: out of memory\n", __func__); |
1958 | rc = -ENOMEM; | 1967 | rc = -ENOMEM; |
1959 | goto notqueued; | 1968 | goto notqueued; |
@@ -2100,7 +2109,8 @@ static int gigaset_initbcshw(struct bc_state *bcs) | |||
2100 | } | 2109 | } |
2101 | ubc->isooutdone = ubc->isooutfree = ubc->isooutovfl = NULL; | 2110 | ubc->isooutdone = ubc->isooutfree = ubc->isooutovfl = NULL; |
2102 | ubc->numsub = 0; | 2111 | ubc->numsub = 0; |
2103 | if (!(ubc->isooutbuf = kmalloc(sizeof(struct isowbuf_t), GFP_KERNEL))) { | 2112 | ubc->isooutbuf = kmalloc(sizeof(struct isowbuf_t), GFP_KERNEL); |
2113 | if (!ubc->isooutbuf) { | ||
2104 | pr_err("out of memory\n"); | 2114 | pr_err("out of memory\n"); |
2105 | kfree(ubc); | 2115 | kfree(ubc); |
2106 | bcs->hw.bas = NULL; | 2116 | bcs->hw.bas = NULL; |
@@ -2252,7 +2262,8 @@ static int gigaset_probe(struct usb_interface *interface, | |||
2252 | gig_dbg(DEBUG_ANY, | 2262 | gig_dbg(DEBUG_ANY, |
2253 | "%s: wrong alternate setting %d - trying to switch", | 2263 | "%s: wrong alternate setting %d - trying to switch", |
2254 | __func__, hostif->desc.bAlternateSetting); | 2264 | __func__, hostif->desc.bAlternateSetting); |
2255 | if (usb_set_interface(udev, hostif->desc.bInterfaceNumber, 3) < 0) { | 2265 | if (usb_set_interface(udev, hostif->desc.bInterfaceNumber, 3) |
2266 | < 0) { | ||
2256 | dev_warn(&udev->dev, "usb_set_interface failed, " | 2267 | dev_warn(&udev->dev, "usb_set_interface failed, " |
2257 | "device %d interface %d altsetting %d\n", | 2268 | "device %d interface %d altsetting %d\n", |
2258 | udev->devnum, hostif->desc.bInterfaceNumber, | 2269 | udev->devnum, hostif->desc.bInterfaceNumber, |
@@ -2321,14 +2332,16 @@ static int gigaset_probe(struct usb_interface *interface, | |||
2321 | (endpoint->bEndpointAddress) & 0x0f), | 2332 | (endpoint->bEndpointAddress) & 0x0f), |
2322 | ucs->int_in_buf, IP_MSGSIZE, read_int_callback, cs, | 2333 | ucs->int_in_buf, IP_MSGSIZE, read_int_callback, cs, |
2323 | endpoint->bInterval); | 2334 | endpoint->bInterval); |
2324 | if ((rc = usb_submit_urb(ucs->urb_int_in, GFP_KERNEL)) != 0) { | 2335 | rc = usb_submit_urb(ucs->urb_int_in, GFP_KERNEL); |
2336 | if (rc != 0) { | ||
2325 | dev_err(cs->dev, "could not submit interrupt URB: %s\n", | 2337 | dev_err(cs->dev, "could not submit interrupt URB: %s\n", |
2326 | get_usb_rcmsg(rc)); | 2338 | get_usb_rcmsg(rc)); |
2327 | goto error; | 2339 | goto error; |
2328 | } | 2340 | } |
2329 | 2341 | ||
2330 | /* tell the device that the driver is ready */ | 2342 | /* tell the device that the driver is ready */ |
2331 | if ((rc = req_submit(cs->bcs, HD_DEVICE_INIT_ACK, 0, 0)) != 0) | 2343 | rc = req_submit(cs->bcs, HD_DEVICE_INIT_ACK, 0, 0); |
2344 | if (rc != 0) | ||
2332 | goto error; | 2345 | goto error; |
2333 | 2346 | ||
2334 | /* tell common part that the device is ready */ | 2347 | /* tell common part that the device is ready */ |
@@ -2524,9 +2537,10 @@ static int __init bas_gigaset_init(void) | |||
2524 | int result; | 2537 | int result; |
2525 | 2538 | ||
2526 | /* allocate memory for our driver state and intialize it */ | 2539 | /* allocate memory for our driver state and intialize it */ |
2527 | if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, | 2540 | driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, |
2528 | GIGASET_MODULENAME, GIGASET_DEVNAME, | 2541 | GIGASET_MODULENAME, GIGASET_DEVNAME, |
2529 | &gigops, THIS_MODULE)) == NULL) | 2542 | &gigops, THIS_MODULE); |
2543 | if (driver == NULL) | ||
2530 | goto error; | 2544 | goto error; |
2531 | 2545 | ||
2532 | /* register this driver with the USB subsystem */ | 2546 | /* register this driver with the USB subsystem */ |
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c index bc41611e541d..85394a6ebae8 100644 --- a/drivers/isdn/gigaset/isocdata.c +++ b/drivers/isdn/gigaset/isocdata.c | |||
@@ -41,7 +41,8 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb) | |||
41 | 41 | ||
42 | read = iwb->read; | 42 | read = iwb->read; |
43 | write = iwb->write; | 43 | write = iwb->write; |
44 | if ((freebytes = read - write) > 0) { | 44 | freebytes = read - write; |
45 | if (freebytes > 0) { | ||
45 | /* no wraparound: need padding space within regular area */ | 46 | /* no wraparound: need padding space within regular area */ |
46 | return freebytes - BAS_OUTBUFPAD; | 47 | return freebytes - BAS_OUTBUFPAD; |
47 | } else if (read < BAS_OUTBUFPAD) { | 48 | } else if (read < BAS_OUTBUFPAD) { |
@@ -53,29 +54,6 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb) | |||
53 | } | 54 | } |
54 | } | 55 | } |
55 | 56 | ||
56 | /* compare two offsets within the buffer | ||
57 | * The buffer is seen as circular, with the read position as start | ||
58 | * returns -1/0/1 if position a </=/> position b without crossing 'read' | ||
59 | */ | ||
60 | static inline int isowbuf_poscmp(struct isowbuf_t *iwb, int a, int b) | ||
61 | { | ||
62 | int read; | ||
63 | if (a == b) | ||
64 | return 0; | ||
65 | read = iwb->read; | ||
66 | if (a < b) { | ||
67 | if (a < read && read <= b) | ||
68 | return +1; | ||
69 | else | ||
70 | return -1; | ||
71 | } else { | ||
72 | if (b < read && read <= a) | ||
73 | return -1; | ||
74 | else | ||
75 | return +1; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | /* start writing | 57 | /* start writing |
80 | * acquire the write semaphore | 58 | * acquire the write semaphore |
81 | * return true if acquired, false if busy | 59 | * return true if acquired, false if busy |
@@ -271,7 +249,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag, | |||
271 | * bit 14..13 = number of bits added by stuffing | 249 | * bit 14..13 = number of bits added by stuffing |
272 | */ | 250 | */ |
273 | static const u16 stufftab[5 * 256] = { | 251 | static const u16 stufftab[5 * 256] = { |
274 | // previous 1s = 0: | 252 | /* previous 1s = 0: */ |
275 | 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, | 253 | 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, |
276 | 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x201f, | 254 | 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x201f, |
277 | 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, | 255 | 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, |
@@ -289,7 +267,7 @@ static const u16 stufftab[5 * 256] = { | |||
289 | 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x0cef, | 267 | 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x0cef, |
290 | 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x2ddf, | 268 | 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x2ddf, |
291 | 269 | ||
292 | // previous 1s = 1: | 270 | /* previous 1s = 1: */ |
293 | 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x200f, | 271 | 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x200f, |
294 | 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x202f, | 272 | 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x202f, |
295 | 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x204f, | 273 | 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x204f, |
@@ -307,7 +285,7 @@ static const u16 stufftab[5 * 256] = { | |||
307 | 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dcf, | 285 | 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dcf, |
308 | 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x31ef, | 286 | 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x31ef, |
309 | 287 | ||
310 | // previous 1s = 2: | 288 | /* previous 1s = 2: */ |
311 | 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x2007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x2017, | 289 | 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x2007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x2017, |
312 | 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x2027, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x2037, | 290 | 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x2027, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x2037, |
313 | 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x2047, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x2057, | 291 | 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x2047, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x2057, |
@@ -325,7 +303,7 @@ static const u16 stufftab[5 * 256] = { | |||
325 | 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dc7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dd7, | 303 | 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dc7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dd7, |
326 | 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x31e7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x41f7, | 304 | 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x31e7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x41f7, |
327 | 305 | ||
328 | // previous 1s = 3: | 306 | /* previous 1s = 3: */ |
329 | 0x0000, 0x0001, 0x0002, 0x2003, 0x0004, 0x0005, 0x0006, 0x200b, 0x0008, 0x0009, 0x000a, 0x2013, 0x000c, 0x000d, 0x000e, 0x201b, | 307 | 0x0000, 0x0001, 0x0002, 0x2003, 0x0004, 0x0005, 0x0006, 0x200b, 0x0008, 0x0009, 0x000a, 0x2013, 0x000c, 0x000d, 0x000e, 0x201b, |
330 | 0x0010, 0x0011, 0x0012, 0x2023, 0x0014, 0x0015, 0x0016, 0x202b, 0x0018, 0x0019, 0x001a, 0x2033, 0x001c, 0x001d, 0x001e, 0x203b, | 308 | 0x0010, 0x0011, 0x0012, 0x2023, 0x0014, 0x0015, 0x0016, 0x202b, 0x0018, 0x0019, 0x001a, 0x2033, 0x001c, 0x001d, 0x001e, 0x203b, |
331 | 0x0020, 0x0021, 0x0022, 0x2043, 0x0024, 0x0025, 0x0026, 0x204b, 0x0028, 0x0029, 0x002a, 0x2053, 0x002c, 0x002d, 0x002e, 0x205b, | 309 | 0x0020, 0x0021, 0x0022, 0x2043, 0x0024, 0x0025, 0x0026, 0x204b, 0x0028, 0x0029, 0x002a, 0x2053, 0x002c, 0x002d, 0x002e, 0x205b, |
@@ -343,7 +321,7 @@ static const u16 stufftab[5 * 256] = { | |||
343 | 0x0ce0, 0x0ce1, 0x0ce2, 0x2dc3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dcb, 0x0ce8, 0x0ce9, 0x0cea, 0x2dd3, 0x0cec, 0x0ced, 0x0cee, 0x2ddb, | 321 | 0x0ce0, 0x0ce1, 0x0ce2, 0x2dc3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dcb, 0x0ce8, 0x0ce9, 0x0cea, 0x2dd3, 0x0cec, 0x0ced, 0x0cee, 0x2ddb, |
344 | 0x10f0, 0x10f1, 0x10f2, 0x31e3, 0x10f4, 0x10f5, 0x10f6, 0x31eb, 0x20f8, 0x20f9, 0x20fa, 0x41f3, 0x257c, 0x257d, 0x29be, 0x46fb, | 322 | 0x10f0, 0x10f1, 0x10f2, 0x31e3, 0x10f4, 0x10f5, 0x10f6, 0x31eb, 0x20f8, 0x20f9, 0x20fa, 0x41f3, 0x257c, 0x257d, 0x29be, 0x46fb, |
345 | 323 | ||
346 | // previous 1s = 4: | 324 | /* previous 1s = 4: */ |
347 | 0x0000, 0x2001, 0x0002, 0x2005, 0x0004, 0x2009, 0x0006, 0x200d, 0x0008, 0x2011, 0x000a, 0x2015, 0x000c, 0x2019, 0x000e, 0x201d, | 325 | 0x0000, 0x2001, 0x0002, 0x2005, 0x0004, 0x2009, 0x0006, 0x200d, 0x0008, 0x2011, 0x000a, 0x2015, 0x000c, 0x2019, 0x000e, 0x201d, |
348 | 0x0010, 0x2021, 0x0012, 0x2025, 0x0014, 0x2029, 0x0016, 0x202d, 0x0018, 0x2031, 0x001a, 0x2035, 0x001c, 0x2039, 0x001e, 0x203d, | 326 | 0x0010, 0x2021, 0x0012, 0x2025, 0x0014, 0x2029, 0x0016, 0x202d, 0x0018, 0x2031, 0x001a, 0x2035, 0x001c, 0x2039, 0x001e, 0x203d, |
349 | 0x0020, 0x2041, 0x0022, 0x2045, 0x0024, 0x2049, 0x0026, 0x204d, 0x0028, 0x2051, 0x002a, 0x2055, 0x002c, 0x2059, 0x002e, 0x205d, | 327 | 0x0020, 0x2041, 0x0022, 0x2045, 0x0024, 0x2049, 0x0026, 0x204d, 0x0028, 0x2051, 0x002a, 0x2055, 0x002c, 0x2059, 0x002e, 0x205d, |
@@ -367,7 +345,8 @@ static const u16 stufftab[5 * 256] = { | |||
367 | * parameters: | 345 | * parameters: |
368 | * cin input byte | 346 | * cin input byte |
369 | * ones number of trailing '1' bits in result before this step | 347 | * ones number of trailing '1' bits in result before this step |
370 | * iwb pointer to output buffer structure (write semaphore must be held) | 348 | * iwb pointer to output buffer structure |
349 | * (write semaphore must be held) | ||
371 | * return value: | 350 | * return value: |
372 | * number of trailing '1' bits in result after this step | 351 | * number of trailing '1' bits in result after this step |
373 | */ | 352 | */ |
@@ -408,7 +387,8 @@ static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin, | |||
408 | * parameters: | 387 | * parameters: |
409 | * in input buffer | 388 | * in input buffer |
410 | * count number of bytes in input buffer | 389 | * count number of bytes in input buffer |
411 | * iwb pointer to output buffer structure (write semaphore must be held) | 390 | * iwb pointer to output buffer structure |
391 | * (write semaphore must be held) | ||
412 | * return value: | 392 | * return value: |
413 | * position of end of packet in output buffer on success, | 393 | * position of end of packet in output buffer on success, |
414 | * -EAGAIN if write semaphore busy or buffer full | 394 | * -EAGAIN if write semaphore busy or buffer full |
@@ -440,7 +420,8 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb, | |||
440 | fcs = crc_ccitt_byte(fcs, c); | 420 | fcs = crc_ccitt_byte(fcs, c); |
441 | } | 421 | } |
442 | 422 | ||
443 | /* bitstuff and append FCS (complemented, least significant byte first) */ | 423 | /* bitstuff and append FCS |
424 | * (complemented, least significant byte first) */ | ||
444 | fcs ^= 0xffff; | 425 | fcs ^= 0xffff; |
445 | ones = hdlc_bitstuff_byte(iwb, fcs & 0x00ff, ones); | 426 | ones = hdlc_bitstuff_byte(iwb, fcs & 0x00ff, ones); |
446 | ones = hdlc_bitstuff_byte(iwb, (fcs >> 8) & 0x00ff, ones); | 427 | ones = hdlc_bitstuff_byte(iwb, (fcs >> 8) & 0x00ff, ones); |
@@ -459,7 +440,8 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb, | |||
459 | * parameters: | 440 | * parameters: |
460 | * in input buffer | 441 | * in input buffer |
461 | * count number of bytes in input buffer | 442 | * count number of bytes in input buffer |
462 | * iwb pointer to output buffer structure (write semaphore must be held) | 443 | * iwb pointer to output buffer structure |
444 | * (write semaphore must be held) | ||
463 | * return value: | 445 | * return value: |
464 | * position of end of packet in output buffer on success, | 446 | * position of end of packet in output buffer on success, |
465 | * -EAGAIN if write semaphore busy or buffer full | 447 | * -EAGAIN if write semaphore busy or buffer full |
@@ -567,8 +549,8 @@ static inline void hdlc_done(struct bc_state *bcs) | |||
567 | hdlc_flush(bcs); | 549 | hdlc_flush(bcs); |
568 | return; | 550 | return; |
569 | } | 551 | } |
570 | 552 | procskb = bcs->skb; | |
571 | if ((procskb = bcs->skb) == NULL) { | 553 | if (procskb == NULL) { |
572 | /* previous error */ | 554 | /* previous error */ |
573 | gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__); | 555 | gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__); |
574 | gigaset_isdn_rcv_err(bcs); | 556 | gigaset_isdn_rcv_err(bcs); |
@@ -646,8 +628,8 @@ static const unsigned char bitcounts[256] = { | |||
646 | }; | 628 | }; |
647 | 629 | ||
648 | /* hdlc_unpack | 630 | /* hdlc_unpack |
649 | * perform HDLC frame processing (bit unstuffing, flag detection, FCS calculation) | 631 | * perform HDLC frame processing (bit unstuffing, flag detection, FCS |
650 | * on a sequence of received data bytes (8 bits each, LSB first) | 632 | * calculation) on a sequence of received data bytes (8 bits each, LSB first) |
651 | * pass on successfully received, complete frames as SKBs via gigaset_skb_rcvd | 633 | * pass on successfully received, complete frames as SKBs via gigaset_skb_rcvd |
652 | * notify of errors via gigaset_isdn_rcv_err | 634 | * notify of errors via gigaset_isdn_rcv_err |
653 | * tally frames, errors etc. in BC structure counters | 635 | * tally frames, errors etc. in BC structure counters |
@@ -665,9 +647,12 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, | |||
665 | 647 | ||
666 | /* load previous state: | 648 | /* load previous state: |
667 | * inputstate = set of flag bits: | 649 | * inputstate = set of flag bits: |
668 | * - INS_flag_hunt: no complete opening flag received since connection setup or last abort | 650 | * - INS_flag_hunt: no complete opening flag received since connection |
669 | * - INS_have_data: at least one complete data byte received since last flag | 651 | * setup or last abort |
670 | * seqlen = number of consecutive '1' bits in last 7 input stream bits (0..7) | 652 | * - INS_have_data: at least one complete data byte received since last |
653 | * flag | ||
654 | * seqlen = number of consecutive '1' bits in last 7 input stream bits | ||
655 | * (0..7) | ||
671 | * inbyte = accumulated partial data byte (if !INS_flag_hunt) | 656 | * inbyte = accumulated partial data byte (if !INS_flag_hunt) |
672 | * inbits = number of valid bits in inbyte, starting at LSB (0..6) | 657 | * inbits = number of valid bits in inbyte, starting at LSB (0..6) |
673 | */ | 658 | */ |
@@ -701,9 +686,11 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, | |||
701 | inbyte = c >> (lead1 + 1); | 686 | inbyte = c >> (lead1 + 1); |
702 | inbits = 7 - lead1; | 687 | inbits = 7 - lead1; |
703 | if (trail1 >= 8) { | 688 | if (trail1 >= 8) { |
704 | /* interior stuffing: omitting the MSB handles most cases */ | 689 | /* interior stuffing: |
690 | * omitting the MSB handles most cases, | ||
691 | * correct the incorrectly handled | ||
692 | * cases individually */ | ||
705 | inbits--; | 693 | inbits--; |
706 | /* correct the incorrectly handled cases individually */ | ||
707 | switch (c) { | 694 | switch (c) { |
708 | case 0xbe: | 695 | case 0xbe: |
709 | inbyte = 0x3f; | 696 | inbyte = 0x3f; |
@@ -729,13 +716,14 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, | |||
729 | hdlc_flush(bcs); | 716 | hdlc_flush(bcs); |
730 | inputstate |= INS_flag_hunt; | 717 | inputstate |= INS_flag_hunt; |
731 | } else if (seqlen == 6) { | 718 | } else if (seqlen == 6) { |
732 | /* closing flag, including (6 - lead1) '1's and one '0' from inbits */ | 719 | /* closing flag, including (6 - lead1) '1's |
720 | * and one '0' from inbits */ | ||
733 | if (inbits > 7 - lead1) { | 721 | if (inbits > 7 - lead1) { |
734 | hdlc_frag(bcs, inbits + lead1 - 7); | 722 | hdlc_frag(bcs, inbits + lead1 - 7); |
735 | inputstate &= ~INS_have_data; | 723 | inputstate &= ~INS_have_data; |
736 | } else { | 724 | } else { |
737 | if (inbits < 7 - lead1) | 725 | if (inbits < 7 - lead1) |
738 | ubc->stolen0s ++; | 726 | ubc->stolen0s++; |
739 | if (inputstate & INS_have_data) { | 727 | if (inputstate & INS_have_data) { |
740 | hdlc_done(bcs); | 728 | hdlc_done(bcs); |
741 | inputstate &= ~INS_have_data; | 729 | inputstate &= ~INS_have_data; |
@@ -744,7 +732,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, | |||
744 | 732 | ||
745 | if (c == PPP_FLAG) { | 733 | if (c == PPP_FLAG) { |
746 | /* complete flag, LSB overlaps preceding flag */ | 734 | /* complete flag, LSB overlaps preceding flag */ |
747 | ubc->shared0s ++; | 735 | ubc->shared0s++; |
748 | inbits = 0; | 736 | inbits = 0; |
749 | inbyte = 0; | 737 | inbyte = 0; |
750 | } else if (trail1 != 7) { | 738 | } else if (trail1 != 7) { |
@@ -752,9 +740,11 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, | |||
752 | inbyte = c >> (lead1 + 1); | 740 | inbyte = c >> (lead1 + 1); |
753 | inbits = 7 - lead1; | 741 | inbits = 7 - lead1; |
754 | if (trail1 >= 8) { | 742 | if (trail1 >= 8) { |
755 | /* interior stuffing: omitting the MSB handles most cases */ | 743 | /* interior stuffing: |
744 | * omitting the MSB handles most cases, | ||
745 | * correct the incorrectly handled | ||
746 | * cases individually */ | ||
756 | inbits--; | 747 | inbits--; |
757 | /* correct the incorrectly handled cases individually */ | ||
758 | switch (c) { | 748 | switch (c) { |
759 | case 0xbe: | 749 | case 0xbe: |
760 | inbyte = 0x3f; | 750 | inbyte = 0x3f; |
@@ -762,7 +752,8 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, | |||
762 | } | 752 | } |
763 | } | 753 | } |
764 | } else { | 754 | } else { |
765 | /* abort sequence follows, skb already empty anyway */ | 755 | /* abort sequence follows, |
756 | * skb already empty anyway */ | ||
766 | ubc->aborts++; | 757 | ubc->aborts++; |
767 | inputstate |= INS_flag_hunt; | 758 | inputstate |= INS_flag_hunt; |
768 | } | 759 | } |
@@ -787,14 +778,17 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, | |||
787 | } else { | 778 | } else { |
788 | /* stuffed data */ | 779 | /* stuffed data */ |
789 | if (trail1 < 7) { /* => seqlen == 5 */ | 780 | if (trail1 < 7) { /* => seqlen == 5 */ |
790 | /* stuff bit at position lead1, no interior stuffing */ | 781 | /* stuff bit at position lead1, |
782 | * no interior stuffing */ | ||
791 | unsigned char mask = (1 << lead1) - 1; | 783 | unsigned char mask = (1 << lead1) - 1; |
792 | c = (c & mask) | ((c & ~mask) >> 1); | 784 | c = (c & mask) | ((c & ~mask) >> 1); |
793 | inbyte |= c << inbits; | 785 | inbyte |= c << inbits; |
794 | inbits += 7; | 786 | inbits += 7; |
795 | } else if (seqlen < 5) { /* trail1 >= 8 */ | 787 | } else if (seqlen < 5) { /* trail1 >= 8 */ |
796 | /* interior stuffing: omitting the MSB handles most cases */ | 788 | /* interior stuffing: |
797 | /* correct the incorrectly handled cases individually */ | 789 | * omitting the MSB handles most cases, |
790 | * correct the incorrectly handled | ||
791 | * cases individually */ | ||
798 | switch (c) { | 792 | switch (c) { |
799 | case 0xbe: | 793 | case 0xbe: |
800 | c = 0x7e; | 794 | c = 0x7e; |
@@ -804,8 +798,9 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, | |||
804 | inbits += 7; | 798 | inbits += 7; |
805 | } else { /* seqlen == 5 && trail1 >= 8 */ | 799 | } else { /* seqlen == 5 && trail1 >= 8 */ |
806 | 800 | ||
807 | /* stuff bit at lead1 *and* interior stuffing */ | 801 | /* stuff bit at lead1 *and* interior |
808 | switch (c) { /* unstuff individually */ | 802 | * stuffing -- unstuff individually */ |
803 | switch (c) { | ||
809 | case 0x7d: | 804 | case 0x7d: |
810 | c = 0x3f; | 805 | c = 0x3f; |
811 | break; | 806 | break; |
@@ -862,7 +857,8 @@ static inline void trans_receive(unsigned char *src, unsigned count, | |||
862 | hdlc_flush(bcs); | 857 | hdlc_flush(bcs); |
863 | return; | 858 | return; |
864 | } | 859 | } |
865 | if (unlikely((skb = bcs->skb) == NULL)) { | 860 | skb = bcs->skb; |
861 | if (unlikely(skb == NULL)) { | ||
866 | bcs->skb = skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len); | 862 | bcs->skb = skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len); |
867 | if (!skb) { | 863 | if (!skb) { |
868 | dev_err(cs->dev, "could not allocate skb\n"); | 864 | dev_err(cs->dev, "could not allocate skb\n"); |
@@ -895,7 +891,8 @@ static inline void trans_receive(unsigned char *src, unsigned count, | |||
895 | } | 891 | } |
896 | } | 892 | } |
897 | 893 | ||
898 | void gigaset_isoc_receive(unsigned char *src, unsigned count, struct bc_state *bcs) | 894 | void gigaset_isoc_receive(unsigned char *src, unsigned count, |
895 | struct bc_state *bcs) | ||
899 | { | 896 | { |
900 | switch (bcs->proto2) { | 897 | switch (bcs->proto2) { |
901 | case L2_HDLC: | 898 | case L2_HDLC: |