Commit 1d1a9e39 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: CAPI: Pass struct capi_appl * instead of index

Now that we have the struct capi_appl *, let's pass this around
instead of just an index which would mean another useless lookup.
parent 10b080a3
...@@ -84,7 +84,7 @@ struct capiminor { ...@@ -84,7 +84,7 @@ struct capiminor {
struct capincci *nccip; struct capincci *nccip;
unsigned int minor; unsigned int minor;
u16 applid; struct capi20_appl *ap;
u32 ncci; u32 ncci;
u16 datahandle; u16 datahandle;
u16 msgid; u16 msgid;
...@@ -207,7 +207,7 @@ static void capiminor_del_all_ack(struct capiminor *mp) ...@@ -207,7 +207,7 @@ static void capiminor_del_all_ack(struct capiminor *mp)
/* -------- struct capiminor ---------------------------------------- */ /* -------- struct capiminor ---------------------------------------- */
static struct capiminor *capiminor_alloc(u16 applid, u32 ncci) static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
{ {
struct capiminor *mp, *p; struct capiminor *mp, *p;
struct list_head *l; struct list_head *l;
...@@ -225,7 +225,7 @@ static struct capiminor *capiminor_alloc(u16 applid, u32 ncci) ...@@ -225,7 +225,7 @@ static struct capiminor *capiminor_alloc(u16 applid, u32 ncci)
printk(KERN_DEBUG "capiminor_alloc %d\n", GET_USE_COUNT(THIS_MODULE)); printk(KERN_DEBUG "capiminor_alloc %d\n", GET_USE_COUNT(THIS_MODULE));
#endif #endif
memset(mp, 0, sizeof(struct capiminor)); memset(mp, 0, sizeof(struct capiminor));
mp->applid = applid; mp->ap = ap;
mp->ncci = ncci; mp->ncci = ncci;
mp->msgid = 0; mp->msgid = 0;
atomic_set(&mp->ttyopencount,0); atomic_set(&mp->ttyopencount,0);
...@@ -309,7 +309,7 @@ static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) ...@@ -309,7 +309,7 @@ static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci)
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
mp = 0; mp = 0;
if (cdev->userflags & CAPIFLAG_HIGHJACKING) if (cdev->userflags & CAPIFLAG_HIGHJACKING)
mp = np->minorp = capiminor_alloc(cdev->ap.applid, ncci); mp = np->minorp = capiminor_alloc(&cdev->ap, ncci);
if (mp) { if (mp) {
mp->nccip = np; mp->nccip = np;
#ifdef _DEBUG_REFCOUNT #ifdef _DEBUG_REFCOUNT
...@@ -423,7 +423,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb) ...@@ -423,7 +423,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
u16 datahandle = CAPIMSG_U16(skb->data,CAPIMSG_BASELEN+4+4+2); u16 datahandle = CAPIMSG_U16(skb->data,CAPIMSG_BASELEN+4+4+2);
unsigned char *s = skb_put(nskb, CAPI_DATA_B3_RESP_LEN); unsigned char *s = skb_put(nskb, CAPI_DATA_B3_RESP_LEN);
capimsg_setu16(s, 0, CAPI_DATA_B3_RESP_LEN); capimsg_setu16(s, 0, CAPI_DATA_B3_RESP_LEN);
capimsg_setu16(s, 2, mp->applid); capimsg_setu16(s, 2, mp->ap->applid);
capimsg_setu8 (s, 4, CAPI_DATA_B3); capimsg_setu8 (s, 4, CAPI_DATA_B3);
capimsg_setu8 (s, 5, CAPI_RESP); capimsg_setu8 (s, 5, CAPI_RESP);
capimsg_setu16(s, 6, mp->msgid++); capimsg_setu16(s, 6, mp->msgid++);
...@@ -463,7 +463,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) ...@@ -463,7 +463,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)
return -1; return -1;
} }
datahandle = CAPIMSG_U16(skb->data,CAPIMSG_BASELEN+4); datahandle = CAPIMSG_U16(skb->data,CAPIMSG_BASELEN+4);
errcode = capi20_put_message(mp->applid, nskb); errcode = capi20_put_message(mp->ap, nskb);
if (errcode != CAPI_NOERROR) { if (errcode != CAPI_NOERROR) {
printk(KERN_ERR "capi: send DATA_B3_RESP failed=%x\n", printk(KERN_ERR "capi: send DATA_B3_RESP failed=%x\n",
errcode); errcode);
...@@ -521,7 +521,7 @@ static int handle_minor_send(struct capiminor *mp) ...@@ -521,7 +521,7 @@ static int handle_minor_send(struct capiminor *mp)
skb_push(skb, CAPI_DATA_B3_REQ_LEN); skb_push(skb, CAPI_DATA_B3_REQ_LEN);
memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN); memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN); capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
capimsg_setu16(skb->data, 2, mp->applid); capimsg_setu16(skb->data, 2, mp->ap->applid);
capimsg_setu8 (skb->data, 4, CAPI_DATA_B3); capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
capimsg_setu8 (skb->data, 5, CAPI_REQ); capimsg_setu8 (skb->data, 5, CAPI_REQ);
capimsg_setu16(skb->data, 6, mp->msgid++); capimsg_setu16(skb->data, 6, mp->msgid++);
...@@ -536,7 +536,7 @@ static int handle_minor_send(struct capiminor *mp) ...@@ -536,7 +536,7 @@ static int handle_minor_send(struct capiminor *mp)
skb_queue_head(&mp->outqueue, skb); skb_queue_head(&mp->outqueue, skb);
return count; return count;
} }
errcode = capi20_put_message(mp->applid, skb); errcode = capi20_put_message(mp->ap, skb);
if (errcode == CAPI_NOERROR) { if (errcode == CAPI_NOERROR) {
mp->datahandle++; mp->datahandle++;
count++; count++;
...@@ -577,14 +577,12 @@ static void capi_signal(u16 applid, void *param) ...@@ -577,14 +577,12 @@ static void capi_signal(u16 applid, void *param)
struct sk_buff *skb = 0; struct sk_buff *skb = 0;
u32 ncci; u32 ncci;
capi20_get_message(applid, &skb); capi20_get_message(&cdev->ap, &skb);
if (!skb) { if (!skb) {
printk(KERN_ERR "BUG: capi_signal: no skb\n"); printk(KERN_ERR "BUG: capi_signal: no skb\n");
return; return;
} }
BUG_ON(cdev->ap.applid != applid);
if (CAPIMSG_COMMAND(skb->data) == CAPI_CONNECT_B3_CONF) { if (CAPIMSG_COMMAND(skb->data) == CAPI_CONNECT_B3_CONF) {
u16 info = CAPIMSG_U16(skb->data, 12); // Info field u16 info = CAPIMSG_U16(skb->data, 12); // Info field
if (info == 0) if (info == 0)
...@@ -747,7 +745,7 @@ capi_write(struct file *file, const char *buf, size_t count, loff_t *ppos) ...@@ -747,7 +745,7 @@ capi_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
} }
cdev->errcode = capi20_put_message(cdev->ap.applid, skb); cdev->errcode = capi20_put_message(&cdev->ap, skb);
if (cdev->errcode) { if (cdev->errcode) {
kfree_skb(skb); kfree_skb(skb);
...@@ -781,28 +779,29 @@ static int ...@@ -781,28 +779,29 @@ static int
capi_ioctl(struct inode *inode, struct file *file, capi_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct capidev *cdev = (struct capidev *)file->private_data; struct capidev *cdev = file->private_data;
struct capi20_appl *ap = &cdev->ap;
capi_ioctl_struct data; capi_ioctl_struct data;
int retval = -EINVAL; int retval = -EINVAL;
switch (cmd) { switch (cmd) {
case CAPI_REGISTER: case CAPI_REGISTER:
{ {
if (cdev->ap.applid) if (ap->applid)
return -EEXIST; return -EEXIST;
if (copy_from_user(&cdev->ap.rparam, (void *) arg, if (copy_from_user(&cdev->ap.rparam, (void *) arg,
sizeof(struct capi_register_params))) sizeof(struct capi_register_params)))
return -EFAULT; return -EFAULT;
cdev->errcode = capi20_register(&cdev->ap); cdev->errcode = capi20_register(ap);
if (cdev->errcode) { if (cdev->errcode) {
cdev->ap.applid = 0; ap->applid = 0;
return -EIO; return -EIO;
} }
capi20_set_signal(cdev->ap.applid, capi_signal, cdev); capi20_set_signal(ap, capi_signal, cdev);
} }
return (int)cdev->ap.applid; return (int)ap->applid;
case CAPI_GET_VERSION: case CAPI_GET_VERSION:
{ {
......
...@@ -518,7 +518,7 @@ static void send_message(capidrv_contr * card, _cmsg * cmsg) ...@@ -518,7 +518,7 @@ static void send_message(capidrv_contr * card, _cmsg * cmsg)
len = CAPIMSG_LEN(cmsg->buf); len = CAPIMSG_LEN(cmsg->buf);
skb = alloc_skb(len, GFP_ATOMIC); skb = alloc_skb(len, GFP_ATOMIC);
memcpy(skb_put(skb, len), cmsg->buf, len); memcpy(skb_put(skb, len), cmsg->buf, len);
capi20_put_message(global.ap.applid, skb); capi20_put_message(&global.ap, skb);
global.nsentctlpkt++; global.nsentctlpkt++;
} }
...@@ -1376,7 +1376,7 @@ static void capidrv_signal(u16 applid, void *dummy) ...@@ -1376,7 +1376,7 @@ static void capidrv_signal(u16 applid, void *dummy)
{ {
struct sk_buff *skb = 0; struct sk_buff *skb = 0;
while (capi20_get_message(global.ap.applid, &skb) == CAPI_NOERROR) { while (capi20_get_message(&global.ap, &skb) == CAPI_NOERROR) {
capi_message2cmsg(&s_cmsg, skb->data); capi_message2cmsg(&s_cmsg, skb->data);
if (debugmode > 2) if (debugmode > 2)
printk(KERN_DEBUG "capidrv_signal: applid=%d %s\n", printk(KERN_DEBUG "capidrv_signal: applid=%d %s\n",
...@@ -1912,7 +1912,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) ...@@ -1912,7 +1912,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)
printk(KERN_DEBUG "capidrv-%d: only %d bytes headroom, need %d\n", printk(KERN_DEBUG "capidrv-%d: only %d bytes headroom, need %d\n",
card->contrnr, skb_headroom(skb), msglen); card->contrnr, skb_headroom(skb), msglen);
memcpy(skb_push(nskb, msglen), sendcmsg.buf, msglen); memcpy(skb_push(nskb, msglen), sendcmsg.buf, msglen);
errcode = capi20_put_message(global.ap.applid, nskb); errcode = capi20_put_message(&global.ap, nskb);
if (errcode == CAPI_NOERROR) { if (errcode == CAPI_NOERROR) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
nccip->datahandle++; nccip->datahandle++;
...@@ -1924,7 +1924,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) ...@@ -1924,7 +1924,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)
return errcode == CAPI_SENDQUEUEFULL ? 0 : -1; return errcode == CAPI_SENDQUEUEFULL ? 0 : -1;
} else { } else {
memcpy(skb_push(skb, msglen), sendcmsg.buf, msglen); memcpy(skb_push(skb, msglen), sendcmsg.buf, msglen);
errcode = capi20_put_message(global.ap.applid, skb); errcode = capi20_put_message(&global.ap, skb);
if (errcode == CAPI_NOERROR) { if (errcode == CAPI_NOERROR) {
nccip->datahandle++; nccip->datahandle++;
global.nsentdatapkt++; global.nsentdatapkt++;
...@@ -2319,7 +2319,7 @@ static int __init capidrv_init(void) ...@@ -2319,7 +2319,7 @@ static int __init capidrv_init(void)
return -EIO; return -EIO;
} }
capi20_set_callback(global.ap.applid, lower_callback); capi20_set_callback(&global.ap, lower_callback);
errcode = capi20_get_profile(0, &profile); errcode = capi20_get_profile(0, &profile);
if (errcode != CAPI_NOERROR) { if (errcode != CAPI_NOERROR) {
...@@ -2328,7 +2328,7 @@ static int __init capidrv_init(void) ...@@ -2328,7 +2328,7 @@ static int __init capidrv_init(void)
return -EIO; return -EIO;
} }
capi20_set_signal(global.ap.applid, capidrv_signal, 0); capi20_set_signal(&global.ap, capidrv_signal, 0);
ncontr = profile.ncontroller; ncontr = profile.ncontroller;
for (contr = 1; contr <= ncontr; contr++) { for (contr = 1; contr <= ncontr; contr++) {
......
...@@ -912,19 +912,17 @@ u16 capi20_release(struct capi20_appl *ap) ...@@ -912,19 +912,17 @@ u16 capi20_release(struct capi20_appl *ap)
EXPORT_SYMBOL(capi20_release); EXPORT_SYMBOL(capi20_release);
u16 capi20_put_message(u16 applid, struct sk_buff *skb) u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb)
{ {
struct capi_ctr *card; struct capi_ctr *card;
struct capi20_appl *ap;
int showctl = 0; int showctl = 0;
u8 cmd, subcmd; u8 cmd, subcmd;
DBG("applid %#x", applid); DBG("applid %#x", ap->applid);
if (ncards == 0) if (ncards == 0)
return CAPI_REGNOTINSTALLED; return CAPI_REGNOTINSTALLED;
ap = get_capi_appl_by_nr(applid); if (ap->applid == 0)
if (!ap)
return CAPI_ILLAPPNR; return CAPI_ILLAPPNR;
if (skb->len < 12 if (skb->len < 12
|| !capi_cmd_valid(CAPIMSG_COMMAND(skb->data)) || !capi_cmd_valid(CAPIMSG_COMMAND(skb->data))
...@@ -971,12 +969,11 @@ u16 capi20_put_message(u16 applid, struct sk_buff *skb) ...@@ -971,12 +969,11 @@ u16 capi20_put_message(u16 applid, struct sk_buff *skb)
EXPORT_SYMBOL(capi20_put_message); EXPORT_SYMBOL(capi20_put_message);
u16 capi20_get_message(u16 applid, struct sk_buff **msgp) u16 capi20_get_message(struct capi20_appl *ap, struct sk_buff **msgp)
{ {
struct capi20_appl *ap = get_capi_appl_by_nr(applid);
struct sk_buff *skb; struct sk_buff *skb;
if (!ap) if (ap->applid == 0)
return CAPI_ILLAPPNR; return CAPI_ILLAPPNR;
if ((skb = skb_dequeue(&ap->recv_queue)) == 0) if ((skb = skb_dequeue(&ap->recv_queue)) == 0)
return CAPI_RECEIVEQUEUEEMPTY; return CAPI_RECEIVEQUEUEEMPTY;
...@@ -986,13 +983,11 @@ u16 capi20_get_message(u16 applid, struct sk_buff **msgp) ...@@ -986,13 +983,11 @@ u16 capi20_get_message(u16 applid, struct sk_buff **msgp)
EXPORT_SYMBOL(capi20_get_message); EXPORT_SYMBOL(capi20_get_message);
u16 capi20_set_signal(u16 applid, u16 capi20_set_signal(struct capi20_appl *ap,
void (*signal) (u16 applid, void *param), void (*signal) (u16 applid, void *param),
void *param) void *param)
{ {
struct capi20_appl *ap = get_capi_appl_by_nr(applid); if (ap->applid == 0)
if (!ap)
return CAPI_ILLAPPNR; return CAPI_ILLAPPNR;
ap->signal = signal; ap->signal = signal;
ap->param = param; ap->param = param;
...@@ -1258,10 +1253,9 @@ int capi20_manufacturer(unsigned int cmd, void *data) ...@@ -1258,10 +1253,9 @@ int capi20_manufacturer(unsigned int cmd, void *data)
EXPORT_SYMBOL(capi20_manufacturer); EXPORT_SYMBOL(capi20_manufacturer);
/* temporary hack */ /* temporary hack */
void capi20_set_callback(u16 applid, void (*callback) (unsigned int cmd, __u32 contr, void *data)) void capi20_set_callback(struct capi20_appl *ap,
void (*callback) (unsigned int cmd, __u32 contr, void *data))
{ {
struct capi20_appl *ap = get_capi_appl_by_nr(applid);
ap->callback = callback; ap->callback = callback;
} }
......
...@@ -77,9 +77,9 @@ struct capi20_appl { ...@@ -77,9 +77,9 @@ struct capi20_appl {
u16 capi20_isinstalled(void); u16 capi20_isinstalled(void);
u16 capi20_register(struct capi20_appl *ap); u16 capi20_register(struct capi20_appl *ap);
u16 capi20_release(struct capi20_appl *ap); u16 capi20_release(struct capi20_appl *ap);
u16 capi20_put_message(u16 applid, struct sk_buff *skb); u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb);
u16 capi20_get_message(u16 applid, struct sk_buff **msgp); u16 capi20_get_message(struct capi20_appl *ap, struct sk_buff **msgp);
u16 capi20_set_signal(u16 applid, u16 capi20_set_signal(struct capi20_appl *ap,
void (*signal) (u16 applid, void *param), void (*signal) (u16 applid, void *param),
void *param); void *param);
u16 capi20_get_manufacturer(u32 contr, u8 buf[CAPI_MANUFACTURER_LEN]); u16 capi20_get_manufacturer(u32 contr, u8 buf[CAPI_MANUFACTURER_LEN]);
...@@ -89,7 +89,8 @@ u16 capi20_get_profile(u32 contr, struct capi_profile *profp); ...@@ -89,7 +89,8 @@ u16 capi20_get_profile(u32 contr, struct capi_profile *profp);
int capi20_manufacturer(unsigned int cmd, void *data); int capi20_manufacturer(unsigned int cmd, void *data);
/* temporary hack XXX */ /* temporary hack XXX */
void capi20_set_callback(u16 applid, void (*callback) (unsigned int cmd, __u32 contr, void *data)); void capi20_set_callback(struct capi20_appl *ap,
void (*callback) (unsigned int cmd, __u32 contr, void *data));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment