From 475be4d85a274d0961593db41cf85689db1d583c Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 19 Feb 2012 19:52:38 -0800 Subject: isdn: whitespace coding style cleanup isdn source code uses a not-current coding style. Update the coding style used on a per-line basis so that git diff -w shows only elided blank lines at EOF. Done with emacs and some scripts and some typing. Built x86 allyesconfig. No detected change in objdump -d or size. Signed-off-by: Joe Perches --- drivers/isdn/pcbit/callbacks.c | 303 +++++++++++---------- drivers/isdn/pcbit/callbacks.h | 28 +- drivers/isdn/pcbit/capi.c | 585 ++++++++++++++++++++--------------------- drivers/isdn/pcbit/capi.h | 46 ++-- drivers/isdn/pcbit/drv.c | 248 ++++++++--------- drivers/isdn/pcbit/edss1.c | 414 +++++++++++++++-------------- drivers/isdn/pcbit/edss1.h | 13 +- drivers/isdn/pcbit/layer2.c | 36 +-- drivers/isdn/pcbit/layer2.h | 265 +++++++++---------- drivers/isdn/pcbit/module.c | 35 ++- drivers/isdn/pcbit/pcbit.h | 32 +-- 11 files changed, 987 insertions(+), 1018 deletions(-) (limited to 'drivers/isdn/pcbit') diff --git a/drivers/isdn/pcbit/callbacks.c b/drivers/isdn/pcbit/callbacks.c index 976143b2346..efb6d6a3639 100644 --- a/drivers/isdn/pcbit/callbacks.c +++ b/drivers/isdn/pcbit/callbacks.c @@ -2,16 +2,16 @@ * Callbacks for the FSM * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ /* * Fix: 19981230 - Carlos Morgado - * Port of Nelson Escravana's fix to CalledPN + * Port of Nelson Escravana's fix to CalledPN * NULL pointer dereference in cb_in_1 (originally fixed in 2.0) */ @@ -39,86 +39,86 @@ ushort last_ref_num = 1; * */ -void cb_out_1(struct pcbit_dev * dev, struct pcbit_chan* chan, - struct callb_data *cbdata) +void cb_out_1(struct pcbit_dev *dev, struct pcbit_chan *chan, + struct callb_data *cbdata) { struct sk_buff *skb; int len; - ushort refnum; + ushort refnum; #ifdef DEBUG - printk(KERN_DEBUG "Called Party Number: %s\n", - cbdata->data.setup.CalledPN); + printk(KERN_DEBUG "Called Party Number: %s\n", + cbdata->data.setup.CalledPN); #endif - /* - * hdr - kmalloc in capi_conn_req - * - kfree when msg has been sent - */ + /* + * hdr - kmalloc in capi_conn_req + * - kfree when msg has been sent + */ - if ((len = capi_conn_req(cbdata->data.setup.CalledPN, &skb, + if ((len = capi_conn_req(cbdata->data.setup.CalledPN, &skb, chan->proto)) < 0) - { - printk("capi_conn_req failed\n"); - return; - } + { + printk("capi_conn_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; + refnum = last_ref_num++ & 0x7fffU; - chan->callref = 0; - chan->layer2link = 0; - chan->snum = 0; - chan->s_refnum = refnum; + chan->callref = 0; + chan->layer2link = 0; + chan->snum = 0; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_CONN_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_CONN_REQ, refnum, skb, len); } /* * rcv CONNECT * will go into ACTIVE state * send CONN_ACTIVE_RESP - * send Select protocol request + * send Select protocol request */ -void cb_out_2(struct pcbit_dev * dev, struct pcbit_chan* chan, - struct callb_data *data) +void cb_out_2(struct pcbit_dev *dev, struct pcbit_chan *chan, + struct callb_data *data) { - isdn_ctrl ictl; - struct sk_buff *skb; + isdn_ctrl ictl; + struct sk_buff *skb; int len; - ushort refnum; + ushort refnum; - if ((len=capi_conn_active_resp(chan, &skb)) < 0) - { - printk("capi_conn_active_req failed\n"); - return; - } + if ((len = capi_conn_active_resp(chan, &skb)) < 0) + { + printk("capi_conn_active_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_CONN_ACTV_RESP, refnum, skb, len); + pcbit_l2_write(dev, MSG_CONN_ACTV_RESP, refnum, skb, len); - ictl.command = ISDN_STAT_DCONN; - ictl.driver=dev->id; - ictl.arg=chan->id; - dev->dev_if->statcallb(&ictl); + ictl.command = ISDN_STAT_DCONN; + ictl.driver = dev->id; + ictl.arg = chan->id; + dev->dev_if->statcallb(&ictl); - /* ACTIVE D-channel */ + /* ACTIVE D-channel */ - /* Select protocol */ + /* Select protocol */ - if ((len=capi_select_proto_req(chan, &skb, 1 /*outgoing*/)) < 0) { - printk("capi_select_proto_req failed\n"); - return; - } + if ((len = capi_select_proto_req(chan, &skb, 1 /*outgoing*/)) < 0) { + printk("capi_select_proto_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len); } @@ -127,22 +127,22 @@ void cb_out_2(struct pcbit_dev * dev, struct pcbit_chan* chan, * inform user */ -void cb_in_1(struct pcbit_dev * dev, struct pcbit_chan* chan, - struct callb_data *cbdata) +void cb_in_1(struct pcbit_dev *dev, struct pcbit_chan *chan, + struct callb_data *cbdata) { - isdn_ctrl ictl; - unsigned short refnum; - struct sk_buff *skb; + isdn_ctrl ictl; + unsigned short refnum; + struct sk_buff *skb; int len; - ictl.command = ISDN_STAT_ICALL; - ictl.driver=dev->id; - ictl.arg=chan->id; - - /* - * ictl.num >= strlen() + strlen() + 5 - */ + ictl.command = ISDN_STAT_ICALL; + ictl.driver = dev->id; + ictl.arg = chan->id; + + /* + * ictl.num >= strlen() + strlen() + 5 + */ if (cbdata->data.setup.CallingPN == NULL) { printk(KERN_DEBUG "NULL CallingPN to phone; using 0\n"); @@ -167,18 +167,18 @@ void cb_in_1(struct pcbit_dev * dev, struct pcbit_chan* chan, printk(KERN_DEBUG "statstr: %s\n", ictl.num); #endif - dev->dev_if->statcallb(&ictl); + dev->dev_if->statcallb(&ictl); + - - if ((len=capi_conn_resp(chan, &skb)) < 0) { - printk(KERN_DEBUG "capi_conn_resp failed\n"); - return; + if ((len = capi_conn_resp(chan, &skb)) < 0) { + printk(KERN_DEBUG "capi_conn_resp failed\n"); + return; } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_CONN_RESP, refnum, skb, len); + pcbit_l2_write(dev, MSG_CONN_RESP, refnum, skb, len); } /* @@ -187,24 +187,24 @@ void cb_in_1(struct pcbit_dev * dev, struct pcbit_chan* chan, * send CONNECT message CONNECT_ACTIVE_REQ in CAPI */ -void cb_in_2(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_in_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { - unsigned short refnum; + unsigned short refnum; struct sk_buff *skb; - int len; - - if ((len = capi_conn_active_req(chan, &skb)) < 0) { - printk(KERN_DEBUG "capi_conn_active_req failed\n"); - return; - } + int len; + + if ((len = capi_conn_active_req(chan, &skb)) < 0) { + printk(KERN_DEBUG "capi_conn_active_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; printk(KERN_DEBUG "sending MSG_CONN_ACTV_REQ\n"); - pcbit_l2_write(dev, MSG_CONN_ACTV_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_CONN_ACTV_REQ, refnum, skb, len); } /* @@ -213,23 +213,23 @@ void cb_in_2(struct pcbit_dev * dev, struct pcbit_chan* chan, * */ -void cb_in_3(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_in_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { - unsigned short refnum; - struct sk_buff *skb; + unsigned short refnum; + struct sk_buff *skb; int len; - - if ((len = capi_select_proto_req(chan, &skb, 0 /*incoming*/)) < 0) - { - printk("capi_select_proto_req failed\n"); - return; - } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + if ((len = capi_select_proto_req(chan, &skb, 0 /*incoming*/)) < 0) + { + printk("capi_select_proto_req failed\n"); + return; + } + + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len); } @@ -239,52 +239,52 @@ void cb_in_3(struct pcbit_dev * dev, struct pcbit_chan* chan, * send disconnect resp * send msg to user */ -void cb_disc_1(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_disc_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { - struct sk_buff *skb; + struct sk_buff *skb; int len; - ushort refnum; - isdn_ctrl ictl; - - if ((len = capi_disc_resp(chan, &skb)) < 0) { - printk("capi_disc_resp failed\n"); - return; - } - - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; - - pcbit_l2_write(dev, MSG_DISC_RESP, refnum, skb, len); - - ictl.command = ISDN_STAT_BHUP; - ictl.driver=dev->id; - ictl.arg=chan->id; - dev->dev_if->statcallb(&ictl); + ushort refnum; + isdn_ctrl ictl; + + if ((len = capi_disc_resp(chan, &skb)) < 0) { + printk("capi_disc_resp failed\n"); + return; + } + + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; + + pcbit_l2_write(dev, MSG_DISC_RESP, refnum, skb, len); + + ictl.command = ISDN_STAT_BHUP; + ictl.driver = dev->id; + ictl.arg = chan->id; + dev->dev_if->statcallb(&ictl); } - + /* * User HANGUP on active/call proceeding state * send disc.req */ -void cb_disc_2(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_disc_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { - struct sk_buff *skb; + struct sk_buff *skb; int len; - ushort refnum; + ushort refnum; - if ((len = capi_disc_req(chan->callref, &skb, CAUSE_NORMAL)) < 0) - { - printk("capi_disc_req failed\n"); - return; - } + if ((len = capi_disc_req(chan->callref, &skb, CAUSE_NORMAL)) < 0) + { + printk("capi_disc_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_DISC_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_DISC_REQ, refnum, skb, len); } /* @@ -292,18 +292,18 @@ void cb_disc_2(struct pcbit_dev * dev, struct pcbit_chan* chan, * Problem: when the HL driver sends the disc req itself * LL receives BHUP */ -void cb_disc_3(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_disc_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { - isdn_ctrl ictl; + isdn_ctrl ictl; - ictl.command = ISDN_STAT_BHUP; - ictl.driver=dev->id; - ictl.arg=chan->id; - dev->dev_if->statcallb(&ictl); + ictl.command = ISDN_STAT_BHUP; + ictl.driver = dev->id; + ictl.arg = chan->id; + dev->dev_if->statcallb(&ictl); } -void cb_notdone(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_notdone(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { } @@ -311,38 +311,35 @@ void cb_notdone(struct pcbit_dev * dev, struct pcbit_chan* chan, /* * send activate b-chan protocol */ -void cb_selp_1(struct pcbit_dev * dev, struct pcbit_chan* chan, - struct callb_data *data) +void cb_selp_1(struct pcbit_dev *dev, struct pcbit_chan *chan, + struct callb_data *data) { - struct sk_buff *skb; + struct sk_buff *skb; int len; - ushort refnum; + ushort refnum; - if ((len = capi_activate_transp_req(chan, &skb)) < 0) - { - printk("capi_conn_activate_transp_req failed\n"); - return; - } + if ((len = capi_activate_transp_req(chan, &skb)) < 0) + { + printk("capi_conn_activate_transp_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_ACT_TRANSP_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_ACT_TRANSP_REQ, refnum, skb, len); } /* * Inform User that the B-channel is available */ -void cb_open(struct pcbit_dev * dev, struct pcbit_chan* chan, - struct callb_data *data) +void cb_open(struct pcbit_dev *dev, struct pcbit_chan *chan, + struct callb_data *data) { - isdn_ctrl ictl; + isdn_ctrl ictl; - ictl.command = ISDN_STAT_BCONN; - ictl.driver=dev->id; - ictl.arg=chan->id; - dev->dev_if->statcallb(&ictl); + ictl.command = ISDN_STAT_BCONN; + ictl.driver = dev->id; + ictl.arg = chan->id; + dev->dev_if->statcallb(&ictl); } - - - diff --git a/drivers/isdn/pcbit/callbacks.h b/drivers/isdn/pcbit/callbacks.h index 17aa0f54bfc..a036b4a7ffa 100644 --- a/drivers/isdn/pcbit/callbacks.h +++ b/drivers/isdn/pcbit/callbacks.h @@ -2,10 +2,10 @@ * Callbacks prototypes for FSM * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -13,34 +13,32 @@ #define CALLBACKS_H -extern void cb_out_1(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_out_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_out_2(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_out_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_in_1(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_in_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_in_2(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_in_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_in_3(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_in_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_disc_1(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_disc_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_disc_2(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_disc_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_disc_3(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_disc_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_notdone(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_notdone(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_selp_1(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_selp_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_open(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_open(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); #endif - - diff --git a/drivers/isdn/pcbit/capi.c b/drivers/isdn/pcbit/capi.c index ac5a91ccde8..4e3cbf857d6 100644 --- a/drivers/isdn/pcbit/capi.c +++ b/drivers/isdn/pcbit/capi.c @@ -3,10 +3,10 @@ * Portugal Telecom CAPI 2.0 * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. * * Not compatible with the AVM Gmbh. CAPI 2.0 @@ -51,39 +51,39 @@ * */ -int capi_conn_req(const char * calledPN, struct sk_buff **skb, int proto) +int capi_conn_req(const char *calledPN, struct sk_buff **skb, int proto) { - ushort len; - - /* - * length - * AppInfoMask - 2 - * BC0 - 3 - * BC1 - 1 - * Chan - 2 - * Keypad - 1 - * CPN - 1 - * CPSA - 1 - * CalledPN - 2 + strlen - * CalledPSA - 1 - * rest... - 4 - * ---------------- - * Total 18 + strlen - */ - - len = 18 + strlen(calledPN); + ushort len; + + /* + * length + * AppInfoMask - 2 + * BC0 - 3 + * BC1 - 1 + * Chan - 2 + * Keypad - 1 + * CPN - 1 + * CPSA - 1 + * CalledPN - 2 + strlen + * CalledPSA - 1 + * rest... - 4 + * ---------------- + * Total 18 + strlen + */ + + len = 18 + strlen(calledPN); if (proto == ISDN_PROTO_L2_TRANS) len++; if ((*skb = dev_alloc_skb(len)) == NULL) { - - printk(KERN_WARNING "capi_conn_req: alloc_skb failed\n"); + + printk(KERN_WARNING "capi_conn_req: alloc_skb failed\n"); return -1; } - /* InfoElmMask */ - *((ushort*) skb_put(*skb, 2)) = AppInfoMask; + /* InfoElmMask */ + *((ushort *)skb_put(*skb, 2)) = AppInfoMask; if (proto == ISDN_PROTO_L2_TRANS) { @@ -101,162 +101,162 @@ int capi_conn_req(const char * calledPN, struct sk_buff **skb, int proto) *(skb_put(*skb, 1)) = 0x90; /* BC0.Octect4 */ } - /* Bearer Capability - Optional*/ - *(skb_put(*skb, 1)) = 0; /* BC1.Length = 0 */ + /* Bearer Capability - Optional*/ + *(skb_put(*skb, 1)) = 0; /* BC1.Length = 0 */ - *(skb_put(*skb, 1)) = 1; /* ChannelID.Length = 1 */ - *(skb_put(*skb, 1)) = 0x83; /* Basic Interface - Any Channel */ + *(skb_put(*skb, 1)) = 1; /* ChannelID.Length = 1 */ + *(skb_put(*skb, 1)) = 0x83; /* Basic Interface - Any Channel */ - *(skb_put(*skb, 1)) = 0; /* Keypad.Length = 0 */ - + *(skb_put(*skb, 1)) = 0; /* Keypad.Length = 0 */ - *(skb_put(*skb, 1)) = 0; /* CallingPN.Length = 0 */ - *(skb_put(*skb, 1)) = 0; /* CallingPSA.Length = 0 */ - /* Called Party Number */ - *(skb_put(*skb, 1)) = strlen(calledPN) + 1; - *(skb_put(*skb, 1)) = 0x81; - memcpy(skb_put(*skb, strlen(calledPN)), calledPN, strlen(calledPN)); + *(skb_put(*skb, 1)) = 0; /* CallingPN.Length = 0 */ + *(skb_put(*skb, 1)) = 0; /* CallingPSA.Length = 0 */ - /* '#' */ + /* Called Party Number */ + *(skb_put(*skb, 1)) = strlen(calledPN) + 1; + *(skb_put(*skb, 1)) = 0x81; + memcpy(skb_put(*skb, strlen(calledPN)), calledPN, strlen(calledPN)); - *(skb_put(*skb, 1)) = 0; /* CalledPSA.Length = 0 */ + /* '#' */ - /* LLC.Length = 0; */ - /* HLC0.Length = 0; */ - /* HLC1.Length = 0; */ - /* UTUS.Length = 0; */ - memset(skb_put(*skb, 4), 0, 4); + *(skb_put(*skb, 1)) = 0; /* CalledPSA.Length = 0 */ - return len; + /* LLC.Length = 0; */ + /* HLC0.Length = 0; */ + /* HLC1.Length = 0; */ + /* UTUS.Length = 0; */ + memset(skb_put(*skb, 4), 0, 4); + + return len; } -int capi_conn_resp(struct pcbit_chan* chan, struct sk_buff **skb) +int capi_conn_resp(struct pcbit_chan *chan, struct sk_buff **skb) { - + if ((*skb = dev_alloc_skb(5)) == NULL) { - + printk(KERN_WARNING "capi_conn_resp: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; - *(skb_put(*skb, 1)) = 0x01; /* ACCEPT_CALL */ - *(skb_put(*skb, 1)) = 0; - *(skb_put(*skb, 1)) = 0; + *((ushort *)skb_put(*skb, 2)) = chan->callref; + *(skb_put(*skb, 1)) = 0x01; /* ACCEPT_CALL */ + *(skb_put(*skb, 1)) = 0; + *(skb_put(*skb, 1)) = 0; - return 5; + return 5; } -int capi_conn_active_req(struct pcbit_chan* chan, struct sk_buff **skb) +int capi_conn_active_req(struct pcbit_chan *chan, struct sk_buff **skb) { - /* - * 8 bytes - */ - + /* + * 8 bytes + */ + if ((*skb = dev_alloc_skb(8)) == NULL) { - + printk(KERN_WARNING "capi_conn_active_req: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; #ifdef DEBUG - printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref); + printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref); #endif - *(skb_put(*skb, 1)) = 0; /* BC.Length = 0; */ - *(skb_put(*skb, 1)) = 0; /* ConnectedPN.Length = 0 */ - *(skb_put(*skb, 1)) = 0; /* PSA.Length */ - *(skb_put(*skb, 1)) = 0; /* LLC.Length = 0; */ - *(skb_put(*skb, 1)) = 0; /* HLC.Length = 0; */ - *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */ + *(skb_put(*skb, 1)) = 0; /* BC.Length = 0; */ + *(skb_put(*skb, 1)) = 0; /* ConnectedPN.Length = 0 */ + *(skb_put(*skb, 1)) = 0; /* PSA.Length */ + *(skb_put(*skb, 1)) = 0; /* LLC.Length = 0; */ + *(skb_put(*skb, 1)) = 0; /* HLC.Length = 0; */ + *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */ return 8; } -int capi_conn_active_resp(struct pcbit_chan* chan, struct sk_buff **skb) +int capi_conn_active_resp(struct pcbit_chan *chan, struct sk_buff **skb) { - /* - * 2 bytes - */ - + /* + * 2 bytes + */ + if ((*skb = dev_alloc_skb(2)) == NULL) { - + printk(KERN_WARNING "capi_conn_active_resp: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; - return 2; + return 2; } -int capi_select_proto_req(struct pcbit_chan *chan, struct sk_buff **skb, - int outgoing) +int capi_select_proto_req(struct pcbit_chan *chan, struct sk_buff **skb, + int outgoing) { - /* - * 18 bytes - */ + /* + * 18 bytes + */ if ((*skb = dev_alloc_skb(18)) == NULL) { - + printk(KERN_WARNING "capi_select_proto_req: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; - /* Layer2 protocol */ + /* Layer2 protocol */ - switch (chan->proto) { - case ISDN_PROTO_L2_X75I: - *(skb_put(*skb, 1)) = 0x05; /* LAPB */ - break; - case ISDN_PROTO_L2_HDLC: - *(skb_put(*skb, 1)) = 0x02; - break; + switch (chan->proto) { + case ISDN_PROTO_L2_X75I: + *(skb_put(*skb, 1)) = 0x05; /* LAPB */ + break; + case ISDN_PROTO_L2_HDLC: + *(skb_put(*skb, 1)) = 0x02; + break; case ISDN_PROTO_L2_TRANS: - /* + /* * Voice (a-law) */ *(skb_put(*skb, 1)) = 0x06; break; - default: -#ifdef DEBUG - printk(KERN_DEBUG "Transparent\n"); + default: +#ifdef DEBUG + printk(KERN_DEBUG "Transparent\n"); #endif - *(skb_put(*skb, 1)) = 0x03; - break; - } - - *(skb_put(*skb, 1)) = (outgoing ? 0x02 : 0x42); /* Don't ask */ - *(skb_put(*skb, 1)) = 0x00; - - *((ushort *) skb_put(*skb, 2)) = MRU; - - - *(skb_put(*skb, 1)) = 0x08; /* Modulo */ - *(skb_put(*skb, 1)) = 0x07; /* Max Window */ - - *(skb_put(*skb, 1)) = 0x01; /* No Layer3 Protocol */ - - /* - * 2 - layer3 MTU [10] - * - Modulo [12] - * - Window - * - layer1 proto [14] - * - bitrate - * - sub-channel [16] - * - layer1dataformat [17] - */ - - memset(skb_put(*skb, 8), 0, 8); - - return 18; + *(skb_put(*skb, 1)) = 0x03; + break; + } + + *(skb_put(*skb, 1)) = (outgoing ? 0x02 : 0x42); /* Don't ask */ + *(skb_put(*skb, 1)) = 0x00; + + *((ushort *) skb_put(*skb, 2)) = MRU; + + + *(skb_put(*skb, 1)) = 0x08; /* Modulo */ + *(skb_put(*skb, 1)) = 0x07; /* Max Window */ + + *(skb_put(*skb, 1)) = 0x01; /* No Layer3 Protocol */ + + /* + * 2 - layer3 MTU [10] + * - Modulo [12] + * - Window + * - layer1 proto [14] + * - bitrate + * - sub-channel [16] + * - layer1dataformat [17] + */ + + memset(skb_put(*skb, 8), 0, 8); + + return 18; } @@ -264,45 +264,45 @@ int capi_activate_transp_req(struct pcbit_chan *chan, struct sk_buff **skb) { if ((*skb = dev_alloc_skb(7)) == NULL) { - + printk(KERN_WARNING "capi_activate_transp_req: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; - - *(skb_put(*skb, 1)) = chan->layer2link; /* Layer2 id */ - *(skb_put(*skb, 1)) = 0x00; /* Transmit by default */ - *((ushort *) skb_put(*skb, 2)) = MRU; + *(skb_put(*skb, 1)) = chan->layer2link; /* Layer2 id */ + *(skb_put(*skb, 1)) = 0x00; /* Transmit by default */ - *(skb_put(*skb, 1)) = 0x01; /* Enables reception*/ + *((ushort *) skb_put(*skb, 2)) = MRU; - return 7; + *(skb_put(*skb, 1)) = 0x01; /* Enables reception*/ + + return 7; } -int capi_tdata_req(struct pcbit_chan* chan, struct sk_buff *skb) +int capi_tdata_req(struct pcbit_chan *chan, struct sk_buff *skb) { ushort data_len; - - /* - * callref - 2 + + /* + * callref - 2 * layer2link - 1 - * wBlockLength - 2 + * wBlockLength - 2 * data - 4 * sernum - 1 */ - + data_len = skb->len; - if(skb_headroom(skb) < 10) + if (skb_headroom(skb) < 10) { printk(KERN_CRIT "No headspace (%u) on headroom %p for capi header\n", skb_headroom(skb), skb); } else - { + { skb_push(skb, 10); } @@ -318,58 +318,58 @@ int capi_tdata_req(struct pcbit_chan* chan, struct sk_buff *skb) return 10; } -int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff ** skb) - +int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff **skb) + { if ((*skb = dev_alloc_skb(4)) == NULL) { - + printk(KERN_WARNING "capi_tdata_resp: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; - *(skb_put(*skb, 1)) = chan->layer2link; - *(skb_put(*skb, 1)) = chan->r_refnum; + *(skb_put(*skb, 1)) = chan->layer2link; + *(skb_put(*skb, 1)) = chan->r_refnum; - return (*skb)->len; + return (*skb)->len; } int capi_disc_req(ushort callref, struct sk_buff **skb, u_char cause) { if ((*skb = dev_alloc_skb(6)) == NULL) { - + printk(KERN_WARNING "capi_disc_req: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = callref; + *((ushort *)skb_put(*skb, 2)) = callref; - *(skb_put(*skb, 1)) = 2; /* Cause.Length = 2; */ - *(skb_put(*skb, 1)) = 0x80; - *(skb_put(*skb, 1)) = 0x80 | cause; + *(skb_put(*skb, 1)) = 2; /* Cause.Length = 2; */ + *(skb_put(*skb, 1)) = 0x80; + *(skb_put(*skb, 1)) = 0x80 | cause; - /* - * Change it: we should send 'Sic transit gloria Mundi' here ;-) - */ + /* + * Change it: we should send 'Sic transit gloria Mundi' here ;-) + */ - *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */ + *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */ - return 6; + return 6; } int capi_disc_resp(struct pcbit_chan *chan, struct sk_buff **skb) { if ((*skb = dev_alloc_skb(2)) == NULL) { - + printk(KERN_WARNING "capi_disc_resp: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2)) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; - return 2; + return 2; } @@ -378,57 +378,57 @@ int capi_disc_resp(struct pcbit_chan *chan, struct sk_buff **skb) * */ -int capi_decode_conn_ind(struct pcbit_chan * chan, - struct sk_buff *skb, - struct callb_data *info) +int capi_decode_conn_ind(struct pcbit_chan *chan, + struct sk_buff *skb, + struct callb_data *info) { - int CIlen, len; + int CIlen, len; - /* Call Reference [CAPI] */ - chan->callref = *((ushort*) skb->data); - skb_pull(skb, 2); + /* Call Reference [CAPI] */ + chan->callref = *((ushort *)skb->data); + skb_pull(skb, 2); #ifdef DEBUG - printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref); + printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref); #endif - /* Channel Identification */ + /* Channel Identification */ - /* Expect - Len = 1 - Octect 3 = 0100 10CC - [ 7 Basic, 4 , 2-1 chan ] - */ + /* Expect + Len = 1 + Octect 3 = 0100 10CC - [ 7 Basic, 4 , 2-1 chan ] + */ - CIlen = skb->data[0]; + CIlen = skb->data[0]; #ifdef DEBUG - if (CIlen == 1) { + if (CIlen == 1) { - if ( ((skb->data[1]) & 0xFC) == 0x48 ) - printk(KERN_DEBUG "decode_conn_ind: chan ok\n"); - printk(KERN_DEBUG "phyChan = %d\n", skb->data[1] & 0x03); - } + if (((skb->data[1]) & 0xFC) == 0x48) + printk(KERN_DEBUG "decode_conn_ind: chan ok\n"); + printk(KERN_DEBUG "phyChan = %d\n", skb->data[1] & 0x03); + } else printk(KERN_DEBUG "conn_ind: CIlen = %d\n", CIlen); #endif - skb_pull(skb, CIlen + 1); + skb_pull(skb, CIlen + 1); - /* Calling Party Number */ - /* An "additional service" as far as Portugal Telecom is concerned */ + /* Calling Party Number */ + /* An "additional service" as far as Portugal Telecom is concerned */ - len = skb->data[0]; + len = skb->data[0]; if (len > 0) { int count = 1; - + #ifdef DEBUG printk(KERN_DEBUG "CPN: Octect 3 %02x\n", skb->data[1]); #endif if ((skb->data[1] & 0x80) == 0) count = 2; - + if (!(info->data.setup.CallingPN = kmalloc(len - count + 1, GFP_ATOMIC))) return -1; - + skb_copy_from_linear_data_offset(skb, count + 1, info->data.setup.CallingPN, len - count); @@ -442,22 +442,22 @@ int capi_decode_conn_ind(struct pcbit_chan * chan, skb_pull(skb, len + 1); - /* Calling Party Subaddress */ - skb_pull(skb, skb->data[0] + 1); + /* Calling Party Subaddress */ + skb_pull(skb, skb->data[0] + 1); - /* Called Party Number */ + /* Called Party Number */ - len = skb->data[0]; + len = skb->data[0]; if (len > 0) { int count = 1; - + if ((skb->data[1] & 0x80) == 0) count = 2; - + if (!(info->data.setup.CalledPN = kmalloc(len - count + 1, GFP_ATOMIC))) return -1; - + skb_copy_from_linear_data_offset(skb, count + 1, info->data.setup.CalledPN, len - count); @@ -471,73 +471,73 @@ int capi_decode_conn_ind(struct pcbit_chan * chan, skb_pull(skb, len + 1); - /* Called Party Subaddress */ - skb_pull(skb, skb->data[0] + 1); + /* Called Party Subaddress */ + skb_pull(skb, skb->data[0] + 1); - /* LLC */ - skb_pull(skb, skb->data[0] + 1); + /* LLC */ + skb_pull(skb, skb->data[0] + 1); - /* HLC */ - skb_pull(skb, skb->data[0] + 1); + /* HLC */ + skb_pull(skb, skb->data[0] + 1); - /* U2U */ - skb_pull(skb, skb->data[0] + 1); + /* U2U */ + skb_pull(skb, skb->data[0] + 1); - return 0; + return 0; } /* * returns errcode */ -int capi_decode_conn_conf(struct pcbit_chan * chan, struct sk_buff *skb, - int *complete) +int capi_decode_conn_conf(struct pcbit_chan *chan, struct sk_buff *skb, + int *complete) { - int errcode; - - chan->callref = *((ushort *) skb->data); /* Update CallReference */ - skb_pull(skb, 2); + int errcode; + + chan->callref = *((ushort *)skb->data); /* Update CallReference */ + skb_pull(skb, 2); + + errcode = *((ushort *) skb->data); /* read errcode */ + skb_pull(skb, 2); - errcode = *((ushort *) skb->data); /* read errcode */ - skb_pull(skb, 2); + *complete = *(skb->data); + skb_pull(skb, 1); - *complete = *(skb->data); - skb_pull(skb, 1); + /* FIX ME */ + /* This is actually a firmware bug */ + if (!*complete) + { + printk(KERN_DEBUG "complete=%02x\n", *complete); + *complete = 1; + } - /* FIX ME */ - /* This is actually a firmware bug */ - if (!*complete) - { - printk(KERN_DEBUG "complete=%02x\n", *complete); - *complete = 1; - } + /* Optional Bearer Capability */ + skb_pull(skb, *(skb->data) + 1); - /* Optional Bearer Capability */ - skb_pull(skb, *(skb->data) + 1); - - /* Channel Identification */ - skb_pull(skb, *(skb->data) + 1); + /* Channel Identification */ + skb_pull(skb, *(skb->data) + 1); - /* High Layer Compatibility follows */ - skb_pull(skb, *(skb->data) + 1); + /* High Layer Compatibility follows */ + skb_pull(skb, *(skb->data) + 1); - return errcode; + return errcode; } -int capi_decode_conn_actv_ind(struct pcbit_chan * chan, struct sk_buff *skb) +int capi_decode_conn_actv_ind(struct pcbit_chan *chan, struct sk_buff *skb) { - ushort len; + ushort len; #ifdef DEBUG - char str[32]; + char str[32]; #endif - /* Yet Another Bearer Capability */ - skb_pull(skb, *(skb->data) + 1); - + /* Yet Another Bearer Capability */ + skb_pull(skb, *(skb->data) + 1); - /* Connected Party Number */ - len=*(skb->data); + + /* Connected Party Number */ + len = *(skb->data); #ifdef DEBUG if (len > 1 && len < 31) { @@ -549,106 +549,101 @@ int capi_decode_conn_actv_ind(struct pcbit_chan * chan, struct sk_buff *skb) printk(KERN_DEBUG "actv_ind CPN len = %d\n", len); #endif - skb_pull(skb, len + 1); + skb_pull(skb, len + 1); - /* Connected Subaddress */ - skb_pull(skb, *(skb->data) + 1); + /* Connected Subaddress */ + skb_pull(skb, *(skb->data) + 1); - /* Low Layer Capability */ - skb_pull(skb, *(skb->data) + 1); + /* Low Layer Capability */ + skb_pull(skb, *(skb->data) + 1); - /* High Layer Capability */ - skb_pull(skb, *(skb->data) + 1); + /* High Layer Capability */ + skb_pull(skb, *(skb->data) + 1); - return 0; + return 0; } -int capi_decode_conn_actv_conf(struct pcbit_chan * chan, struct sk_buff *skb) +int capi_decode_conn_actv_conf(struct pcbit_chan *chan, struct sk_buff *skb) { - ushort errcode; - - errcode = *((ushort*) skb->data); - skb_pull(skb, 2); - - /* Channel Identification - skb_pull(skb, skb->data[0] + 1); - */ - return errcode; + ushort errcode; + + errcode = *((ushort *)skb->data); + skb_pull(skb, 2); + + /* Channel Identification + skb_pull(skb, skb->data[0] + 1); + */ + return errcode; } int capi_decode_sel_proto_conf(struct pcbit_chan *chan, struct sk_buff *skb) { - ushort errcode; - - chan->layer2link = *(skb->data); - skb_pull(skb, 1); + ushort errcode; - errcode = *((ushort*) skb->data); - skb_pull(skb, 2); + chan->layer2link = *(skb->data); + skb_pull(skb, 1); - return errcode; + errcode = *((ushort *)skb->data); + skb_pull(skb, 2); + + return errcode; } int capi_decode_actv_trans_conf(struct pcbit_chan *chan, struct sk_buff *skb) { - ushort errcode; + ushort errcode; - if (chan->layer2link != *(skb->data) ) - printk("capi_decode_actv_trans_conf: layer2link doesn't match\n"); + if (chan->layer2link != *(skb->data)) + printk("capi_decode_actv_trans_conf: layer2link doesn't match\n"); - skb_pull(skb, 1); + skb_pull(skb, 1); - errcode = *((ushort*) skb->data); - skb_pull(skb, 2); + errcode = *((ushort *)skb->data); + skb_pull(skb, 2); - return errcode; + return errcode; } int capi_decode_disc_ind(struct pcbit_chan *chan, struct sk_buff *skb) { - ushort len; + ushort len; #ifdef DEBUG - int i; + int i; #endif - /* Cause */ - - len = *(skb->data); - skb_pull(skb, 1); + /* Cause */ + + len = *(skb->data); + skb_pull(skb, 1); #ifdef DEBUG - for (i=0; idata + i)); + for (i = 0; i < len; i++) + printk(KERN_DEBUG "Cause Octect %d: %02x\n", i + 3, + *(skb->data + i)); #endif - skb_pull(skb, len); + skb_pull(skb, len); - return 0; + return 0; } #ifdef DEBUG int capi_decode_debug_188(u_char *hdr, ushort hdrlen) { - char str[64]; - int len; - - len = hdr[0]; - - if (len < 64 && len == hdrlen - 1) { - memcpy(str, hdr + 1, hdrlen - 1); - str[hdrlen - 1] = 0; - printk("%s\n", str); - } - else - printk("debug message incorrect\n"); - - return 0; -} -#endif - - + char str[64]; + int len; + len = hdr[0]; + if (len < 64 && len == hdrlen - 1) { + memcpy(str, hdr + 1, hdrlen - 1); + str[hdrlen - 1] = 0; + printk("%s\n", str); + } + else + printk("debug message incorrect\n"); + return 0; +} +#endif diff --git a/drivers/isdn/pcbit/capi.h b/drivers/isdn/pcbit/capi.h index df8e73c04d7..635f6347694 100644 --- a/drivers/isdn/pcbit/capi.h +++ b/drivers/isdn/pcbit/capi.h @@ -2,10 +2,10 @@ * CAPI encode/decode prototypes and defines * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -15,42 +15,42 @@ #define REQ_CAUSE 0x01 #define REQ_DISPLAY 0x04 -#define REQ_USER_TO_USER 0x08 +#define REQ_USER_TO_USER 0x08 -#define AppInfoMask REQ_CAUSE|REQ_DISPLAY|REQ_USER_TO_USER +#define AppInfoMask REQ_CAUSE | REQ_DISPLAY | REQ_USER_TO_USER /* Connection Setup */ -extern int capi_conn_req(const char * calledPN, struct sk_buff **buf, +extern int capi_conn_req(const char *calledPN, struct sk_buff **buf, int proto); -extern int capi_decode_conn_conf(struct pcbit_chan * chan, struct sk_buff *skb, - int *complete); +extern int capi_decode_conn_conf(struct pcbit_chan *chan, struct sk_buff *skb, + int *complete); -extern int capi_decode_conn_ind(struct pcbit_chan * chan, struct sk_buff *skb, +extern int capi_decode_conn_ind(struct pcbit_chan *chan, struct sk_buff *skb, struct callb_data *info); -extern int capi_conn_resp(struct pcbit_chan* chan, struct sk_buff **skb); +extern int capi_conn_resp(struct pcbit_chan *chan, struct sk_buff **skb); -extern int capi_conn_active_req(struct pcbit_chan* chan, struct sk_buff **skb); -extern int capi_decode_conn_actv_conf(struct pcbit_chan * chan, +extern int capi_conn_active_req(struct pcbit_chan *chan, struct sk_buff **skb); +extern int capi_decode_conn_actv_conf(struct pcbit_chan *chan, struct sk_buff *skb); -extern int capi_decode_conn_actv_ind(struct pcbit_chan * chan, +extern int capi_decode_conn_actv_ind(struct pcbit_chan *chan, struct sk_buff *skb); -extern int capi_conn_active_resp(struct pcbit_chan* chan, +extern int capi_conn_active_resp(struct pcbit_chan *chan, struct sk_buff **skb); /* Data */ extern int capi_select_proto_req(struct pcbit_chan *chan, struct sk_buff **skb, int outgoing); -extern int capi_decode_sel_proto_conf(struct pcbit_chan *chan, +extern int capi_decode_sel_proto_conf(struct pcbit_chan *chan, struct sk_buff *skb); -extern int capi_activate_transp_req(struct pcbit_chan *chan, +extern int capi_activate_transp_req(struct pcbit_chan *chan, struct sk_buff **skb); -extern int capi_decode_actv_trans_conf(struct pcbit_chan *chan, +extern int capi_decode_actv_trans_conf(struct pcbit_chan *chan, struct sk_buff *skb); -extern int capi_tdata_req(struct pcbit_chan* chan, struct sk_buff *skb); -extern int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff ** skb); +extern int capi_tdata_req(struct pcbit_chan *chan, struct sk_buff *skb); +extern int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff **skb); /* Connection Termination */ extern int capi_disc_req(ushort callref, struct sk_buff **skb, u_char cause); @@ -62,12 +62,12 @@ extern int capi_disc_resp(struct pcbit_chan *chan, struct sk_buff **skb); extern int capi_decode_debug_188(u_char *hdr, ushort hdrlen); #endif -static inline struct pcbit_chan * +static inline struct pcbit_chan * capi_channel(struct pcbit_dev *dev, struct sk_buff *skb) { ushort callref; - callref = *((ushort*) skb->data); + callref = *((ushort *)skb->data); skb_pull(skb, 2); if (dev->b1->callref == callref) @@ -79,9 +79,3 @@ capi_channel(struct pcbit_dev *dev, struct sk_buff *skb) } #endif - - - - - - diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c index 1507d2e83fb..1eaf6227390 100644 --- a/drivers/isdn/pcbit/drv.c +++ b/drivers/isdn/pcbit/drv.c @@ -2,10 +2,10 @@ * PCBIT-D interface with isdn4linux * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -14,7 +14,7 @@ * * Nuno Grilo * fixed msn_list NULL pointer dereference. - * + * */ #include @@ -43,9 +43,9 @@ extern ushort last_ref_num; -static int pcbit_ioctl(isdn_ctrl* ctl); +static int pcbit_ioctl(isdn_ctrl *ctl); -static char* pcbit_devname[MAX_PCBIT_CARDS] = { +static char *pcbit_devname[MAX_PCBIT_CARDS] = { "pcbit0", "pcbit1", "pcbit2", @@ -56,12 +56,12 @@ static char* pcbit_devname[MAX_PCBIT_CARDS] = { * prototypes */ -static int pcbit_command(isdn_ctrl* ctl); -static int pcbit_stat(u_char __user * buf, int len, int, int); +static int pcbit_command(isdn_ctrl *ctl); +static int pcbit_stat(u_char __user *buf, int len, int, int); static int pcbit_xmit(int driver, int chan, int ack, struct sk_buff *skb); static int pcbit_writecmd(const u_char __user *, int, int, int); -static int set_protocol_running(struct pcbit_dev * dev); +static int set_protocol_running(struct pcbit_dev *dev); static void pcbit_clear_msn(struct pcbit_dev *dev); static void pcbit_set_msn(struct pcbit_dev *dev, char *list); @@ -73,7 +73,7 @@ int pcbit_init_dev(int board, int mem_base, int irq) struct pcbit_dev *dev; isdn_if *dev_if; - if ((dev=kzalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL) + if ((dev = kzalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL) { printk("pcbit_init: couldn't malloc pcbit_dev struct\n"); return -ENOMEM; @@ -83,19 +83,19 @@ int pcbit_init_dev(int board, int mem_base, int irq) init_waitqueue_head(&dev->set_running_wq); spin_lock_init(&dev->lock); - if (mem_base >= 0xA0000 && mem_base <= 0xFFFFF ) { + if (mem_base >= 0xA0000 && mem_base <= 0xFFFFF) { dev->ph_mem = mem_base; if (!request_mem_region(dev->ph_mem, 4096, "PCBIT mem")) { printk(KERN_WARNING - "PCBIT: memory region %lx-%lx already in use\n", - dev->ph_mem, dev->ph_mem + 4096); + "PCBIT: memory region %lx-%lx already in use\n", + dev->ph_mem, dev->ph_mem + 4096); kfree(dev); dev_pcbit[board] = NULL; return -EACCES; } dev->sh_mem = ioremap(dev->ph_mem, 4096); } - else + else { printk("memory address invalid"); kfree(dev); @@ -111,7 +111,7 @@ int pcbit_init_dev(int board, int mem_base, int irq) kfree(dev); return -ENOMEM; } - + dev->b2 = kzalloc(sizeof(struct pcbit_chan), GFP_KERNEL); if (!dev->b2) { printk("pcbit_init: couldn't malloc pcbit_chan struct\n"); @@ -130,7 +130,7 @@ int pcbit_init_dev(int board, int mem_base, int irq) * interrupts */ - if (request_irq(irq, &pcbit_irq_handler, 0, pcbit_devname[board], dev) != 0) + if (request_irq(irq, &pcbit_irq_handler, 0, pcbit_devname[board], dev) != 0) { kfree(dev->b1); kfree(dev->b2); @@ -168,16 +168,16 @@ int pcbit_init_dev(int board, int mem_base, int irq) dev_if->owner = THIS_MODULE; dev_if->channels = 2; - - dev_if->features = (ISDN_FEATURE_P_EURO | ISDN_FEATURE_L3_TRANS | - ISDN_FEATURE_L2_HDLC | ISDN_FEATURE_L2_TRANS ); + + dev_if->features = (ISDN_FEATURE_P_EURO | ISDN_FEATURE_L3_TRANS | + ISDN_FEATURE_L2_HDLC | ISDN_FEATURE_L2_TRANS); dev_if->writebuf_skb = pcbit_xmit; dev_if->hl_hdrlen = 16; dev_if->maxbufsize = MAXBUFSIZE; dev_if->command = pcbit_command; - + dev_if->writecmd = pcbit_writecmd; dev_if->readstat = pcbit_stat; @@ -211,12 +211,12 @@ int pcbit_init_dev(int board, int mem_base, int irq) #ifdef MODULE void pcbit_terminate(int board) { - struct pcbit_dev * dev; + struct pcbit_dev *dev; dev = dev_pcbit[board]; if (dev) { - /* unregister_isdn(dev->dev_if); */ + /* unregister_isdn(dev->dev_if); */ free_irq(dev->irq, dev); pcbit_clear_msn(dev); kfree(dev->dev_if); @@ -233,9 +233,9 @@ void pcbit_terminate(int board) } #endif -static int pcbit_command(isdn_ctrl* ctl) +static int pcbit_command(isdn_ctrl *ctl) { - struct pcbit_dev *dev; + struct pcbit_dev *dev; struct pcbit_chan *chan; struct callb_data info; @@ -250,7 +250,7 @@ static int pcbit_command(isdn_ctrl* ctl) chan = (ctl->arg & 0x0F) ? dev->b2 : dev->b1; - switch(ctl->command) { + switch (ctl->command) { case ISDN_CMD_IOCTL: return pcbit_ioctl(ctl); break; @@ -299,10 +299,10 @@ static int pcbit_command(isdn_ctrl* ctl) static void pcbit_block_timer(unsigned long data) { struct pcbit_chan *chan; - struct pcbit_dev * dev; + struct pcbit_dev *dev; isdn_ctrl ictl; - chan = (struct pcbit_chan *) data; + chan = (struct pcbit_chan *)data; dev = chan2dev(chan); @@ -316,12 +316,12 @@ static void pcbit_block_timer(unsigned long data) #ifdef DEBUG printk(KERN_DEBUG "pcbit_block_timer\n"); -#endif +#endif chan->queued = 0; ictl.driver = dev->id; ictl.command = ISDN_STAT_BSENT; ictl.arg = chan->id; - dev->dev_if->statcallb(&ictl); + dev->dev_if->statcallb(&ictl); } #endif @@ -329,7 +329,7 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) { ushort hdrlen; int refnum, len; - struct pcbit_chan * chan; + struct pcbit_chan *chan; struct pcbit_dev *dev; dev = finddev(driver); @@ -345,10 +345,10 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) if (chan->fsm_state != ST_ACTIVE) return -1; - if (chan->queued >= MAX_QUEUED ) + if (chan->queued >= MAX_QUEUED) { #ifdef DEBUG_QUEUE - printk(KERN_DEBUG + printk(KERN_DEBUG "pcbit: %d packets already in queue - write fails\n", chan->queued); #endif @@ -365,14 +365,14 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) chan->block_timer.expires = jiffies + 1 * HZ; add_timer(&chan->block_timer); } -#endif - return 0; +#endif + return 0; } chan->queued++; - - len = skb->len; + + len = skb->len; hdrlen = capi_tdata_req(chan, skb); @@ -386,10 +386,10 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) static int pcbit_writecmd(const u_char __user *buf, int len, int driver, int channel) { - struct pcbit_dev * dev; + struct pcbit_dev *dev; int i, j; - const u_char * loadbuf; - u_char * ptr = NULL; + const u_char *loadbuf; + u_char *ptr = NULL; u_char *cbuf; int errstat; @@ -402,7 +402,7 @@ static int pcbit_writecmd(const u_char __user *buf, int len, int driver, int cha return -ENODEV; } - switch(dev->l2_state) { + switch (dev->l2_state) { case L2_LWMODE: /* check (size <= rdp_size); write buf into board */ if (len < 0 || len > BANK4 + 1 || len > 1024) @@ -422,19 +422,19 @@ static int pcbit_writecmd(const u_char __user *buf, int len, int driver, int cha /* this is the hard part */ /* dumb board */ /* get it into kernel space */ - if ((ptr = kmalloc(len, GFP_KERNEL))==NULL) + if ((ptr = kmalloc(len, GFP_KERNEL)) == NULL) return -ENOMEM; if (copy_from_user(ptr, buf, len)) { kfree(ptr); return -EFAULT; } loadbuf = ptr; - + errstat = 0; - for (i=0; i < len; i++) + for (i = 0; i < len; i++) { - for(j=0; j < LOAD_RETRY; j++) + for (j = 0; j < LOAD_RETRY; j++) if (!(readb(dev->sh_mem + dev->loadptr))) break; @@ -464,9 +464,9 @@ static int pcbit_writecmd(const u_char __user *buf, int len, int driver, int cha * */ -void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, - struct sk_buff * skb, - ushort hdr_len, ushort refnum) +void pcbit_l3_receive(struct pcbit_dev *dev, ulong msg, + struct sk_buff *skb, + ushort hdr_len, ushort refnum) { struct pcbit_chan *chan; struct sk_buff *skb2; @@ -475,11 +475,11 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, int complete, err; isdn_ctrl ictl; - switch(msg) { + switch (msg) { case MSG_TDATA_IND: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } @@ -488,30 +488,30 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, dev->dev_if->rcvcallb_skb(dev->id, chan->id, skb); - if (capi_tdata_resp(chan, &skb2) > 0) - pcbit_l2_write(dev, MSG_TDATA_RESP, refnum, + if (capi_tdata_resp(chan, &skb2) > 0) + pcbit_l2_write(dev, MSG_TDATA_RESP, refnum, skb2, skb2->len); return; - break; + break; case MSG_TDATA_CONF: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } #ifdef DEBUG - if ( (*((ushort *) (skb->data + 2) )) != 0) { - printk(KERN_DEBUG "TDATA_CONF error\n"); + if ((*((ushort *)(skb->data + 2))) != 0) { + printk(KERN_DEBUG "TDATA_CONF error\n"); } #endif #ifdef BLOCK_TIMER - if (chan->queued == MAX_QUEUED) { - del_timer(&chan->block_timer); + if (chan->queued == MAX_QUEUED) { + del_timer(&chan->block_timer); chan->block_timer.function = NULL; } - -#endif + +#endif chan->queued--; ictl.driver = dev->id; @@ -523,7 +523,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, case MSG_CONN_IND: /* * channel: 1st not used will do - * if both are used we're in trouble + * if both are used we're in trouble */ if (!dev->b1->fsm_state) @@ -531,12 +531,12 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, else if (!dev->b2->fsm_state) chan = dev->b2; else { - printk(KERN_INFO + printk(KERN_INFO "Incoming connection: no channels available"); - if ((len = capi_disc_req(*(ushort*)(skb->data), &skb2, CAUSE_NOCHAN)) > 0) + if ((len = capi_disc_req(*(ushort *)(skb->data), &skb2, CAUSE_NOCHAN)) > 0) pcbit_l2_write(dev, MSG_DISC_REQ, refnum, skb2, len); - break; + break; } cbdata.data.setup.CalledPN = NULL; @@ -547,7 +547,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, pcbit_fsm_event(dev, chan, EV_NET_SETUP, NULL); - if (pcbit_check_msn(dev, cbdata.data.setup.CallingPN)) + if (pcbit_check_msn(dev, cbdata.data.setup.CallingPN)) pcbit_fsm_event(dev, chan, EV_USR_PROCED_REQ, &cbdata); else pcbit_fsm_event(dev, chan, EV_USR_RELEASE_REQ, NULL); @@ -555,26 +555,26 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, kfree(cbdata.data.setup.CalledPN); kfree(cbdata.data.setup.CallingPN); break; - + case MSG_CONN_CONF: - /* + /* * We should be able to find the channel by the message * reference number. The current version of the firmware * doesn't sent the ref number correctly. */ #ifdef DEBUG - printk(KERN_DEBUG "refnum=%04x b1=%04x b2=%04x\n", refnum, - dev->b1->s_refnum, + printk(KERN_DEBUG "refnum=%04x b1=%04x b2=%04x\n", refnum, + dev->b1->s_refnum, dev->b2->s_refnum); #endif /* We just try to find a channel in the right state */ if (dev->b1->fsm_state == ST_CALL_INIT) chan = dev->b1; - else { + else { if (dev->b2->s_refnum == ST_CALL_INIT) chan = dev->b2; - else { + else { chan = NULL; printk(KERN_WARNING "Connection Confirm - no channel in Call Init state\n"); break; @@ -589,18 +589,18 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, pcbit_fsm_event(dev, chan, EV_NET_CALL_PROC, NULL); else pcbit_fsm_event(dev, chan, EV_NET_SETUP_ACK, NULL); - break; + break; case MSG_CONN_ACTV_IND: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } - + if (capi_decode_conn_actv_ind(chan, skb)) { printk("error in capi_decode_conn_actv_ind\n"); - /* pcbit_fsm_event(dev, chan, EV_ERROR, NULL); */ + /* pcbit_fsm_event(dev, chan, EV_ERROR, NULL); */ break; } chan->r_refnum = refnum; @@ -609,14 +609,14 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, case MSG_CONN_ACTV_CONF: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } if (capi_decode_conn_actv_conf(chan, skb) == 0) pcbit_fsm_event(dev, chan, EV_NET_CONN_ACK, NULL); - + else printk(KERN_DEBUG "decode_conn_actv_conf failed\n"); break; @@ -624,7 +624,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, case MSG_SELP_CONF: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } @@ -638,7 +638,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, break; case MSG_ACT_TRANSP_CONF: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } @@ -650,7 +650,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, case MSG_DISC_IND: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } @@ -662,7 +662,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, break; case MSG_DISC_CONF: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } @@ -711,24 +711,24 @@ static int pcbit_stat(u_char __user *buf, int len, int driver, int channel) stat_count = STATBUF_LEN - stat_st + stat_end; /* FIXME: should we sleep and wait for more cookies ? */ - if (len > stat_count) + if (len > stat_count) len = stat_count; if (stat_st < stat_end) { if (copy_to_user(buf, statbuf + stat_st, len)) return -EFAULT; - stat_st += len; + stat_st += len; } else { if (len > STATBUF_LEN - stat_st) { if (copy_to_user(buf, statbuf + stat_st, - STATBUF_LEN - stat_st)) + STATBUF_LEN - stat_st)) return -EFAULT; if (copy_to_user(buf, statbuf, - len - (STATBUF_LEN - stat_st))) + len - (STATBUF_LEN - stat_st))) return -EFAULT; stat_st = len - (STATBUF_LEN - stat_st); @@ -739,7 +739,7 @@ static int pcbit_stat(u_char __user *buf, int len, int driver, int channel) return -EFAULT; stat_st += len; - + if (stat_st == STATBUF_LEN) stat_st = 0; } @@ -756,27 +756,27 @@ static void pcbit_logstat(struct pcbit_dev *dev, char *str) int i; isdn_ctrl ictl; - for (i=stat_end; iid; - ictl.arg=strlen(str); + ictl.command = ISDN_STAT_STAVAIL; + ictl.driver = dev->id; + ictl.arg = strlen(str); dev->dev_if->statcallb(&ictl); } - -void pcbit_state_change(struct pcbit_dev * dev, struct pcbit_chan * chan, + +void pcbit_state_change(struct pcbit_dev *dev, struct pcbit_chan *chan, unsigned short i, unsigned short ev, unsigned short f) { char buf[256]; - + sprintf(buf, "change on device: %d channel:%d\n%s -> %s -> %s\n", - dev->id, chan->id, + dev->id, chan->id, isdn_state_table[i], strisdnevent(ev), isdn_state_table[f] ); @@ -789,7 +789,7 @@ void pcbit_state_change(struct pcbit_dev * dev, struct pcbit_chan * chan, static void set_running_timeout(unsigned long ptr) { - struct pcbit_dev * dev; + struct pcbit_dev *dev; #ifdef DEBUG printk(KERN_DEBUG "set_running_timeout\n"); @@ -799,7 +799,7 @@ static void set_running_timeout(unsigned long ptr) wake_up_interruptible(&dev->set_running_wq); } -static int set_protocol_running(struct pcbit_dev * dev) +static int set_protocol_running(struct pcbit_dev *dev) { isdn_ctrl ctl; @@ -813,7 +813,7 @@ static int set_protocol_running(struct pcbit_dev * dev) dev->l2_state = L2_STARTING; - writeb((0x80U | ((dev->rcv_seq & 0x07) << 3) | (dev->send_seq & 0x07)), + writeb((0x80U | ((dev->rcv_seq & 0x07) << 3) | (dev->send_seq & 0x07)), dev->sh_mem + BANK4); add_timer(&dev->set_running_timer); @@ -830,8 +830,8 @@ static int set_protocol_running(struct pcbit_dev * dev) dev->writeptr = dev->sh_mem; dev->readptr = dev->sh_mem + BANK2; - - /* tell the good news to the upper layer */ + + /* tell the good news to the upper layer */ ctl.driver = dev->id; ctl.command = ISDN_STAT_RUN; @@ -845,7 +845,7 @@ static int set_protocol_running(struct pcbit_dev * dev) dev->l2_state = L2_DOWN; #ifdef DEBUG - printk(KERN_DEBUG "Bank3 = %02x\n", + printk(KERN_DEBUG "Bank3 = %02x\n", readb(dev->sh_mem + BANK3)); #endif writeb(0x40, dev->sh_mem + BANK4); @@ -862,13 +862,13 @@ static int set_protocol_running(struct pcbit_dev * dev) return 0; } -static int pcbit_ioctl(isdn_ctrl* ctl) +static int pcbit_ioctl(isdn_ctrl *ctl) { - struct pcbit_dev * dev; + struct pcbit_dev *dev; struct pcbit_ioctl *cmd; dev = finddev(ctl->driver); - + if (!dev) { printk(KERN_DEBUG "pcbit_ioctl: unknown device\n"); @@ -877,7 +877,7 @@ static int pcbit_ioctl(isdn_ctrl* ctl) cmd = (struct pcbit_ioctl *) ctl->parm.num; - switch(ctl->arg) { + switch (ctl->arg) { case PCBIT_IOCTL_GETSTAT: cmd->info.l2_status = dev->l2_state; break; @@ -890,7 +890,7 @@ static int pcbit_ioctl(isdn_ctrl* ctl) dev->writeptr = dev->sh_mem; dev->readptr = dev->sh_mem + BANK2; - + dev->l2_state = L2_LOADING; break; @@ -907,21 +907,21 @@ static int pcbit_ioctl(isdn_ctrl* ctl) dev->loadptr = LOAD_ZONE_START; dev->l2_state = L2_FWMODE; - break; + break; case PCBIT_IOCTL_ENDLOAD: if (dev->l2_state == L2_RUNNING) return -EBUSY; dev->l2_state = L2_DOWN; - break; + break; - case PCBIT_IOCTL_SETBYTE: + case PCBIT_IOCTL_SETBYTE: if (dev->l2_state == L2_RUNNING) return -EBUSY; /* check addr */ if (cmd->info.rdp_byte.addr > BANK4) return -EFAULT; - + writeb(cmd->info.rdp_byte.value, dev->sh_mem + cmd->info.rdp_byte.addr); break; case PCBIT_IOCTL_GETBYTE: @@ -935,10 +935,10 @@ static int pcbit_ioctl(isdn_ctrl* ctl) printk("getbyte: invalid addr %04x\n", cmd->info.rdp_byte.addr); return -EFAULT; } - - cmd->info.rdp_byte.value = readb(dev->sh_mem + cmd->info.rdp_byte.addr); + + cmd->info.rdp_byte.value = readb(dev->sh_mem + cmd->info.rdp_byte.addr); break; - case PCBIT_IOCTL_RUNNING: + case PCBIT_IOCTL_RUNNING: if (dev->l2_state == L2_RUNNING) return -EBUSY; return set_protocol_running(dev); @@ -972,25 +972,25 @@ static int pcbit_ioctl(isdn_ctrl* ctl) return 0; } -/* +/* * MSN list handling * * if null reject all calls - * if first entry has null MSN accept all calls + * if first entry has null MSN accept all calls */ static void pcbit_clear_msn(struct pcbit_dev *dev) { struct msn_entry *ptr, *back; - for (ptr=dev->msn_list; ptr; ) + for (ptr = dev->msn_list; ptr;) { back = ptr->next; kfree(ptr); ptr = back; } - dev->msn_list = NULL; + dev->msn_list = NULL; } static void pcbit_set_msn(struct pcbit_dev *dev, char *list) @@ -1016,12 +1016,12 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list) } if (dev->msn_list) - for (back=dev->msn_list; back->next; back=back->next); - + for (back = dev->msn_list; back->next; back = back->next); + sp = list; do { - cp=strchr(sp, ','); + cp = strchr(sp, ','); if (cp) len = cp - sp; else @@ -1034,7 +1034,7 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list) return; } ptr->next = NULL; - + ptr->msn = kmalloc(len, GFP_ATOMIC); if (!ptr->msn) { printk(KERN_WARNING "kmalloc failed\n"); @@ -1054,7 +1054,7 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list) back->next = ptr; back = ptr; sp += len; - } while(cp); + } while (cp); } /* @@ -1063,12 +1063,12 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list) static int pcbit_check_msn(struct pcbit_dev *dev, char *msn) { struct msn_entry *ptr; - - for (ptr=dev->msn_list; ptr; ptr=ptr->next) { - if (ptr->msn == NULL) + for (ptr = dev->msn_list; ptr; ptr = ptr->next) { + + if (ptr->msn == NULL) return 1; - + if (strcmp(ptr->msn, msn) == 0) return 1; } diff --git a/drivers/isdn/pcbit/edss1.c b/drivers/isdn/pcbit/edss1.c index 80c9c16fd5e..b2262ba6f0c 100644 --- a/drivers/isdn/pcbit/edss1.c +++ b/drivers/isdn/pcbit/edss1.c @@ -3,10 +3,10 @@ * base: ITU-T Rec Q.931 * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -34,145 +34,145 @@ const char * const isdn_state_table[] = { - "Closed", - "Call initiated", - "Overlap sending", - "Outgoing call proceeding", - "NOT DEFINED", - "Call delivered", - "Call present", - "Call received", - "Connect request", - "Incoming call proceeding", - "Active", - "Disconnect request", - "Disconnect indication", - "NOT DEFINED", - "NOT DEFINED", - "Suspend request", - "NOT DEFINED", - "Resume request", - "NOT DEFINED", - "Release Request", - "NOT DEFINED", - "NOT DEFINED", - "NOT DEFINED", - "NOT DEFINED", - "NOT DEFINED", - "Overlap receiving", - "Select protocol on B-Channel", - "Activate B-channel protocol" + "Closed", + "Call initiated", + "Overlap sending", + "Outgoing call proceeding", + "NOT DEFINED", + "Call delivered", + "Call present", + "Call received", + "Connect request", + "Incoming call proceeding", + "Active", + "Disconnect request", + "Disconnect indication", + "NOT DEFINED", + "NOT DEFINED", + "Suspend request", + "NOT DEFINED", + "Resume request", + "NOT DEFINED", + "Release Request", + "NOT DEFINED", + "NOT DEFINED", + "NOT DEFINED", + "NOT DEFINED", + "NOT DEFINED", + "Overlap receiving", + "Select protocol on B-Channel", + "Activate B-channel protocol" }; #ifdef DEBUG_ERRS static struct CauseValue { - byte nr; - char *descr; -} cvlist[]={ - {0x01,"Unallocated (unassigned) number"}, - {0x02,"No route to specified transit network"}, - {0x03,"No route to destination"}, - {0x04,"Send special information tone"}, - {0x05,"Misdialled trunk prefix"}, - {0x06,"Channel unacceptable"}, - {0x07,"Channel awarded and being delivered in an established channel"}, - {0x08,"Preemption"}, - {0x09,"Preemption - circuit reserved for reuse"}, - {0x10,"Normal call clearing"}, - {0x11,"User busy"}, - {0x12,"No user responding"}, - {0x13,"No answer from user (user alerted)"}, - {0x14,"Subscriber absent"}, - {0x15,"Call rejected"}, - {0x16,"Number changed"}, - {0x1a,"non-selected user clearing"}, - {0x1b,"Destination out of order"}, - {0x1c,"Invalid number format (address incomplete)"}, - {0x1d,"Facility rejected"}, - {0x1e,"Response to Status enquiry"}, - {0x1f,"Normal, unspecified"}, - {0x22,"No circuit/channel available"}, - {0x26,"Network out of order"}, - {0x27,"Permanent frame mode connection out-of-service"}, - {0x28,"Permanent frame mode connection operational"}, - {0x29,"Temporary failure"}, - {0x2a,"Switching equipment congestion"}, - {0x2b,"Access information discarded"}, - {0x2c,"Requested circuit/channel not available"}, - {0x2e,"Precedence call blocked"}, - {0x2f,"Resource unavailable, unspecified"}, - {0x31,"Quality of service unavailable"}, - {0x32,"Requested facility not subscribed"}, - {0x35,"Outgoing calls barred within CUG"}, - {0x37,"Incoming calls barred within CUG"}, - {0x39,"Bearer capability not authorized"}, - {0x3a,"Bearer capability not presently available"}, - {0x3e,"Inconsistency in designated outgoing access information and subscriber class"}, - {0x3f,"Service or option not available, unspecified"}, - {0x41,"Bearer capability not implemented"}, - {0x42,"Channel type not implemented"}, - {0x43,"Requested facility not implemented"}, - {0x44,"Only restricted digital information bearer capability is available"}, - {0x4f,"Service or option not implemented"}, - {0x51,"Invalid call reference value"}, - {0x52,"Identified channel does not exist"}, - {0x53,"A suspended call exists, but this call identity does not"}, - {0x54,"Call identity in use"}, - {0x55,"No call suspended"}, - {0x56,"Call having the requested call identity has been cleared"}, - {0x57,"User not member of CUG"}, - {0x58,"Incompatible destination"}, - {0x5a,"Non-existent CUG"}, - {0x5b,"Invalid transit network selection"}, - {0x5f,"Invalid message, unspecified"}, - {0x60,"Mandatory information element is missing"}, - {0x61,"Message type non-existent or not implemented"}, - {0x62,"Message not compatible with call state or message type non-existent or not implemented"}, - {0x63,"Information element/parameter non-existent or not implemented"}, - {0x64,"Invalid information element contents"}, - {0x65,"Message not compatible with call state"}, - {0x66,"Recovery on timer expiry"}, - {0x67,"Parameter non-existent or not implemented - passed on"}, - {0x6e,"Message with unrecognized parameter discarded"}, - {0x6f,"Protocol error, unspecified"}, - {0x7f,"Interworking, unspecified"} + byte nr; + char *descr; +} cvlist[] = { + {0x01, "Unallocated (unassigned) number"}, + {0x02, "No route to specified transit network"}, + {0x03, "No route to destination"}, + {0x04, "Send special information tone"}, + {0x05, "Misdialled trunk prefix"}, + {0x06, "Channel unacceptable"}, + {0x07, "Channel awarded and being delivered in an established channel"}, + {0x08, "Preemption"}, + {0x09, "Preemption - circuit reserved for reuse"}, + {0x10, "Normal call clearing"}, + {0x11, "User busy"}, + {0x12, "No user responding"}, + {0x13, "No answer from user (user alerted)"}, + {0x14, "Subscriber absent"}, + {0x15, "Call rejected"}, + {0x16, "Number changed"}, + {0x1a, "non-selected user clearing"}, + {0x1b, "Destination out of order"}, + {0x1c, "Invalid number format (address incomplete)"}, + {0x1d, "Facility rejected"}, + {0x1e, "Response to Status enquiry"}, + {0x1f, "Normal, unspecified"}, + {0x22, "No circuit/channel available"}, + {0x26, "Network out of order"}, + {0x27, "Permanent frame mode connection out-of-service"}, + {0x28, "Permanent frame mode connection operational"}, + {0x29, "Temporary failure"}, + {0x2a, "Switching equipment congestion"}, + {0x2b, "Access information discarded"}, + {0x2c, "Requested circuit/channel not available"}, + {0x2e, "Precedence call blocked"}, + {0x2f, "Resource unavailable, unspecified"}, + {0x31, "Quality of service unavailable"}, + {0x32, "Requested facility not subscribed"}, + {0x35, "Outgoing calls barred within CUG"}, + {0x37, "Incoming calls barred within CUG"}, + {0x39, "Bearer capability not authorized"}, + {0x3a, "Bearer capability not presently available"}, + {0x3e, "Inconsistency in designated outgoing access information and subscriber class"}, + {0x3f, "Service or option not available, unspecified"}, + {0x41, "Bearer capability not implemented"}, + {0x42, "Channel type not implemented"}, + {0x43, "Requested facility not implemented"}, + {0x44, "Only restricted digital information bearer capability is available"}, + {0x4f, "Service or option not implemented"}, + {0x51, "Invalid call reference value"}, + {0x52, "Identified channel does not exist"}, + {0x53, "A suspended call exists, but this call identity does not"}, + {0x54, "Call identity in use"}, + {0x55, "No call suspended"}, + {0x56, "Call having the requested call identity has been cleared"}, + {0x57, "User not member of CUG"}, + {0x58, "Incompatible destination"}, + {0x5a, "Non-existent CUG"}, + {0x5b, "Invalid transit network selection"}, + {0x5f, "Invalid message, unspecified"}, + {0x60, "Mandatory information element is missing"}, + {0x61, "Message type non-existent or not implemented"}, + {0x62, "Message not compatible with call state or message type non-existent or not implemented"}, + {0x63, "Information element/parameter non-existent or not implemented"}, + {0x64, "Invalid information element contents"}, + {0x65, "Message not compatible with call state"}, + {0x66, "Recovery on timer expiry"}, + {0x67, "Parameter non-existent or not implemented - passed on"}, + {0x6e, "Message with unrecognized parameter discarded"}, + {0x6f, "Protocol error, unspecified"}, + {0x7f, "Interworking, unspecified"} }; #endif static struct isdn_event_desc { - unsigned short ev; - char * desc; -} isdn_event_table [] = { - {EV_USR_SETUP_REQ, "CC->L3: Setup Request"}, - {EV_USR_SETUP_RESP, "CC->L3: Setup Response"}, - {EV_USR_PROCED_REQ, "CC->L3: Proceeding Request"}, - {EV_USR_RELEASE_REQ, "CC->L3: Release Request"}, - - {EV_NET_SETUP, "NET->TE: setup "}, - {EV_NET_CALL_PROC, "NET->TE: call proceeding"}, - {EV_NET_SETUP_ACK, "NET->TE: setup acknowledge (more info needed)"}, - {EV_NET_CONN, "NET->TE: connect"}, - {EV_NET_CONN_ACK, "NET->TE: connect acknowledge"}, - {EV_NET_DISC, "NET->TE: disconnect indication"}, - {EV_NET_RELEASE, "NET->TE: release"}, - {EV_NET_RELEASE_COMP, "NET->TE: release complete"}, - {EV_NET_SELP_RESP, "Board: Select B-channel protocol ack"}, - {EV_NET_ACTV_RESP, "Board: Activate B-channel protocol ack"}, - {EV_TIMER, "Timeout"}, - {0, "NULL"} + unsigned short ev; + char *desc; +} isdn_event_table[] = { + {EV_USR_SETUP_REQ, "CC->L3: Setup Request"}, + {EV_USR_SETUP_RESP, "CC->L3: Setup Response"}, + {EV_USR_PROCED_REQ, "CC->L3: Proceeding Request"}, + {EV_USR_RELEASE_REQ, "CC->L3: Release Request"}, + + {EV_NET_SETUP, "NET->TE: setup "}, + {EV_NET_CALL_PROC, "NET->TE: call proceeding"}, + {EV_NET_SETUP_ACK, "NET->TE: setup acknowledge (more info needed)"}, + {EV_NET_CONN, "NET->TE: connect"}, + {EV_NET_CONN_ACK, "NET->TE: connect acknowledge"}, + {EV_NET_DISC, "NET->TE: disconnect indication"}, + {EV_NET_RELEASE, "NET->TE: release"}, + {EV_NET_RELEASE_COMP, "NET->TE: release complete"}, + {EV_NET_SELP_RESP, "Board: Select B-channel protocol ack"}, + {EV_NET_ACTV_RESP, "Board: Activate B-channel protocol ack"}, + {EV_TIMER, "Timeout"}, + {0, "NULL"} }; -char * strisdnevent(ushort ev) +char *strisdnevent(ushort ev) { - struct isdn_event_desc * entry; - - for (entry = isdn_event_table; entry->ev; entry++) - if (entry->ev == ev) - break; + struct isdn_event_desc *entry; + + for (entry = isdn_event_table; entry->ev; entry++) + if (entry->ev == ev) + break; - return entry->desc; + return entry->desc; } /* @@ -180,130 +180,130 @@ char * strisdnevent(ushort ev) */ static struct fsm_timer_entry fsm_timers[] = { - {ST_CALL_PROC, 10}, - {ST_DISC_REQ, 2}, - {ST_ACTIVE_SELP, 5}, - {ST_ACTIVE_ACTV, 5}, - {ST_INCM_PROC, 10}, - {ST_CONN_REQ, 2}, - {0xff, 0} + {ST_CALL_PROC, 10}, + {ST_DISC_REQ, 2}, + {ST_ACTIVE_SELP, 5}, + {ST_ACTIVE_ACTV, 5}, + {ST_INCM_PROC, 10}, + {ST_CONN_REQ, 2}, + {0xff, 0} }; static struct fsm_entry fsm_table[] = { /* Connect Phase */ - /* Outgoing */ - {ST_NULL, ST_CALL_INIT, EV_USR_SETUP_REQ, cb_out_1}, + /* Outgoing */ + {ST_NULL, ST_CALL_INIT, EV_USR_SETUP_REQ, cb_out_1}, - {ST_CALL_INIT, ST_OVER_SEND, EV_NET_SETUP_ACK, cb_notdone}, - {ST_CALL_INIT, ST_CALL_PROC, EV_NET_CALL_PROC, NULL}, - {ST_CALL_INIT, ST_NULL, EV_NET_DISC, cb_out_2}, + {ST_CALL_INIT, ST_OVER_SEND, EV_NET_SETUP_ACK, cb_notdone}, + {ST_CALL_INIT, ST_CALL_PROC, EV_NET_CALL_PROC, NULL}, + {ST_CALL_INIT, ST_NULL, EV_NET_DISC, cb_out_2}, - {ST_CALL_PROC, ST_ACTIVE_SELP, EV_NET_CONN, cb_out_2}, - {ST_CALL_PROC, ST_NULL, EV_NET_DISC, cb_disc_1}, - {ST_CALL_PROC, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + {ST_CALL_PROC, ST_ACTIVE_SELP, EV_NET_CONN, cb_out_2}, + {ST_CALL_PROC, ST_NULL, EV_NET_DISC, cb_disc_1}, + {ST_CALL_PROC, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - /* Incoming */ - {ST_NULL, ST_CALL_PRES, EV_NET_SETUP, NULL}, + /* Incoming */ + {ST_NULL, ST_CALL_PRES, EV_NET_SETUP, NULL}, - {ST_CALL_PRES, ST_INCM_PROC, EV_USR_PROCED_REQ, cb_in_1}, - {ST_CALL_PRES, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + {ST_CALL_PRES, ST_INCM_PROC, EV_USR_PROCED_REQ, cb_in_1}, + {ST_CALL_PRES, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - {ST_INCM_PROC, ST_CONN_REQ, EV_USR_SETUP_RESP, cb_in_2}, - {ST_INCM_PROC, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + {ST_INCM_PROC, ST_CONN_REQ, EV_USR_SETUP_RESP, cb_in_2}, + {ST_INCM_PROC, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - {ST_CONN_REQ, ST_ACTIVE_SELP, EV_NET_CONN_ACK, cb_in_3}, + {ST_CONN_REQ, ST_ACTIVE_SELP, EV_NET_CONN_ACK, cb_in_3}, - /* Active */ - {ST_ACTIVE, ST_NULL, EV_NET_DISC, cb_disc_1}, - {ST_ACTIVE, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - {ST_ACTIVE, ST_NULL, EV_NET_RELEASE, cb_disc_3}, + /* Active */ + {ST_ACTIVE, ST_NULL, EV_NET_DISC, cb_disc_1}, + {ST_ACTIVE, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + {ST_ACTIVE, ST_NULL, EV_NET_RELEASE, cb_disc_3}, - /* Disconnect */ + /* Disconnect */ - {ST_DISC_REQ, ST_NULL, EV_NET_DISC, cb_disc_1}, - {ST_DISC_REQ, ST_NULL, EV_NET_RELEASE, cb_disc_3}, + {ST_DISC_REQ, ST_NULL, EV_NET_DISC, cb_disc_1}, + {ST_DISC_REQ, ST_NULL, EV_NET_RELEASE, cb_disc_3}, - /* protocol selection */ - {ST_ACTIVE_SELP, ST_ACTIVE_ACTV, EV_NET_SELP_RESP, cb_selp_1}, - {ST_ACTIVE_SELP, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + /* protocol selection */ + {ST_ACTIVE_SELP, ST_ACTIVE_ACTV, EV_NET_SELP_RESP, cb_selp_1}, + {ST_ACTIVE_SELP, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - {ST_ACTIVE_ACTV, ST_ACTIVE, EV_NET_ACTV_RESP, cb_open}, - {ST_ACTIVE_ACTV, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + {ST_ACTIVE_ACTV, ST_ACTIVE, EV_NET_ACTV_RESP, cb_open}, + {ST_ACTIVE_ACTV, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - /* Timers */ - {ST_CALL_PROC, ST_DISC_REQ, EV_TIMER, cb_disc_2}, - {ST_DISC_REQ, ST_NULL, EV_TIMER, cb_disc_3}, - {ST_ACTIVE_SELP, ST_DISC_REQ, EV_TIMER, cb_disc_2}, - {ST_ACTIVE_ACTV, ST_DISC_REQ, EV_TIMER, cb_disc_2}, - {ST_INCM_PROC, ST_DISC_REQ, EV_TIMER, cb_disc_2}, - {ST_CONN_REQ, ST_CONN_REQ, EV_TIMER, cb_in_2}, - - {0xff, 0, 0, NULL} + /* Timers */ + {ST_CALL_PROC, ST_DISC_REQ, EV_TIMER, cb_disc_2}, + {ST_DISC_REQ, ST_NULL, EV_TIMER, cb_disc_3}, + {ST_ACTIVE_SELP, ST_DISC_REQ, EV_TIMER, cb_disc_2}, + {ST_ACTIVE_ACTV, ST_DISC_REQ, EV_TIMER, cb_disc_2}, + {ST_INCM_PROC, ST_DISC_REQ, EV_TIMER, cb_disc_2}, + {ST_CONN_REQ, ST_CONN_REQ, EV_TIMER, cb_in_2}, + + {0xff, 0, 0, NULL} }; static void pcbit_fsm_timer(unsigned long data) { - struct pcbit_dev *dev; - struct pcbit_chan *chan; + struct pcbit_dev *dev; + struct pcbit_chan *chan; - chan = (struct pcbit_chan *) data; + chan = (struct pcbit_chan *) data; - del_timer(&chan->fsm_timer); - chan->fsm_timer.function = NULL; + del_timer(&chan->fsm_timer); + chan->fsm_timer.function = NULL; - dev = chan2dev(chan); + dev = chan2dev(chan); - if (dev == NULL) { - printk(KERN_WARNING "pcbit: timer for unknown device\n"); - return; - } + if (dev == NULL) { + printk(KERN_WARNING "pcbit: timer for unknown device\n"); + return; + } - pcbit_fsm_event(dev, chan, EV_TIMER, NULL); + pcbit_fsm_event(dev, chan, EV_TIMER, NULL); } void pcbit_fsm_event(struct pcbit_dev *dev, struct pcbit_chan *chan, - unsigned short event, struct callb_data *data) + unsigned short event, struct callb_data *data) { - struct fsm_entry * action; + struct fsm_entry *action; struct fsm_timer_entry *tentry; unsigned long flags; spin_lock_irqsave(&dev->lock, flags); - for (action = fsm_table; action->init != 0xff; action++) - if (action->init == chan->fsm_state && action->event == event) - break; - + for (action = fsm_table; action->init != 0xff; action++) + if (action->init == chan->fsm_state && action->event == event) + break; + if (action->init == 0xff) { - + spin_unlock_irqrestore(&dev->lock, flags); - printk(KERN_DEBUG "fsm error: event %x on state %x\n", - event, chan->fsm_state); + printk(KERN_DEBUG "fsm error: event %x on state %x\n", + event, chan->fsm_state); return; } - if (chan->fsm_timer.function) { - del_timer(&chan->fsm_timer); - chan->fsm_timer.function = NULL; - } + if (chan->fsm_timer.function) { + del_timer(&chan->fsm_timer); + chan->fsm_timer.function = NULL; + } chan->fsm_state = action->final; - + pcbit_state_change(dev, chan, action->init, event, action->final); - for (tentry = fsm_timers; tentry->init != 0xff; tentry++) - if (tentry->init == chan->fsm_state) - break; + for (tentry = fsm_timers; tentry->init != 0xff; tentry++) + if (tentry->init == chan->fsm_state) + break; - if (tentry->init != 0xff) { - init_timer(&chan->fsm_timer); - chan->fsm_timer.function = &pcbit_fsm_timer; - chan->fsm_timer.data = (ulong) chan; - chan->fsm_timer.expires = jiffies + tentry->timeout * HZ; - add_timer(&chan->fsm_timer); - } + if (tentry->init != 0xff) { + init_timer(&chan->fsm_timer); + chan->fsm_timer.function = &pcbit_fsm_timer; + chan->fsm_timer.data = (ulong) chan; + chan->fsm_timer.expires = jiffies + tentry->timeout * HZ; + add_timer(&chan->fsm_timer); + } spin_unlock_irqrestore(&dev->lock, flags); @@ -311,7 +311,3 @@ void pcbit_fsm_event(struct pcbit_dev *dev, struct pcbit_chan *chan, action->callb(dev, chan, data); } - - - - diff --git a/drivers/isdn/pcbit/edss1.h b/drivers/isdn/pcbit/edss1.h index 39f8346e28c..2f6b3a8edfb 100644 --- a/drivers/isdn/pcbit/edss1.h +++ b/drivers/isdn/pcbit/edss1.h @@ -2,10 +2,10 @@ * DSS.1 module definitions * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -62,9 +62,9 @@ /* * Cause values * only the ones we use - */ + */ -#define CAUSE_NORMAL 0x10U +#define CAUSE_NORMAL 0x10U #define CAUSE_NOCHAN 0x22U struct callb_data { @@ -94,9 +94,6 @@ extern const char * const isdn_state_table[]; void pcbit_fsm_event(struct pcbit_dev *, struct pcbit_chan *, unsigned short event, struct callb_data *); -char * strisdnevent(ushort ev); +char *strisdnevent(ushort ev); #endif - - - diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c index 30f0f45e313..682911f8113 100644 --- a/drivers/isdn/pcbit/layer2.c +++ b/drivers/isdn/pcbit/layer2.c @@ -12,7 +12,7 @@ /* * 19991203 - Fernando Carvalho - takion@superbofh.org * Hacked to compile with egcs and run with current version of isdn modules -*/ + */ /* * Based on documentation provided by Inesc: @@ -77,7 +77,7 @@ pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum, struct sk_buff *skb, unsigned short hdr_len) { struct frame_buf *frame, - *ptr; + *ptr; unsigned long flags; if (dev->l2_state != L2_RUNNING && dev->l2_state != L2_LOADING) { @@ -85,7 +85,7 @@ pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum, return -1; } if ((frame = kmalloc(sizeof(struct frame_buf), - GFP_ATOMIC)) == NULL) { + GFP_ATOMIC)) == NULL) { printk(KERN_WARNING "pcbit_2_write: kmalloc failed\n"); dev_kfree_skb(skb); return -1; @@ -147,7 +147,7 @@ pcbit_transmit(struct pcbit_dev *dev) int flen; /* fragment frame length including all headers */ int free; int count, - cp_len; + cp_len; unsigned long flags; unsigned short tt; @@ -177,7 +177,7 @@ pcbit_transmit(struct pcbit_dev *dev) /* Type 0 frame */ - ulong msg; + ulong msg; if (frame->skb) flen = FRAME_HDR_LEN + PREHDR_LEN + frame->skb->len; @@ -270,7 +270,7 @@ pcbit_transmit(struct pcbit_dev *dev) spin_unlock_irqrestore(&dev->lock, flags); #ifdef DEBUG printk(KERN_DEBUG "unacked %d free %d write_queue %s\n", - unacked, dev->free, dev->write_queue ? "not empty" : + unacked, dev->free, dev->write_queue ? "not empty" : "empty"); #endif } @@ -301,8 +301,8 @@ pcbit_deliver(struct work_struct *work) SET_MSG_CMD(msg, frame->skb->data[2]); SET_MSG_SCMD(msg, frame->skb->data[3]); - frame->refnum = *((ushort *) frame->skb->data + 4); - frame->msg = *((ulong *) & msg); + frame->refnum = *((ushort *)frame->skb->data + 4); + frame->msg = *((ulong *)&msg); skb_pull(frame->skb, 6); @@ -326,7 +326,7 @@ pcbit_receive(struct pcbit_dev *dev) { unsigned short tt; u_char cpu, - proc; + proc; struct frame_buf *frame = NULL; unsigned long flags; u_char type1; @@ -378,10 +378,10 @@ pcbit_receive(struct pcbit_dev *dev) frame->dt_len = pcbit_readw(dev); /* - * 0 sized packet - * I don't know if they are an error or not... - * But they are very frequent - * Not documented + * 0 sized packet + * I don't know if they are an error or not... + * But they are very frequent + * Not documented */ if (frame->hdr_len == 0) { @@ -499,8 +499,8 @@ pcbit_irq_handler(int interrupt, void *devptr) { struct pcbit_dev *dev; u_char info, - ack_seq, - read_seq; + ack_seq, + read_seq; dev = (struct pcbit_dev *) devptr; @@ -666,7 +666,7 @@ static void pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack) { int i, - count; + count; int unacked; unacked = (dev->send_seq + (8 - dev->unack_seq)) & 0x07; @@ -678,13 +678,13 @@ pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack) if (dev->send_seq > dev->unack_seq) { if (ack <= dev->unack_seq || ack > dev->send_seq) { printk(KERN_DEBUG - "layer 2 ack unacceptable - dev %d", + "layer 2 ack unacceptable - dev %d", dev->id); pcbit_l2_error(dev); } else if (ack > dev->send_seq && ack <= dev->unack_seq) { printk(KERN_DEBUG - "layer 2 ack unacceptable - dev %d", + "layer 2 ack unacceptable - dev %d", dev->id); pcbit_l2_error(dev); } diff --git a/drivers/isdn/pcbit/layer2.h b/drivers/isdn/pcbit/layer2.h index 2ac295e1a6e..be1327bc162 100644 --- a/drivers/isdn/pcbit/layer2.h +++ b/drivers/isdn/pcbit/layer2.h @@ -2,17 +2,17 @@ * PCBIT-D low-layer interface definitions * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ /* * 19991203 - Fernando Carvalho - takion@superbofh.org * Hacked to compile with egcs and run with current version of isdn modules -*/ + */ #ifndef LAYER2_H #define LAYER2_H @@ -37,8 +37,8 @@ /* TAM - XX - C - S - NUM */ #define PREHDR_LEN 8 -/* TT - M - I - TH - TD */ -#define FRAME_HDR_LEN 8 +/* TT - M - I - TH - TD */ +#define FRAME_HDR_LEN 8 #define MSG_CONN_REQ 0x08000100 #define MSG_CONN_CONF 0x00000101 @@ -84,21 +84,21 @@ #define MSG_DEBUG_188 0x0000ff00 /* - - long 4 3 2 1 - Intel 1 2 3 4 + + long 4 3 2 1 + Intel 1 2 3 4 */ #ifdef __LITTLE_ENDIAN -#define SET_MSG_SCMD(msg, ch) (msg = (msg & 0xffffff00) | (((ch) & 0xff))) -#define SET_MSG_CMD(msg, ch) (msg = (msg & 0xffff00ff) | (((ch) & 0xff) << 8)) -#define SET_MSG_PROC(msg, ch) (msg = (msg & 0xff00ffff) | (((ch) & 0xff) << 16)) -#define SET_MSG_CPU(msg, ch) (msg = (msg & 0x00ffffff) | (((ch) & 0xff) << 24)) +#define SET_MSG_SCMD(msg, ch) (msg = (msg & 0xffffff00) | (((ch) & 0xff))) +#define SET_MSG_CMD(msg, ch) (msg = (msg & 0xffff00ff) | (((ch) & 0xff) << 8)) +#define SET_MSG_PROC(msg, ch) (msg = (msg & 0xff00ffff) | (((ch) & 0xff) << 16)) +#define SET_MSG_CPU(msg, ch) (msg = (msg & 0x00ffffff) | (((ch) & 0xff) << 24)) -#define GET_MSG_SCMD(msg) ((msg) & 0xFF) -#define GET_MSG_CMD(msg) ((msg) >> 8 & 0xFF) -#define GET_MSG_PROC(msg) ((msg) >> 16 & 0xFF) -#define GET_MSG_CPU(msg) ((msg) >> 24) +#define GET_MSG_SCMD(msg) ((msg) & 0xFF) +#define GET_MSG_CMD(msg) ((msg) >> 8 & 0xFF) +#define GET_MSG_PROC(msg) ((msg) >> 16 & 0xFF) +#define GET_MSG_CPU(msg) ((msg) >> 24) #else #error "Non-Intel CPU" @@ -109,60 +109,60 @@ #define SCHED_READ 0x01 #define SCHED_WRITE 0x02 -#define SET_RUN_TIMEOUT 2*HZ /* 2 seconds */ - +#define SET_RUN_TIMEOUT 2 * HZ /* 2 seconds */ + struct frame_buf { - ulong msg; - unsigned int refnum; - unsigned int dt_len; - unsigned int hdr_len; - struct sk_buff *skb; + ulong msg; + unsigned int refnum; + unsigned int dt_len; + unsigned int hdr_len; + struct sk_buff *skb; unsigned int copied; - struct frame_buf * next; + struct frame_buf *next; }; -extern int pcbit_l2_write(struct pcbit_dev * dev, ulong msg, ushort refnum, - struct sk_buff *skb, unsigned short hdr_len); +extern int pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum, + struct sk_buff *skb, unsigned short hdr_len); extern irqreturn_t pcbit_irq_handler(int interrupt, void *); -extern struct pcbit_dev * dev_pcbit[MAX_PCBIT_CARDS]; +extern struct pcbit_dev *dev_pcbit[MAX_PCBIT_CARDS]; #ifdef DEBUG static __inline__ void log_state(struct pcbit_dev *dev) { - printk(KERN_DEBUG "writeptr = %ld\n", + printk(KERN_DEBUG "writeptr = %ld\n", (ulong) (dev->writeptr - dev->sh_mem)); - printk(KERN_DEBUG "readptr = %ld\n", + printk(KERN_DEBUG "readptr = %ld\n", (ulong) (dev->readptr - (dev->sh_mem + BANK2))); - printk(KERN_DEBUG "{rcv_seq=%01x, send_seq=%01x, unack_seq=%01x}\n", + printk(KERN_DEBUG "{rcv_seq=%01x, send_seq=%01x, unack_seq=%01x}\n", dev->rcv_seq, dev->send_seq, dev->unack_seq); } #endif -static __inline__ struct pcbit_dev * chan2dev(struct pcbit_chan * chan) +static __inline__ struct pcbit_dev *chan2dev(struct pcbit_chan *chan) { - struct pcbit_dev * dev; - int i; + struct pcbit_dev *dev; + int i; - for (i=0; ib1 == chan || dev->b2 == chan) - return dev; - return NULL; + for (i = 0; i < MAX_PCBIT_CARDS; i++) + if ((dev = dev_pcbit[i])) + if (dev->b1 == chan || dev->b2 == chan) + return dev; + return NULL; } -static __inline__ struct pcbit_dev * finddev(int id) +static __inline__ struct pcbit_dev *finddev(int id) { - struct pcbit_dev * dev; - int i; - - for (i=0; iid == id) - return dev; - return NULL; + struct pcbit_dev *dev; + int i; + + for (i = 0; i < MAX_PCBIT_CARDS; i++) + if ((dev = dev_pcbit[i])) + if (dev->id == id) + return dev; + return NULL; } @@ -172,117 +172,110 @@ static __inline__ struct pcbit_dev * finddev(int id) static __inline__ void pcbit_writeb(struct pcbit_dev *dev, unsigned char dt) { - writeb(dt, dev->writeptr++); - if (dev->writeptr == dev->sh_mem + BANKLEN) - dev->writeptr = dev->sh_mem; + writeb(dt, dev->writeptr++); + if (dev->writeptr == dev->sh_mem + BANKLEN) + dev->writeptr = dev->sh_mem; } static __inline__ void pcbit_writew(struct pcbit_dev *dev, unsigned short dt) { - int dist; - - dist = BANKLEN - (dev->writeptr - dev->sh_mem); - switch (dist) { - case 2: - writew(dt, dev->writeptr); - dev->writeptr = dev->sh_mem; - break; - case 1: - writeb((u_char) (dt & 0x00ffU), dev->writeptr); - dev->writeptr = dev->sh_mem; - writeb((u_char) (dt >> 8), dev->writeptr++); - break; - default: - writew(dt, dev->writeptr); - dev->writeptr += 2; - break; - }; + int dist; + + dist = BANKLEN - (dev->writeptr - dev->sh_mem); + switch (dist) { + case 2: + writew(dt, dev->writeptr); + dev->writeptr = dev->sh_mem; + break; + case 1: + writeb((u_char) (dt & 0x00ffU), dev->writeptr); + dev->writeptr = dev->sh_mem; + writeb((u_char) (dt >> 8), dev->writeptr++); + break; + default: + writew(dt, dev->writeptr); + dev->writeptr += 2; + break; + }; } -static __inline__ void memcpy_topcbit(struct pcbit_dev * dev, u_char * data, +static __inline__ void memcpy_topcbit(struct pcbit_dev *dev, u_char *data, int len) { - int diff; - - diff = len - (BANKLEN - (dev->writeptr - dev->sh_mem) ); - - if (diff > 0) - { - memcpy_toio(dev->writeptr, data, len - diff); - memcpy_toio(dev->sh_mem, data + (len - diff), diff); - dev->writeptr = dev->sh_mem + diff; - } - else - { - memcpy_toio(dev->writeptr, data, len); - - dev->writeptr += len; - if (diff == 0) - dev->writeptr = dev->sh_mem; - } + int diff; + + diff = len - (BANKLEN - (dev->writeptr - dev->sh_mem)); + + if (diff > 0) + { + memcpy_toio(dev->writeptr, data, len - diff); + memcpy_toio(dev->sh_mem, data + (len - diff), diff); + dev->writeptr = dev->sh_mem + diff; + } + else + { + memcpy_toio(dev->writeptr, data, len); + + dev->writeptr += len; + if (diff == 0) + dev->writeptr = dev->sh_mem; + } } static __inline__ unsigned char pcbit_readb(struct pcbit_dev *dev) { - unsigned char val; + unsigned char val; - val = readb(dev->readptr++); - if (dev->readptr == dev->sh_mem + BANK2 + BANKLEN) - dev->readptr = dev->sh_mem + BANK2; + val = readb(dev->readptr++); + if (dev->readptr == dev->sh_mem + BANK2 + BANKLEN) + dev->readptr = dev->sh_mem + BANK2; - return val; + return val; } static __inline__ unsigned short pcbit_readw(struct pcbit_dev *dev) { - int dist; - unsigned short val; - - dist = BANKLEN - ( dev->readptr - (dev->sh_mem + BANK2 ) ); - switch (dist) { - case 2: - val = readw(dev->readptr); - dev->readptr = dev->sh_mem + BANK2; - break; - case 1: - val = readb(dev->readptr); - dev->readptr = dev->sh_mem + BANK2; - val = (readb(dev->readptr++) << 8) | val; - break; - default: - val = readw(dev->readptr); - dev->readptr += 2; - break; - }; - return val; + int dist; + unsigned short val; + + dist = BANKLEN - (dev->readptr - (dev->sh_mem + BANK2)); + switch (dist) { + case 2: + val = readw(dev->readptr); + dev->readptr = dev->sh_mem + BANK2; + break; + case 1: + val = readb(dev->readptr); + dev->readptr = dev->sh_mem + BANK2; + val = (readb(dev->readptr++) << 8) | val; + break; + default: + val = readw(dev->readptr); + dev->readptr += 2; + break; + }; + return val; } -static __inline__ void memcpy_frompcbit(struct pcbit_dev * dev, u_char * data, int len) +static __inline__ void memcpy_frompcbit(struct pcbit_dev *dev, u_char *data, int len) { - int diff; - - diff = len - (BANKLEN - (dev->readptr - (dev->sh_mem + BANK2) ) ); - if (diff > 0) - { - memcpy_fromio(data, dev->readptr, len - diff); - memcpy_fromio(data + (len - diff), dev->sh_mem + BANK2 , diff); - dev->readptr = dev->sh_mem + BANK2 + diff; - } - else - { - memcpy_fromio(data, dev->readptr, len); - dev->readptr += len; - if (diff == 0) - dev->readptr = dev->sh_mem + BANK2; - } + int diff; + + diff = len - (BANKLEN - (dev->readptr - (dev->sh_mem + BANK2))); + if (diff > 0) + { + memcpy_fromio(data, dev->readptr, len - diff); + memcpy_fromio(data + (len - diff), dev->sh_mem + BANK2 , diff); + dev->readptr = dev->sh_mem + BANK2 + diff; + } + else + { + memcpy_fromio(data, dev->readptr, len); + dev->readptr += len; + if (diff == 0) + dev->readptr = dev->sh_mem + BANK2; + } } #endif - - - - - - - diff --git a/drivers/isdn/pcbit/module.c b/drivers/isdn/pcbit/module.c index 04ea241ff17..0a59bd0b821 100644 --- a/drivers/isdn/pcbit/module.c +++ b/drivers/isdn/pcbit/module.c @@ -2,10 +2,10 @@ * PCBIT-D module support * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -29,7 +29,7 @@ module_param_array(mem, int, NULL, 0); module_param_array(irq, int, NULL, 0); static int num_boards; -struct pcbit_dev * dev_pcbit[MAX_PCBIT_CARDS]; +struct pcbit_dev *dev_pcbit[MAX_PCBIT_CARDS]; static int __init pcbit_init(void) { @@ -37,26 +37,26 @@ static int __init pcbit_init(void) num_boards = 0; - printk(KERN_NOTICE + printk(KERN_NOTICE "PCBIT-D device driver v 0.5-fjpc0 19991204 - " "Copyright (C) 1996 Universidade de Lisboa\n"); - if (mem[0] || irq[0]) + if (mem[0] || irq[0]) { - for (board=0; board < MAX_PCBIT_CARDS && mem[board] && irq[board]; board++) + for (board = 0; board < MAX_PCBIT_CARDS && mem[board] && irq[board]; board++) { if (!mem[board]) mem[board] = 0xD0000; if (!irq[board]) irq[board] = 5; - + if (pcbit_init_dev(board, mem[board], irq[board]) == 0) num_boards++; - - else + + else { - printk(KERN_WARNING - "pcbit_init failed for dev %d", + printk(KERN_WARNING + "pcbit_init failed for dev %d", board + 1); return -EIO; } @@ -67,7 +67,7 @@ static int __init pcbit_init(void) if (!num_boards) { - printk(KERN_INFO + printk(KERN_INFO "Trying to detect board using default settings\n"); if (pcbit_init_dev(0, 0xD0000, 5) == 0) num_boards++; @@ -84,7 +84,7 @@ static void __exit pcbit_exit(void) for (board = 0; board < num_boards; board++) pcbit_terminate(board); - printk(KERN_NOTICE + printk(KERN_NOTICE "PCBIT-D module unloaded\n"); #endif } @@ -95,20 +95,20 @@ static int __init pcbit_setup(char *line) { int i, j, argc; char *str; - int ints[MAX_PARA+1]; + int ints[MAX_PARA + 1]; str = get_options(line, MAX_PARA, ints); argc = ints[0]; i = 0; j = 1; - while (argc && (i