Commit 83bc4e5e authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: CAPI cleanup: register/release

Introduce register_appl() / release_appl() which are basically equivalent 
to open()/close() for net_device's.

Remove the registered() / released() callbacks and do the work immediately
instead.
parent 702d27c7
......@@ -72,7 +72,6 @@ struct capi_ncci {
struct capi_appl {
u16 applid;
capi_register_params rparam;
int releasing;
void *param;
void (*signal) (u16 applid, void *param);
struct sk_buff_head recv_queue;
......@@ -470,6 +469,35 @@ static void proc_capi_exit(void)
}
}
/* ------------------------------------------------------------ */
static void register_appl(struct capi_ctr *card, u16 applid, capi_register_params *rparam)
{
card->driver->register_appl(card, applid, rparam);
}
static void release_appl(struct capi_ctr *card, u16 applid)
{
struct capi_ncci **pp, **nextpp;
for (pp = &APPL(applid)->nccilist; *pp; pp = nextpp) {
if (NCCI2CTRL((*pp)->ncci) == card->cnr) {
struct capi_ncci *np = *pp;
*pp = np->next;
printk(KERN_INFO "kcapi: appl %d ncci 0x%x down!\n", applid, np->ncci);
kfree(np);
APPL(applid)->nncci--;
nextpp = pp;
} else {
nextpp = &(*pp)->next;
}
}
card->driver->release_appl(card, applid);
}
/* -------- Notifier handling --------------------------------- */
static struct capi_notifier_list{
......@@ -685,32 +713,6 @@ static inline int mq_dequeue(struct capi_ncci * np, u16 msgid)
return 0;
}
static void controllercb_appl_registered(struct capi_ctr * card, u16 appl)
{
}
static void controllercb_appl_released(struct capi_ctr * card, u16 appl)
{
struct capi_ncci **pp, **nextpp;
for (pp = &APPL(appl)->nccilist; *pp; pp = nextpp) {
if (NCCI2CTRL((*pp)->ncci) == card->cnr) {
struct capi_ncci *np = *pp;
*pp = np->next;
printk(KERN_INFO "kcapi: appl %d ncci 0x%x down!\n", appl, np->ncci);
kfree(np);
APPL(appl)->nncci--;
nextpp = pp;
} else {
nextpp = &(*pp)->next;
}
}
APPL(appl)->releasing--;
if (APPL(appl)->releasing <= 0) {
APPL(appl)->signal = 0;
APPL_MARK_FREE(appl);
printk(KERN_INFO "kcapi: appl %d down\n", appl);
}
}
/*
* ncci management
*/
......@@ -868,8 +870,7 @@ static void controllercb_ready(struct capi_ctr * card)
for (appl = 1; appl <= CAPI_MAXAPPL; appl++) {
if (!VALID_APPLID(appl)) continue;
if (APPL(appl)->releasing) continue;
card->driver->register_appl(card, appl, &APPL(appl)->rparam);
register_appl(card, appl, &APPL(appl)->rparam);
}
printk(KERN_NOTICE "kcapi: card %d \"%s\" ready.\n",
......@@ -961,8 +962,6 @@ drivercb_attach_ctr(struct capi_driver *driver, char *name, void *driverdata)
card->suspend_output = controllercb_suspend_output;
card->resume_output = controllercb_resume_output;
card->handle_capimsg = controllercb_handle_capimsg;
card->appl_registered = controllercb_appl_registered;
card->appl_released = controllercb_appl_released;
card->new_ncci = controllercb_new_ncci;
card->free_ncci = controllercb_free_ncci;
......@@ -1122,8 +1121,7 @@ static u16 capi_register(capi_register_params * rparam, u16 * applidp)
for (i = 0; i < CAPI_MAXCONTR; i++) {
if (cards[i].cardstate != CARD_RUNNING)
continue;
cards[i].driver->register_appl(&cards[i], appl,
&APPL(appl)->rparam);
register_appl(&cards[i], appl, &APPL(appl)->rparam);
}
*applidp = appl;
printk(KERN_INFO "kcapi: appl %d up\n", appl);
......@@ -1135,22 +1133,18 @@ static u16 capi_release(u16 applid)
{
int i;
if (!VALID_APPLID(applid) || APPL(applid)->releasing)
if (!VALID_APPLID(applid))
return CAPI_ILLAPPNR;
APPL(applid)->releasing++;
skb_queue_purge(&APPL(applid)->recv_queue);
for (i = 0; i < CAPI_MAXCONTR; i++) {
if (cards[i].cardstate != CARD_RUNNING)
continue;
APPL(applid)->releasing++;
cards[i].driver->release_appl(&cards[i], applid);
}
APPL(applid)->releasing--;
if (APPL(applid)->releasing <= 0) {
APPL(applid)->signal = 0;
APPL_MARK_FREE(applid);
printk(KERN_INFO "kcapi: appl %d down\n", applid);
release_appl(&cards[i], applid);
}
APPL(applid)->signal = 0;
APPL_MARK_FREE(applid);
printk(KERN_INFO "kcapi: appl %d down\n", applid);
return CAPI_NOERROR;
}
......
......@@ -357,8 +357,6 @@ void b1_register_appl(struct capi_ctr *ctrl,
b1_put_word(port, rp->datablkcnt);
b1_put_word(port, rp->datablklen);
restore_flags(flags);
ctrl->appl_registered(ctrl, appl);
}
void b1_release_appl(struct capi_ctr *ctrl, u16 appl)
......@@ -548,7 +546,7 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
if (NCCI != 0xffffffff)
ctrl->free_ncci(ctrl, ApplId, NCCI);
else ctrl->appl_released(ctrl, ApplId);
break;
case RECEIVE_START:
......
......@@ -509,7 +509,7 @@ static void b1dma_handle_rx(avmcard *card)
if (NCCI != 0xffffffff)
ctrl->free_ncci(ctrl, ApplId, NCCI);
else ctrl->appl_released(ctrl, ApplId);
break;
case RECEIVE_START:
......@@ -774,8 +774,6 @@ void b1dma_register_appl(struct capi_ctr *ctrl,
skb_put(skb, (u8 *)p - (u8 *)skb->data);
b1dma_queue_tx(card, skb);
ctrl->appl_registered(ctrl, appl);
}
/* ------------------------------------------------------------- */
......
......@@ -587,12 +587,6 @@ static void c4_handle_rx(avmcard *card)
ctrl = card->ctrlinfo[cidx].capi_ctrl;
if (ctrl)
ctrl->free_ncci(ctrl, ApplId, NCCI);
} else {
for (cidx=0; cidx < 4; cidx++) {
ctrl = card->ctrlinfo[cidx].capi_ctrl;
if (ctrl)
ctrl->appl_released(ctrl, ApplId);
}
}
break;
......@@ -973,8 +967,6 @@ void c4_register_appl(struct capi_ctr *ctrl,
skb_queue_tail(&card->dma->send_queue, skb);
c4_dispatch_tx(card);
}
ctrl->appl_registered(ctrl, appl);
}
/* ------------------------------------------------------------- */
......
......@@ -199,7 +199,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
if (NCCI != 0xffffffff)
ctrl->free_ncci(ctrl, ApplId, NCCI);
else ctrl->appl_released(ctrl, ApplId);
break;
case RECEIVE_START:
......
......@@ -57,8 +57,6 @@ struct capi_ctr {
void (*resume_output)(struct capi_ctr * card);
void (*handle_capimsg)(struct capi_ctr * card,
__u16 appl, struct sk_buff *skb);
void (*appl_registered)(struct capi_ctr * card, __u16 appl);
void (*appl_released)(struct capi_ctr * card, __u16 appl);
void (*new_ncci)(struct capi_ctr * card,
__u16 appl, __u32 ncci, __u32 winsize);
......
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