Commit 7891adf1 authored by Tilman Schmidt's avatar Tilman Schmidt Committed by David S. Miller

bas_gigaset: checkpatch cleanup

On the quest for the holy grail of checkpatch.pl silence.

Impact: cosmetic
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ae67d7d8
...@@ -57,7 +57,7 @@ MODULE_PARM_DESC(cidmode, "Call-ID mode"); ...@@ -57,7 +57,7 @@ MODULE_PARM_DESC(cidmode, "Call-ID mode");
#define USB_SX353_PRODUCT_ID 0x0022 #define USB_SX353_PRODUCT_ID 0x0022
/* table of devices that work with this driver */ /* table of devices that work with this driver */
static const struct usb_device_id gigaset_table [] = { static const struct usb_device_id gigaset_table[] = {
{ USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3070_PRODUCT_ID) }, { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3070_PRODUCT_ID) },
{ USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3075_PRODUCT_ID) }, { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3075_PRODUCT_ID) },
{ USB_DEVICE(USB_GIGA_VENDOR_ID, USB_SX303_PRODUCT_ID) }, { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_SX303_PRODUCT_ID) },
...@@ -137,7 +137,7 @@ struct bas_cardstate { ...@@ -137,7 +137,7 @@ struct bas_cardstate {
#define BS_RESETTING 0x200 /* waiting for HD_RESET_INTERRUPT_PIPE_ACK */ #define BS_RESETTING 0x200 /* waiting for HD_RESET_INTERRUPT_PIPE_ACK */
static struct gigaset_driver *driver = NULL; static struct gigaset_driver *driver;
/* usb specific object needed to register this driver with the usb subsystem */ /* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver gigaset_usb_driver = { static struct usb_driver gigaset_usb_driver = {
...@@ -601,11 +601,12 @@ static int atread_submit(struct cardstate *cs, int timeout) ...@@ -601,11 +601,12 @@ static int atread_submit(struct cardstate *cs, int timeout)
ucs->dr_cmd_in.wLength = cpu_to_le16(ucs->rcvbuf_size); ucs->dr_cmd_in.wLength = cpu_to_le16(ucs->rcvbuf_size);
usb_fill_control_urb(ucs->urb_cmd_in, ucs->udev, usb_fill_control_urb(ucs->urb_cmd_in, ucs->udev,
usb_rcvctrlpipe(ucs->udev, 0), usb_rcvctrlpipe(ucs->udev, 0),
(unsigned char*) & ucs->dr_cmd_in, (unsigned char *) &ucs->dr_cmd_in,
ucs->rcvbuf, ucs->rcvbuf_size, ucs->rcvbuf, ucs->rcvbuf_size,
read_ctrl_callback, cs->inbuf); read_ctrl_callback, cs->inbuf);
if ((ret = usb_submit_urb(ucs->urb_cmd_in, GFP_ATOMIC)) != 0) { ret = usb_submit_urb(ucs->urb_cmd_in, GFP_ATOMIC);
if (ret != 0) {
update_basstate(ucs, 0, BS_ATRDPEND); update_basstate(ucs, 0, BS_ATRDPEND);
dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n", dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n",
get_usb_rcmsg(ret)); get_usb_rcmsg(ret));
...@@ -652,13 +653,11 @@ static void read_int_callback(struct urb *urb) ...@@ -652,13 +653,11 @@ static void read_int_callback(struct urb *urb)
return; return;
case -ENODEV: /* device removed */ case -ENODEV: /* device removed */
case -ESHUTDOWN: /* device shut down */ case -ESHUTDOWN: /* device shut down */
//FIXME use this as disconnect indicator?
gig_dbg(DEBUG_USBREQ, "%s: device disconnected", __func__); gig_dbg(DEBUG_USBREQ, "%s: device disconnected", __func__);
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(status)); get_usb_statmsg(status));
//FIXME corrective action? resubmission always ok?
goto resubmit; goto resubmit;
} }
...@@ -742,7 +741,8 @@ static void read_int_callback(struct urb *urb) ...@@ -742,7 +741,8 @@ static void read_int_callback(struct urb *urb)
kfree(ucs->rcvbuf); kfree(ucs->rcvbuf);
ucs->rcvbuf_size = 0; ucs->rcvbuf_size = 0;
} }
if ((ucs->rcvbuf = kmalloc(l, GFP_ATOMIC)) == NULL) { ucs->rcvbuf = kmalloc(l, GFP_ATOMIC);
if (ucs->rcvbuf == NULL) {
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
dev_err(cs->dev, "out of memory receiving AT data\n"); dev_err(cs->dev, "out of memory receiving AT data\n");
error_reset(cs); error_reset(cs);
...@@ -750,12 +750,12 @@ static void read_int_callback(struct urb *urb) ...@@ -750,12 +750,12 @@ static void read_int_callback(struct urb *urb)
} }
ucs->rcvbuf_size = l; ucs->rcvbuf_size = l;
ucs->retry_cmd_in = 0; ucs->retry_cmd_in = 0;
if ((rc = atread_submit(cs, BAS_TIMEOUT)) < 0) { rc = atread_submit(cs, BAS_TIMEOUT);
if (rc < 0) {
kfree(ucs->rcvbuf); kfree(ucs->rcvbuf);
ucs->rcvbuf = NULL; ucs->rcvbuf = NULL;
ucs->rcvbuf_size = 0; ucs->rcvbuf_size = 0;
if (rc != -ENODEV) { if (rc != -ENODEV) {
//FIXME corrective action?
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
error_reset(cs); error_reset(cs);
break; break;
...@@ -940,7 +940,8 @@ static int starturbs(struct bc_state *bcs) ...@@ -940,7 +940,8 @@ static int starturbs(struct bc_state *bcs)
} }
dump_urb(DEBUG_ISO, "Initial isoc read", urb); dump_urb(DEBUG_ISO, "Initial isoc read", urb);
if ((rc = usb_submit_urb(urb, GFP_ATOMIC)) != 0) rc = usb_submit_urb(urb, GFP_ATOMIC);
if (rc != 0)
goto error; goto error;
} }
...@@ -1045,7 +1046,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) ...@@ -1045,7 +1046,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
/* compute frame length according to flow control */ /* compute frame length according to flow control */
ifd->length = BAS_NORMFRAME; ifd->length = BAS_NORMFRAME;
if ((corrbytes = atomic_read(&ubc->corrbytes)) != 0) { corrbytes = atomic_read(&ubc->corrbytes);
if (corrbytes != 0) {
gig_dbg(DEBUG_ISO, "%s: corrbytes=%d", gig_dbg(DEBUG_ISO, "%s: corrbytes=%d",
__func__, corrbytes); __func__, corrbytes);
if (corrbytes > BAS_HIGHFRAME - BAS_NORMFRAME) if (corrbytes > BAS_HIGHFRAME - BAS_NORMFRAME)
...@@ -1284,7 +1286,8 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1284,7 +1286,8 @@ static void read_iso_tasklet(unsigned long data)
for (;;) { for (;;) {
/* retrieve URB */ /* retrieve URB */
spin_lock_irqsave(&ubc->isoinlock, flags); spin_lock_irqsave(&ubc->isoinlock, flags);
if (!(urb = ubc->isoindone)) { urb = ubc->isoindone;
if (!urb) {
spin_unlock_irqrestore(&ubc->isoinlock, flags); spin_unlock_irqrestore(&ubc->isoinlock, flags);
return; return;
} }
...@@ -1371,7 +1374,7 @@ static void read_iso_tasklet(unsigned long data) ...@@ -1371,7 +1374,7 @@ static void read_iso_tasklet(unsigned long data)
"isochronous read: %d data bytes missing\n", "isochronous read: %d data bytes missing\n",
totleft); totleft);
error: error:
/* URB processed, resubmit */ /* URB processed, resubmit */
for (frame = 0; frame < BAS_NUMFRAMES; frame++) { for (frame = 0; frame < BAS_NUMFRAMES; frame++) {
urb->iso_frame_desc[frame].status = 0; 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,7 +1571,7 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
ucs->dr_ctrl.wLength = 0; ucs->dr_ctrl.wLength = 0;
usb_fill_control_urb(ucs->urb_ctrl, ucs->udev, usb_fill_control_urb(ucs->urb_ctrl, ucs->udev,
usb_sndctrlpipe(ucs->udev, 0), usb_sndctrlpipe(ucs->udev, 0),
(unsigned char*) &ucs->dr_ctrl, NULL, 0, (unsigned char *) &ucs->dr_ctrl, NULL, 0,
write_ctrl_callback, ucs); write_ctrl_callback, ucs);
ucs->retry_ctrl = 0; ucs->retry_ctrl = 0;
ret = usb_submit_urb(ucs->urb_ctrl, GFP_ATOMIC); ret = usb_submit_urb(ucs->urb_ctrl, GFP_ATOMIC);
...@@ -1621,7 +1624,8 @@ static int gigaset_init_bchannel(struct bc_state *bcs) ...@@ -1621,7 +1624,8 @@ static int gigaset_init_bchannel(struct bc_state *bcs)
return -EHOSTUNREACH; return -EHOSTUNREACH;
} }
if ((ret = starturbs(bcs)) < 0) { ret = starturbs(bcs);
if (ret < 0) {
dev_err(cs->dev, dev_err(cs->dev,
"could not start isochronous I/O for channel B%d: %s\n", "could not start isochronous I/O for channel B%d: %s\n",
bcs->channel + 1, bcs->channel + 1,
...@@ -1633,7 +1637,8 @@ static int gigaset_init_bchannel(struct bc_state *bcs) ...@@ -1633,7 +1637,8 @@ static int gigaset_init_bchannel(struct bc_state *bcs)
} }
req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL; req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL;
if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) { ret = req_submit(bcs, req, 0, BAS_TIMEOUT);
if (ret < 0) {
dev_err(cs->dev, "could not open channel B%d\n", dev_err(cs->dev, "could not open channel B%d\n",
bcs->channel + 1); bcs->channel + 1);
stopurbs(bcs->hw.bas); stopurbs(bcs->hw.bas);
...@@ -1677,7 +1682,8 @@ static int gigaset_close_bchannel(struct bc_state *bcs) ...@@ -1677,7 +1682,8 @@ static int gigaset_close_bchannel(struct bc_state *bcs)
/* channel running: tell device to close it */ /* channel running: tell device to close it */
req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL; req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL;
if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) ret = req_submit(bcs, req, 0, BAS_TIMEOUT);
if (ret < 0)
dev_err(cs->dev, "closing channel B%d failed\n", dev_err(cs->dev, "closing channel B%d failed\n",
bcs->channel + 1); bcs->channel + 1);
...@@ -1703,10 +1709,12 @@ static void complete_cb(struct cardstate *cs) ...@@ -1703,10 +1709,12 @@ static void complete_cb(struct cardstate *cs)
gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD,
"write_command: sent %u bytes, %u left", "write_command: sent %u bytes, %u left",
cs->curlen, cs->cmdbytes); cs->curlen, cs->cmdbytes);
if ((cs->cmdbuf = cb->next) != NULL) { if (cb->next != NULL) {
cs->cmdbuf = cb->next;
cs->cmdbuf->prev = NULL; cs->cmdbuf->prev = NULL;
cs->curlen = cs->cmdbuf->len; cs->curlen = cs->cmdbuf->len;
} else { } else {
cs->cmdbuf = NULL;
cs->lastcmdbuf = NULL; cs->lastcmdbuf = NULL;
cs->curlen = 0; cs->curlen = 0;
} }
...@@ -1833,7 +1841,7 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len) ...@@ -1833,7 +1841,7 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
ucs->dr_cmd_out.wLength = cpu_to_le16(len); ucs->dr_cmd_out.wLength = cpu_to_le16(len);
usb_fill_control_urb(ucs->urb_cmd_out, ucs->udev, usb_fill_control_urb(ucs->urb_cmd_out, ucs->udev,
usb_sndctrlpipe(ucs->udev, 0), usb_sndctrlpipe(ucs->udev, 0),
(unsigned char*) &ucs->dr_cmd_out, buf, len, (unsigned char *) &ucs->dr_cmd_out, buf, len,
write_command_callback, cs); write_command_callback, cs);
rc = usb_submit_urb(ucs->urb_cmd_out, GFP_ATOMIC); rc = usb_submit_urb(ucs->urb_cmd_out, GFP_ATOMIC);
if (unlikely(rc)) { if (unlikely(rc)) {
...@@ -1953,7 +1961,8 @@ static int gigaset_write_cmd(struct cardstate *cs, ...@@ -1953,7 +1961,8 @@ static int gigaset_write_cmd(struct cardstate *cs,
if (len > IF_WRITEBUF) if (len > IF_WRITEBUF)
len = IF_WRITEBUF; len = IF_WRITEBUF;
if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC);
if (!cb) {
dev_err(cs->dev, "%s: out of memory\n", __func__); dev_err(cs->dev, "%s: out of memory\n", __func__);
rc = -ENOMEM; rc = -ENOMEM;
goto notqueued; goto notqueued;
...@@ -2100,7 +2109,8 @@ static int gigaset_initbcshw(struct bc_state *bcs) ...@@ -2100,7 +2109,8 @@ static int gigaset_initbcshw(struct bc_state *bcs)
} }
ubc->isooutdone = ubc->isooutfree = ubc->isooutovfl = NULL; ubc->isooutdone = ubc->isooutfree = ubc->isooutovfl = NULL;
ubc->numsub = 0; ubc->numsub = 0;
if (!(ubc->isooutbuf = kmalloc(sizeof(struct isowbuf_t), GFP_KERNEL))) { ubc->isooutbuf = kmalloc(sizeof(struct isowbuf_t), GFP_KERNEL);
if (!ubc->isooutbuf) {
pr_err("out of memory\n"); pr_err("out of memory\n");
kfree(ubc); kfree(ubc);
bcs->hw.bas = NULL; bcs->hw.bas = NULL;
...@@ -2252,7 +2262,8 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2252,7 +2262,8 @@ static int gigaset_probe(struct usb_interface *interface,
gig_dbg(DEBUG_ANY, gig_dbg(DEBUG_ANY,
"%s: wrong alternate setting %d - trying to switch", "%s: wrong alternate setting %d - trying to switch",
__func__, hostif->desc.bAlternateSetting); __func__, hostif->desc.bAlternateSetting);
if (usb_set_interface(udev, hostif->desc.bInterfaceNumber, 3) < 0) { if (usb_set_interface(udev, hostif->desc.bInterfaceNumber, 3)
< 0) {
dev_warn(&udev->dev, "usb_set_interface failed, " dev_warn(&udev->dev, "usb_set_interface failed, "
"device %d interface %d altsetting %d\n", "device %d interface %d altsetting %d\n",
udev->devnum, hostif->desc.bInterfaceNumber, udev->devnum, hostif->desc.bInterfaceNumber,
...@@ -2321,14 +2332,16 @@ static int gigaset_probe(struct usb_interface *interface, ...@@ -2321,14 +2332,16 @@ static int gigaset_probe(struct usb_interface *interface,
(endpoint->bEndpointAddress) & 0x0f), (endpoint->bEndpointAddress) & 0x0f),
ucs->int_in_buf, IP_MSGSIZE, read_int_callback, cs, ucs->int_in_buf, IP_MSGSIZE, read_int_callback, cs,
endpoint->bInterval); endpoint->bInterval);
if ((rc = usb_submit_urb(ucs->urb_int_in, GFP_KERNEL)) != 0) { rc = usb_submit_urb(ucs->urb_int_in, GFP_KERNEL);
if (rc != 0) {
dev_err(cs->dev, "could not submit interrupt URB: %s\n", dev_err(cs->dev, "could not submit interrupt URB: %s\n",
get_usb_rcmsg(rc)); get_usb_rcmsg(rc));
goto error; goto error;
} }
/* tell the device that the driver is ready */ /* tell the device that the driver is ready */
if ((rc = req_submit(cs->bcs, HD_DEVICE_INIT_ACK, 0, 0)) != 0) rc = req_submit(cs->bcs, HD_DEVICE_INIT_ACK, 0, 0);
if (rc != 0)
goto error; goto error;
/* tell common part that the device is ready */ /* tell common part that the device is ready */
...@@ -2524,9 +2537,10 @@ static int __init bas_gigaset_init(void) ...@@ -2524,9 +2537,10 @@ static int __init bas_gigaset_init(void)
int result; int result;
/* allocate memory for our driver state and intialize it */ /* allocate memory for our driver state and intialize it */
if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
GIGASET_MODULENAME, GIGASET_DEVNAME, GIGASET_MODULENAME, GIGASET_DEVNAME,
&gigops, THIS_MODULE)) == NULL) &gigops, THIS_MODULE);
if (driver == NULL)
goto error; goto error;
/* register this driver with the USB subsystem */ /* register this driver with the USB subsystem */
......
...@@ -41,7 +41,8 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb) ...@@ -41,7 +41,8 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb)
read = iwb->read; read = iwb->read;
write = iwb->write; write = iwb->write;
if ((freebytes = read - write) > 0) { freebytes = read - write;
if (freebytes > 0) {
/* no wraparound: need padding space within regular area */ /* no wraparound: need padding space within regular area */
return freebytes - BAS_OUTBUFPAD; return freebytes - BAS_OUTBUFPAD;
} else if (read < BAS_OUTBUFPAD) { } else if (read < BAS_OUTBUFPAD) {
...@@ -53,29 +54,6 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb) ...@@ -53,29 +54,6 @@ static inline int isowbuf_freebytes(struct isowbuf_t *iwb)
} }
} }
/* compare two offsets within the buffer
* The buffer is seen as circular, with the read position as start
* returns -1/0/1 if position a </=/> position b without crossing 'read'
*/
static inline int isowbuf_poscmp(struct isowbuf_t *iwb, int a, int b)
{
int read;
if (a == b)
return 0;
read = iwb->read;
if (a < b) {
if (a < read && read <= b)
return +1;
else
return -1;
} else {
if (b < read && read <= a)
return -1;
else
return +1;
}
}
/* start writing /* start writing
* acquire the write semaphore * acquire the write semaphore
* return true if acquired, false if busy * return true if acquired, false if busy
...@@ -271,7 +249,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag, ...@@ -271,7 +249,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
* bit 14..13 = number of bits added by stuffing * bit 14..13 = number of bits added by stuffing
*/ */
static const u16 stufftab[5 * 256] = { static const u16 stufftab[5 * 256] = {
// previous 1s = 0: /* previous 1s = 0: */
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x201f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x201f,
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, 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,7 +267,7 @@ static const u16 stufftab[5 * 256] = {
0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x0cef, 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x0cef,
0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x2ddf, 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x2ddf,
// previous 1s = 1: /* previous 1s = 1: */
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x200f, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x200f,
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x202f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x202f,
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x204f, 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,7 +285,7 @@ static const u16 stufftab[5 * 256] = {
0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dcf, 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dcf,
0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x31ef, 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x31ef,
// previous 1s = 2: /* previous 1s = 2: */
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x2007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x2017, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x2007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x2017,
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x2027, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x2037, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x2027, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x2037,
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x2047, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x2057, 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,7 +303,7 @@ static const u16 stufftab[5 * 256] = {
0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dc7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dd7, 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dc7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dd7,
0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x31e7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x41f7, 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x31e7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x41f7,
// previous 1s = 3: /* previous 1s = 3: */
0x0000, 0x0001, 0x0002, 0x2003, 0x0004, 0x0005, 0x0006, 0x200b, 0x0008, 0x0009, 0x000a, 0x2013, 0x000c, 0x000d, 0x000e, 0x201b, 0x0000, 0x0001, 0x0002, 0x2003, 0x0004, 0x0005, 0x0006, 0x200b, 0x0008, 0x0009, 0x000a, 0x2013, 0x000c, 0x000d, 0x000e, 0x201b,
0x0010, 0x0011, 0x0012, 0x2023, 0x0014, 0x0015, 0x0016, 0x202b, 0x0018, 0x0019, 0x001a, 0x2033, 0x001c, 0x001d, 0x001e, 0x203b, 0x0010, 0x0011, 0x0012, 0x2023, 0x0014, 0x0015, 0x0016, 0x202b, 0x0018, 0x0019, 0x001a, 0x2033, 0x001c, 0x001d, 0x001e, 0x203b,
0x0020, 0x0021, 0x0022, 0x2043, 0x0024, 0x0025, 0x0026, 0x204b, 0x0028, 0x0029, 0x002a, 0x2053, 0x002c, 0x002d, 0x002e, 0x205b, 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,7 +321,7 @@ static const u16 stufftab[5 * 256] = {
0x0ce0, 0x0ce1, 0x0ce2, 0x2dc3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dcb, 0x0ce8, 0x0ce9, 0x0cea, 0x2dd3, 0x0cec, 0x0ced, 0x0cee, 0x2ddb, 0x0ce0, 0x0ce1, 0x0ce2, 0x2dc3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dcb, 0x0ce8, 0x0ce9, 0x0cea, 0x2dd3, 0x0cec, 0x0ced, 0x0cee, 0x2ddb,
0x10f0, 0x10f1, 0x10f2, 0x31e3, 0x10f4, 0x10f5, 0x10f6, 0x31eb, 0x20f8, 0x20f9, 0x20fa, 0x41f3, 0x257c, 0x257d, 0x29be, 0x46fb, 0x10f0, 0x10f1, 0x10f2, 0x31e3, 0x10f4, 0x10f5, 0x10f6, 0x31eb, 0x20f8, 0x20f9, 0x20fa, 0x41f3, 0x257c, 0x257d, 0x29be, 0x46fb,
// previous 1s = 4: /* previous 1s = 4: */
0x0000, 0x2001, 0x0002, 0x2005, 0x0004, 0x2009, 0x0006, 0x200d, 0x0008, 0x2011, 0x000a, 0x2015, 0x000c, 0x2019, 0x000e, 0x201d, 0x0000, 0x2001, 0x0002, 0x2005, 0x0004, 0x2009, 0x0006, 0x200d, 0x0008, 0x2011, 0x000a, 0x2015, 0x000c, 0x2019, 0x000e, 0x201d,
0x0010, 0x2021, 0x0012, 0x2025, 0x0014, 0x2029, 0x0016, 0x202d, 0x0018, 0x2031, 0x001a, 0x2035, 0x001c, 0x2039, 0x001e, 0x203d, 0x0010, 0x2021, 0x0012, 0x2025, 0x0014, 0x2029, 0x0016, 0x202d, 0x0018, 0x2031, 0x001a, 0x2035, 0x001c, 0x2039, 0x001e, 0x203d,
0x0020, 0x2041, 0x0022, 0x2045, 0x0024, 0x2049, 0x0026, 0x204d, 0x0028, 0x2051, 0x002a, 0x2055, 0x002c, 0x2059, 0x002e, 0x205d, 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,7 +345,8 @@ static const u16 stufftab[5 * 256] = {
* parameters: * parameters:
* cin input byte * cin input byte
* ones number of trailing '1' bits in result before this step * ones number of trailing '1' bits in result before this step
* iwb pointer to output buffer structure (write semaphore must be held) * iwb pointer to output buffer structure
* (write semaphore must be held)
* return value: * return value:
* number of trailing '1' bits in result after this step * number of trailing '1' bits in result after this step
*/ */
...@@ -408,7 +387,8 @@ static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin, ...@@ -408,7 +387,8 @@ static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin,
* parameters: * parameters:
* in input buffer * in input buffer
* count number of bytes in input buffer * count number of bytes in input buffer
* iwb pointer to output buffer structure (write semaphore must be held) * iwb pointer to output buffer structure
* (write semaphore must be held)
* return value: * return value:
* position of end of packet in output buffer on success, * position of end of packet in output buffer on success,
* -EAGAIN if write semaphore busy or buffer full * -EAGAIN if write semaphore busy or buffer full
...@@ -440,7 +420,8 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb, ...@@ -440,7 +420,8 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb,
fcs = crc_ccitt_byte(fcs, c); fcs = crc_ccitt_byte(fcs, c);
} }
/* bitstuff and append FCS (complemented, least significant byte first) */ /* bitstuff and append FCS
* (complemented, least significant byte first) */
fcs ^= 0xffff; fcs ^= 0xffff;
ones = hdlc_bitstuff_byte(iwb, fcs & 0x00ff, ones); ones = hdlc_bitstuff_byte(iwb, fcs & 0x00ff, ones);
ones = hdlc_bitstuff_byte(iwb, (fcs >> 8) & 0x00ff, ones); ones = hdlc_bitstuff_byte(iwb, (fcs >> 8) & 0x00ff, ones);
...@@ -459,7 +440,8 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb, ...@@ -459,7 +440,8 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb,
* parameters: * parameters:
* in input buffer * in input buffer
* count number of bytes in input buffer * count number of bytes in input buffer
* iwb pointer to output buffer structure (write semaphore must be held) * iwb pointer to output buffer structure
* (write semaphore must be held)
* return value: * return value:
* position of end of packet in output buffer on success, * position of end of packet in output buffer on success,
* -EAGAIN if write semaphore busy or buffer full * -EAGAIN if write semaphore busy or buffer full
...@@ -567,8 +549,8 @@ static inline void hdlc_done(struct bc_state *bcs) ...@@ -567,8 +549,8 @@ static inline void hdlc_done(struct bc_state *bcs)
hdlc_flush(bcs); hdlc_flush(bcs);
return; return;
} }
procskb = bcs->skb;
if ((procskb = bcs->skb) == NULL) { if (procskb == NULL) {
/* previous error */ /* previous error */
gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__); gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
gigaset_isdn_rcv_err(bcs); gigaset_isdn_rcv_err(bcs);
...@@ -646,8 +628,8 @@ static const unsigned char bitcounts[256] = { ...@@ -646,8 +628,8 @@ static const unsigned char bitcounts[256] = {
}; };
/* hdlc_unpack /* hdlc_unpack
* perform HDLC frame processing (bit unstuffing, flag detection, FCS calculation) * perform HDLC frame processing (bit unstuffing, flag detection, FCS
* on a sequence of received data bytes (8 bits each, LSB first) * calculation) on a sequence of received data bytes (8 bits each, LSB first)
* pass on successfully received, complete frames as SKBs via gigaset_skb_rcvd * pass on successfully received, complete frames as SKBs via gigaset_skb_rcvd
* notify of errors via gigaset_isdn_rcv_err * notify of errors via gigaset_isdn_rcv_err
* tally frames, errors etc. in BC structure counters * tally frames, errors etc. in BC structure counters
...@@ -665,9 +647,12 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, ...@@ -665,9 +647,12 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
/* load previous state: /* load previous state:
* inputstate = set of flag bits: * inputstate = set of flag bits:
* - INS_flag_hunt: no complete opening flag received since connection setup or last abort * - INS_flag_hunt: no complete opening flag received since connection
* - INS_have_data: at least one complete data byte received since last flag * setup or last abort
* seqlen = number of consecutive '1' bits in last 7 input stream bits (0..7) * - INS_have_data: at least one complete data byte received since last
* flag
* seqlen = number of consecutive '1' bits in last 7 input stream bits
* (0..7)
* inbyte = accumulated partial data byte (if !INS_flag_hunt) * inbyte = accumulated partial data byte (if !INS_flag_hunt)
* inbits = number of valid bits in inbyte, starting at LSB (0..6) * inbits = number of valid bits in inbyte, starting at LSB (0..6)
*/ */
...@@ -701,9 +686,11 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, ...@@ -701,9 +686,11 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
inbyte = c >> (lead1 + 1); inbyte = c >> (lead1 + 1);
inbits = 7 - lead1; inbits = 7 - lead1;
if (trail1 >= 8) { if (trail1 >= 8) {
/* interior stuffing: omitting the MSB handles most cases */ /* interior stuffing:
* omitting the MSB handles most cases,
* correct the incorrectly handled
* cases individually */
inbits--; inbits--;
/* correct the incorrectly handled cases individually */
switch (c) { switch (c) {
case 0xbe: case 0xbe:
inbyte = 0x3f; inbyte = 0x3f;
...@@ -729,13 +716,14 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, ...@@ -729,13 +716,14 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
hdlc_flush(bcs); hdlc_flush(bcs);
inputstate |= INS_flag_hunt; inputstate |= INS_flag_hunt;
} else if (seqlen == 6) { } else if (seqlen == 6) {
/* closing flag, including (6 - lead1) '1's and one '0' from inbits */ /* closing flag, including (6 - lead1) '1's
* and one '0' from inbits */
if (inbits > 7 - lead1) { if (inbits > 7 - lead1) {
hdlc_frag(bcs, inbits + lead1 - 7); hdlc_frag(bcs, inbits + lead1 - 7);
inputstate &= ~INS_have_data; inputstate &= ~INS_have_data;
} else { } else {
if (inbits < 7 - lead1) if (inbits < 7 - lead1)
ubc->stolen0s ++; ubc->stolen0s++;
if (inputstate & INS_have_data) { if (inputstate & INS_have_data) {
hdlc_done(bcs); hdlc_done(bcs);
inputstate &= ~INS_have_data; inputstate &= ~INS_have_data;
...@@ -744,7 +732,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, ...@@ -744,7 +732,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
if (c == PPP_FLAG) { if (c == PPP_FLAG) {
/* complete flag, LSB overlaps preceding flag */ /* complete flag, LSB overlaps preceding flag */
ubc->shared0s ++; ubc->shared0s++;
inbits = 0; inbits = 0;
inbyte = 0; inbyte = 0;
} else if (trail1 != 7) { } else if (trail1 != 7) {
...@@ -752,9 +740,11 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, ...@@ -752,9 +740,11 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
inbyte = c >> (lead1 + 1); inbyte = c >> (lead1 + 1);
inbits = 7 - lead1; inbits = 7 - lead1;
if (trail1 >= 8) { if (trail1 >= 8) {
/* interior stuffing: omitting the MSB handles most cases */ /* interior stuffing:
* omitting the MSB handles most cases,
* correct the incorrectly handled
* cases individually */
inbits--; inbits--;
/* correct the incorrectly handled cases individually */
switch (c) { switch (c) {
case 0xbe: case 0xbe:
inbyte = 0x3f; inbyte = 0x3f;
...@@ -762,7 +752,8 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, ...@@ -762,7 +752,8 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
} }
} }
} else { } else {
/* abort sequence follows, skb already empty anyway */ /* abort sequence follows,
* skb already empty anyway */
ubc->aborts++; ubc->aborts++;
inputstate |= INS_flag_hunt; inputstate |= INS_flag_hunt;
} }
...@@ -787,14 +778,17 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, ...@@ -787,14 +778,17 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
} else { } else {
/* stuffed data */ /* stuffed data */
if (trail1 < 7) { /* => seqlen == 5 */ if (trail1 < 7) { /* => seqlen == 5 */
/* stuff bit at position lead1, no interior stuffing */ /* stuff bit at position lead1,
* no interior stuffing */
unsigned char mask = (1 << lead1) - 1; unsigned char mask = (1 << lead1) - 1;
c = (c & mask) | ((c & ~mask) >> 1); c = (c & mask) | ((c & ~mask) >> 1);
inbyte |= c << inbits; inbyte |= c << inbits;
inbits += 7; inbits += 7;
} else if (seqlen < 5) { /* trail1 >= 8 */ } else if (seqlen < 5) { /* trail1 >= 8 */
/* interior stuffing: omitting the MSB handles most cases */ /* interior stuffing:
/* correct the incorrectly handled cases individually */ * omitting the MSB handles most cases,
* correct the incorrectly handled
* cases individually */
switch (c) { switch (c) {
case 0xbe: case 0xbe:
c = 0x7e; c = 0x7e;
...@@ -804,8 +798,9 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count, ...@@ -804,8 +798,9 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
inbits += 7; inbits += 7;
} else { /* seqlen == 5 && trail1 >= 8 */ } else { /* seqlen == 5 && trail1 >= 8 */
/* stuff bit at lead1 *and* interior stuffing */ /* stuff bit at lead1 *and* interior
switch (c) { /* unstuff individually */ * stuffing -- unstuff individually */
switch (c) {
case 0x7d: case 0x7d:
c = 0x3f; c = 0x3f;
break; break;
...@@ -862,7 +857,8 @@ static inline void trans_receive(unsigned char *src, unsigned count, ...@@ -862,7 +857,8 @@ static inline void trans_receive(unsigned char *src, unsigned count,
hdlc_flush(bcs); hdlc_flush(bcs);
return; return;
} }
if (unlikely((skb = bcs->skb) == NULL)) { skb = bcs->skb;
if (unlikely(skb == NULL)) {
bcs->skb = skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len); bcs->skb = skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
if (!skb) { if (!skb) {
dev_err(cs->dev, "could not allocate skb\n"); dev_err(cs->dev, "could not allocate skb\n");
...@@ -895,7 +891,8 @@ static inline void trans_receive(unsigned char *src, unsigned count, ...@@ -895,7 +891,8 @@ static inline void trans_receive(unsigned char *src, unsigned count,
} }
} }
void gigaset_isoc_receive(unsigned char *src, unsigned count, struct bc_state *bcs) void gigaset_isoc_receive(unsigned char *src, unsigned count,
struct bc_state *bcs)
{ {
switch (bcs->proto2) { switch (bcs->proto2) {
case L2_HDLC: case L2_HDLC:
......
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