X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fisdn%2Fcapi%2Fcapidrv.c;h=c4d438c17dabf0cd1a1bbb06a1fda9953cce25e2;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=36ee8c2d0492b8047ed9f0556fcce52d0d7cdb29;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index 36ee8c2d0..c4d438c17 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -40,7 +41,7 @@ static int debugmode = 0; MODULE_DESCRIPTION("CAPI4Linux: Interface to ISDN4Linux"); MODULE_AUTHOR("Carsten Paeth"); MODULE_LICENSE("GPL"); -MODULE_PARM(debugmode, "i"); +module_param(debugmode, uint, 0); /* -------- type definitions ----------------------------------------- */ @@ -139,7 +140,7 @@ typedef struct capidrv_bchan capidrv_bchan; /* -------- data definitions ----------------------------------------- */ static capidrv_data global; -static spinlock_t global_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(global_lock); static void handle_dtrace_data(capidrv_contr *card, int send, int level2, u8 *data, u16 len); @@ -230,7 +231,7 @@ static _cstruct b1config(int l2, int l3) case ISDN_PROTO_L2_HDLC: case ISDN_PROTO_L2_TRANS: default: - return 0; + return NULL; case ISDN_PROTO_L2_V11096: return b1config_async_v110(9600); case ISDN_PROTO_L2_V11019: @@ -333,12 +334,11 @@ static capidrv_plci *new_plci(capidrv_contr * card, int chan) { capidrv_plci *plcip; - plcip = (capidrv_plci *) kmalloc(sizeof(capidrv_plci), GFP_ATOMIC); + plcip = kzalloc(sizeof(capidrv_plci), GFP_ATOMIC); if (plcip == 0) - return 0; + return NULL; - memset(plcip, 0, sizeof(capidrv_plci)); plcip->state = ST_PLCI_NONE; plcip->plci = 0; plcip->msgid = 0; @@ -356,7 +356,7 @@ static capidrv_plci *find_plci_by_plci(capidrv_contr * card, u32 plci) for (p = card->plci_list; p; p = p->next) if (p->plci == plci) return p; - return 0; + return NULL; } static capidrv_plci *find_plci_by_msgid(capidrv_contr * card, u16 msgid) @@ -365,7 +365,7 @@ static capidrv_plci *find_plci_by_msgid(capidrv_contr * card, u16 msgid) for (p = card->plci_list; p; p = p->next) if (p->msgid == msgid) return p; - return 0; + return NULL; } static capidrv_plci *find_plci_by_ncci(capidrv_contr * card, u32 ncci) @@ -374,7 +374,7 @@ static capidrv_plci *find_plci_by_ncci(capidrv_contr * card, u32 ncci) for (p = card->plci_list; p; p = p->next) if (p->plci == (ncci & 0xffff)) return p; - return 0; + return NULL; } static void free_plci(capidrv_contr * card, capidrv_plci * plcip) @@ -384,7 +384,7 @@ static void free_plci(capidrv_contr * card, capidrv_plci * plcip) for (pp = &card->plci_list; *pp; pp = &(*pp)->next) { if (*pp == plcip) { *pp = (*pp)->next; - card->bchans[plcip->chan].plcip = 0; + card->bchans[plcip->chan].plcip = NULL; card->bchans[plcip->chan].disconnecting = 0; card->bchans[plcip->chan].incoming = 0; kfree(plcip); @@ -403,12 +403,11 @@ static inline capidrv_ncci *new_ncci(capidrv_contr * card, { capidrv_ncci *nccip; - nccip = (capidrv_ncci *) kmalloc(sizeof(capidrv_ncci), GFP_ATOMIC); + nccip = kzalloc(sizeof(capidrv_ncci), GFP_ATOMIC); if (nccip == 0) - return 0; + return NULL; - memset(nccip, 0, sizeof(capidrv_ncci)); nccip->ncci = ncci; nccip->state = ST_NCCI_NONE; nccip->plcip = plcip; @@ -429,12 +428,12 @@ static inline capidrv_ncci *find_ncci(capidrv_contr * card, u32 ncci) capidrv_ncci *p; if ((plcip = find_plci_by_ncci(card, ncci)) == 0) - return 0; + return NULL; for (p = plcip->ncci_list; p; p = p->next) if (p->ncci == ncci) return p; - return 0; + return NULL; } static inline capidrv_ncci *find_ncci_by_msgid(capidrv_contr * card, @@ -444,12 +443,12 @@ static inline capidrv_ncci *find_ncci_by_msgid(capidrv_contr * card, capidrv_ncci *p; if ((plcip = find_plci_by_ncci(card, ncci)) == 0) - return 0; + return NULL; for (p = plcip->ncci_list; p; p = p->next) if (p->msgid == msgid) return p; - return 0; + return NULL; } static void free_ncci(capidrv_contr * card, struct capidrv_ncci *nccip) @@ -462,7 +461,7 @@ static void free_ncci(capidrv_contr * card, struct capidrv_ncci *nccip) break; } } - card->bchans[nccip->chan].nccip = 0; + card->bchans[nccip->chan].nccip = NULL; kfree(nccip); } @@ -477,7 +476,7 @@ static int capidrv_add_ack(struct capidrv_ncci *nccip, printk(KERN_ERR "capidrv: kmalloc ncci_datahandle failed\n"); return -1; } - n->next = 0; + n->next = NULL; n->datahandle = datahandle; n->len = len; for (pp = &nccip->ackqueue; *pp; pp = &(*pp)->next) ; @@ -512,7 +511,8 @@ static void send_message(capidrv_contr * card, _cmsg * cmsg) len = CAPIMSG_LEN(cmsg->buf); skb = alloc_skb(len, GFP_ATOMIC); memcpy(skb_put(skb, len), cmsg->buf, len); - capi20_put_message(&global.ap, skb); + if (capi20_put_message(&global.ap, skb) != CAPI_NOERROR) + kfree_skb(skb); } /* -------- state machine -------------------------------------------- */ @@ -560,7 +560,7 @@ static void p0(capidrv_contr * card, capidrv_plci * plci) { isdn_ctrl cmd; - card->bchans[plci->chan].contr = 0; + card->bchans[plci->chan].contr = NULL; cmd.command = ISDN_STAT_DHUP; cmd.driver = card->myid; cmd.arg = plci->chan; @@ -580,54 +580,54 @@ struct plcistatechange { static struct plcistatechange plcitable[] = { /* P-0 */ - {ST_PLCI_NONE, ST_PLCI_OUTGOING, EV_PLCI_CONNECT_REQ, 0}, - {ST_PLCI_NONE, ST_PLCI_ALLOCATED, EV_PLCI_FACILITY_IND_UP, 0}, - {ST_PLCI_NONE, ST_PLCI_INCOMING, EV_PLCI_CONNECT_IND, 0}, - {ST_PLCI_NONE, ST_PLCI_RESUMEING, EV_PLCI_RESUME_REQ, 0}, + {ST_PLCI_NONE, ST_PLCI_OUTGOING, EV_PLCI_CONNECT_REQ, NULL}, + {ST_PLCI_NONE, ST_PLCI_ALLOCATED, EV_PLCI_FACILITY_IND_UP, NULL}, + {ST_PLCI_NONE, ST_PLCI_INCOMING, EV_PLCI_CONNECT_IND, NULL}, + {ST_PLCI_NONE, ST_PLCI_RESUMEING, EV_PLCI_RESUME_REQ, NULL}, /* P-0.1 */ {ST_PLCI_OUTGOING, ST_PLCI_NONE, EV_PLCI_CONNECT_CONF_ERROR, p0}, - {ST_PLCI_OUTGOING, ST_PLCI_ALLOCATED, EV_PLCI_CONNECT_CONF_OK, 0}, + {ST_PLCI_OUTGOING, ST_PLCI_ALLOCATED, EV_PLCI_CONNECT_CONF_OK, NULL}, /* P-1 */ - {ST_PLCI_ALLOCATED, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, 0}, - {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, 0}, - {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, 0}, - {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, 0}, + {ST_PLCI_ALLOCATED, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, + {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, + {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, + {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, /* P-ACT */ - {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, 0}, - {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, 0}, - {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, 0}, - {ST_PLCI_ACTIVE, ST_PLCI_HELD, EV_PLCI_HOLD_IND, 0}, - {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_SUSPEND_IND, 0}, + {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, + {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, + {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, + {ST_PLCI_ACTIVE, ST_PLCI_HELD, EV_PLCI_HOLD_IND, NULL}, + {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_SUSPEND_IND, NULL}, /* P-2 */ - {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, 0}, - {ST_PLCI_INCOMING, ST_PLCI_FACILITY_IND, EV_PLCI_FACILITY_IND_UP, 0}, - {ST_PLCI_INCOMING, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_RESP, 0}, - {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, 0}, - {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, 0}, - {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, 0}, - {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CD_IND, 0}, + {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_FACILITY_IND, EV_PLCI_FACILITY_IND_UP, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_RESP, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CD_IND, NULL}, /* P-3 */ - {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, 0}, - {ST_PLCI_FACILITY_IND, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_ACTIVE_IND, 0}, - {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, 0}, - {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, 0}, - {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, 0}, + {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, NULL}, + {ST_PLCI_FACILITY_IND, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, + {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, + {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, + {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, /* P-4 */ - {ST_PLCI_ACCEPTING, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, 0}, - {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, 0}, - {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, 0}, - {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, 0}, + {ST_PLCI_ACCEPTING, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, + {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, + {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, + {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, /* P-5 */ - {ST_PLCI_DISCONNECTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, 0}, + {ST_PLCI_DISCONNECTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, /* P-6 */ {ST_PLCI_DISCONNECTED, ST_PLCI_NONE, EV_PLCI_DISCONNECT_RESP, p0}, /* P-0.Res */ {ST_PLCI_RESUMEING, ST_PLCI_NONE, EV_PLCI_RESUME_CONF_ERROR, p0}, - {ST_PLCI_RESUMEING, ST_PLCI_RESUME, EV_PLCI_RESUME_CONF_OK, 0}, + {ST_PLCI_RESUMEING, ST_PLCI_RESUME, EV_PLCI_RESUME_CONF_OK, NULL}, /* P-RES */ - {ST_PLCI_RESUME, ST_PLCI_ACTIVE, EV_PLCI_RESUME_IND, 0}, + {ST_PLCI_RESUME, ST_PLCI_ACTIVE, EV_PLCI_RESUME_IND, NULL}, /* P-HELD */ - {ST_PLCI_HELD, ST_PLCI_ACTIVE, EV_PLCI_RETRIEVE_IND, 0}, + {ST_PLCI_HELD, ST_PLCI_ACTIVE, EV_PLCI_RETRIEVE_IND, NULL}, {}, }; @@ -662,10 +662,10 @@ static void n0(capidrv_contr * card, capidrv_ncci * ncci) global.ap.applid, card->msgid++, ncci->plcip->plci, - 0, /* BChannelinformation */ - 0, /* Keypadfacility */ - 0, /* Useruserdata */ /* $$$$ */ - 0 /* Facilitydataarray */ + NULL, /* BChannelinformation */ + NULL, /* Keypadfacility */ + NULL, /* Useruserdata */ /* $$$$ */ + NULL /* Facilitydataarray */ ); send_message(card, &cmsg); plci_change_state(card, ncci->plcip, EV_PLCI_DISCONNECT_REQ); @@ -689,32 +689,32 @@ struct nccistatechange { static struct nccistatechange nccitable[] = { /* N-0 */ - {ST_NCCI_NONE, ST_NCCI_OUTGOING, EV_NCCI_CONNECT_B3_REQ, 0}, - {ST_NCCI_NONE, ST_NCCI_INCOMING, EV_NCCI_CONNECT_B3_IND, 0}, + {ST_NCCI_NONE, ST_NCCI_OUTGOING, EV_NCCI_CONNECT_B3_REQ, NULL}, + {ST_NCCI_NONE, ST_NCCI_INCOMING, EV_NCCI_CONNECT_B3_IND, NULL}, /* N-0.1 */ - {ST_NCCI_OUTGOING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_CONF_OK, 0}, + {ST_NCCI_OUTGOING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_CONF_OK, NULL}, {ST_NCCI_OUTGOING, ST_NCCI_NONE, EV_NCCI_CONNECT_B3_CONF_ERROR, n0}, /* N-1 */ - {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_CONNECT_B3_REJECT, 0}, - {ST_NCCI_INCOMING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_RESP, 0}, - {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, 0}, - {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, 0}, + {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_CONNECT_B3_REJECT, NULL}, + {ST_NCCI_INCOMING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_RESP, NULL}, + {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, + {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, /* N-2 */ - {ST_NCCI_ALLOCATED, ST_NCCI_ACTIVE, EV_NCCI_CONNECT_B3_ACTIVE_IND, 0}, - {ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, 0}, - {ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, 0}, + {ST_NCCI_ALLOCATED, ST_NCCI_ACTIVE, EV_NCCI_CONNECT_B3_ACTIVE_IND, NULL}, + {ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, + {ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, /* N-ACT */ - {ST_NCCI_ACTIVE, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, 0}, - {ST_NCCI_ACTIVE, ST_NCCI_RESETING, EV_NCCI_RESET_B3_REQ, 0}, - {ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, 0}, - {ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, 0}, + {ST_NCCI_ACTIVE, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, NULL}, + {ST_NCCI_ACTIVE, ST_NCCI_RESETING, EV_NCCI_RESET_B3_REQ, NULL}, + {ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, + {ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, /* N-3 */ - {ST_NCCI_RESETING, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, 0}, - {ST_NCCI_RESETING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, 0}, - {ST_NCCI_RESETING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, 0}, + {ST_NCCI_RESETING, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, NULL}, + {ST_NCCI_RESETING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, + {ST_NCCI_RESETING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, /* N-4 */ - {ST_NCCI_DISCONNECTING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, 0}, - {ST_NCCI_DISCONNECTING, ST_NCCI_PREVIOUS, EV_NCCI_DISCONNECT_B3_CONF_ERROR,0}, + {ST_NCCI_DISCONNECTING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, + {ST_NCCI_DISCONNECTING, ST_NCCI_PREVIOUS, EV_NCCI_DISCONNECT_B3_CONF_ERROR,NULL}, /* N-5 */ {ST_NCCI_DISCONNECTED, ST_NCCI_NONE, EV_NCCI_DISCONNECT_B3_RESP, n0}, {}, @@ -821,7 +821,7 @@ static void handle_controller(_cmsg * cmsg) goto ignored; case CAPI_MANUFACTURER_CONF: /* Controller */ if (cmsg->ManuID == 0x214D5641) { - char *s = 0; + char *s = NULL; switch (cmsg->Class) { case 0: break; case 1: s = "unknown class"; break; @@ -950,10 +950,10 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg) global.ap.applid, card->msgid++, plcip->plci, /* adr */ - 0, /* BChannelinformation */ - 0, /* Keypadfacility */ - 0, /* Useruserdata */ - 0 /* Facilitydataarray */ + NULL,/* BChannelinformation */ + NULL,/* Keypadfacility */ + NULL,/* Useruserdata */ + NULL /* Facilitydataarray */ ); plcip->msgid = cmsg->Messagenumber; send_message(card, cmsg); @@ -1090,7 +1090,7 @@ static void handle_plci(_cmsg * cmsg) global.ap.applid, card->msgid++, plcip->plci, /* adr */ - 0 /* NCPI */ + NULL /* NCPI */ ); nccip->msgid = cmsg->Messagenumber; send_message(card, cmsg); @@ -1208,7 +1208,7 @@ static void handle_ncci(_cmsg * cmsg) card->msgid++, nccip->ncci, /* adr */ 0, /* Reject */ - 0 /* NCPI */ + NULL /* NCPI */ ); send_message(card, cmsg); ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_RESP); @@ -1226,7 +1226,7 @@ static void handle_ncci(_cmsg * cmsg) card->msgid++, cmsg->adr.adrNCCI, 2, /* Reject */ - 0 /* NCPI */ + NULL /* NCPI */ ); send_message(card, cmsg); break; @@ -1624,22 +1624,22 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) si2cip(bchan->si1, bchan->si2), /* cipvalue */ called, /* CalledPartyNumber */ calling, /* CallingPartyNumber */ - 0, /* CalledPartySubaddress */ - 0, /* CallingPartySubaddress */ + NULL, /* CalledPartySubaddress */ + NULL, /* CallingPartySubaddress */ b1prot(bchan->l2, bchan->l3), /* B1protocol */ b2prot(bchan->l2, bchan->l3), /* B2protocol */ b3prot(bchan->l2, bchan->l3), /* B3protocol */ b1config(bchan->l2, bchan->l3), /* B1configuration */ - 0, /* B2configuration */ - 0, /* B3configuration */ - 0, /* BC */ - 0, /* LLC */ - 0, /* HLC */ + NULL, /* B2configuration */ + NULL, /* B3configuration */ + NULL, /* BC */ + NULL, /* LLC */ + NULL, /* HLC */ /* BChannelinformation */ - isleasedline ? AdditionalInfo : 0, - 0, /* Keypadfacility */ - 0, /* Useruserdata */ - 0 /* Facilitydataarray */ + isleasedline ? AdditionalInfo : NULL, + NULL, /* Keypadfacility */ + NULL, /* Useruserdata */ + NULL /* Facilitydataarray */ ); if ((plcip = new_plci(card, (c->arg % card->nbchan))) == 0) { cmd.command = ISDN_STAT_DHUP; @@ -1672,15 +1672,15 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) b2prot(bchan->l2, bchan->l3), /* B2protocol */ b3prot(bchan->l2, bchan->l3), /* B3protocol */ b1config(bchan->l2, bchan->l3), /* B1configuration */ - 0, /* B2configuration */ - 0, /* B3configuration */ - 0, /* ConnectedNumber */ - 0, /* ConnectedSubaddress */ - 0, /* LLC */ - 0, /* BChannelinformation */ - 0, /* Keypadfacility */ - 0, /* Useruserdata */ - 0 /* Facilitydataarray */ + NULL, /* B2configuration */ + NULL, /* B3configuration */ + NULL, /* ConnectedNumber */ + NULL, /* ConnectedSubaddress */ + NULL, /* LLC */ + NULL, /* BChannelinformation */ + NULL, /* Keypadfacility */ + NULL, /* Useruserdata */ + NULL /* Facilitydataarray */ ); capi_cmsg2message(&cmdcmsg, cmdcmsg.buf); plci_change_state(card, bchan->plcip, EV_PLCI_CONNECT_RESP); @@ -1714,7 +1714,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) global.ap.applid, card->msgid++, bchan->nccip->ncci, - 0 /* NCPI */ + NULL /* NCPI */ ); ncci_change_state(card, bchan->nccip, EV_NCCI_DISCONNECT_B3_REQ); send_message(card, &cmdcmsg); @@ -1735,10 +1735,10 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) global.ap.applid, card->msgid++, bchan->plcip->plci, - 0, /* BChannelinformation */ - 0, /* Keypadfacility */ - 0, /* Useruserdata */ - 0 /* Facilitydataarray */ + NULL, /* BChannelinformation */ + NULL, /* Keypadfacility */ + NULL, /* Useruserdata */ + NULL /* Facilitydataarray */ ); plci_change_state(card, bchan->plcip, EV_PLCI_DISCONNECT_REQ); send_message(card, &cmdcmsg); @@ -1892,11 +1892,11 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) } } -static int if_readstat(u8 *buf, int len, int user, int id, int channel) +static int if_readstat(u8 __user *buf, int len, int id, int channel) { capidrv_contr *card = findcontrbydriverid(id); int count; - u8 *p; + u8 __user *p; if (!card) { printk(KERN_ERR "capidrv: if_readstat called with invalid driverId %d!\n", @@ -1905,10 +1905,8 @@ static int if_readstat(u8 *buf, int len, int user, int id, int channel) } for (p=buf, count=0; count < len; p++, count++) { - if (user) - put_user(*card->q931_read++, p); - else - *p = *card->q931_read++; + if (put_user(*card->q931_read++, p)) + return -EFAULT; if (card->q931_read > card->q931_end) card->q931_read = card->q931_buf; } @@ -1977,7 +1975,7 @@ static void send_listen(capidrv_contr *card) 1 << 6, /* Infomask */ card->cipmask, card->cipmask2, - 0, 0); + NULL, NULL); send_message(card, &cmdcmsg); listen_change_state(card, EV_LISTEN_REQ); } @@ -2005,18 +2003,17 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) printk(KERN_WARNING "capidrv: (%s) Could not reserve module\n", id); return -1; } - if (!(card = (capidrv_contr *) kmalloc(sizeof(capidrv_contr), GFP_ATOMIC))) { + if (!(card = kzalloc(sizeof(capidrv_contr), GFP_ATOMIC))) { printk(KERN_WARNING "capidrv: (%s) Could not allocate contr-struct.\n", id); return -1; } - memset(card, 0, sizeof(capidrv_contr)); card->owner = THIS_MODULE; init_timer(&card->listentimer); strcpy(card->name, id); card->contrnr = contr; card->nbchan = profp->nbchannel; - card->bchans = (capidrv_bchan *) kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC); + card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC); if (!card->bchans) { printk(KERN_WARNING "capidrv: (%s) Could not allocate bchan-structs.\n", id); @@ -2028,7 +2025,7 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) card->interface.maxbufsize = 2048; card->interface.command = if_command; card->interface.writebuf_skb = if_sendbuf; - card->interface.writecmd = 0; + card->interface.writecmd = NULL; card->interface.readstat = if_readstat; card->interface.features = ISDN_FEATURE_L2_HDLC | ISDN_FEATURE_L2_TRANS | @@ -2059,6 +2056,10 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) return -1; } card->myid = card->interface.channels; + memset(card->bchans, 0, sizeof(capidrv_bchan) * card->nbchan); + for (i = 0; i < card->nbchan; i++) { + card->bchans[i].contr = card; + } spin_lock_irqsave(&global_lock, flags); card->next = global.contr_list; @@ -2066,11 +2067,6 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) global.ncontr++; spin_unlock_irqrestore(&global_lock, flags); - memset(card->bchans, 0, sizeof(capidrv_bchan) * card->nbchan); - for (i = 0; i < card->nbchan; i++) { - card->bchans[i].contr = card; - } - cmd.command = ISDN_STAT_RUN; cmd.driver = card->myid; card->interface.statcallb(&cmd); @@ -2078,10 +2074,9 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) card->cipmask = 0x1FFF03FF; /* any */ card->cipmask2 = 0; - send_listen(card); - card->listentimer.data = (unsigned long)card; card->listentimer.function = listentimerfunc; + send_listen(card); mod_timer(&card->listentimer, jiffies + 60*HZ); printk(KERN_INFO "%s: now up (%d B channels)\n", @@ -2141,7 +2136,7 @@ static int capidrv_delcontr(u16 contr) card->nbchan--; } kfree(card->bchans); - card->bchans = 0; + card->bchans = NULL; if (debugmode) printk(KERN_DEBUG "capidrv-%d: id=%d isdn unload\n", @@ -2159,7 +2154,7 @@ static int capidrv_delcontr(u16 contr) for (pp = &global.contr_list; *pp; pp = &(*pp)->next) { if (*pp == card) { *pp = (*pp)->next; - card->next = 0; + card->next = NULL; global.ncontr--; break; } @@ -2228,7 +2223,7 @@ static void __init proc_init(void) for (i=0; i < nelem; i++) { struct procfsentries *p = procfsentries + i; - p->procent = create_proc_entry(p->name, p->mode, 0); + p->procent = create_proc_entry(p->name, p->mode, NULL); if (p->procent) p->procent->read_proc = p->read_proc; } } @@ -2241,8 +2236,8 @@ static void __exit proc_exit(void) for (i=nelem-1; i >= 0; i--) { struct procfsentries *p = procfsentries + i; if (p->procent) { - remove_proc_entry(p->name, 0); - p->procent = 0; + remove_proc_entry(p->name, NULL); + p->procent = NULL; } } }