Commit b5919c97 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/CAPI: Export callbacks for CAPI drivers directly

They're always the same, so no point in using function pointers.
parent 2b8fd805
......@@ -324,8 +324,7 @@ static void recv_handler(void *dummy)
}
}
static void controllercb_handle_capimsg(struct capi_ctr * card,
u16 appl, struct sk_buff *skb)
void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *skb)
{
int showctl = 0;
u8 cmd, subcmd;
......@@ -368,7 +367,9 @@ static void controllercb_handle_capimsg(struct capi_ctr * card,
kfree_skb(skb);
}
static void controllercb_ready(struct capi_ctr * card)
EXPORT_SYMBOL(capi_ctr_handle_message);
void capi_ctr_ready(struct capi_ctr * card)
{
u16 appl;
struct capi20_appl *ap;
......@@ -387,7 +388,9 @@ static void controllercb_ready(struct capi_ctr * card)
notify_push(KCI_CONTRUP, card->cnr, 0, 0);
}
static void controllercb_reseted(struct capi_ctr * card)
EXPORT_SYMBOL(capi_ctr_ready);
void capi_ctr_reseted(struct capi_ctr * card)
{
u16 appl;
......@@ -416,7 +419,9 @@ static void controllercb_reseted(struct capi_ctr * card)
notify_push(KCI_CONTRDOWN, card->cnr, 0, 0);
}
static void controllercb_suspend_output(struct capi_ctr *card)
EXPORT_SYMBOL(capi_ctr_reseted);
void capi_ctr_suspend_output(struct capi_ctr *card)
{
if (!card->blocked) {
printk(KERN_DEBUG "kcapi: card %d suspend\n", card->cnr);
......@@ -424,7 +429,9 @@ static void controllercb_suspend_output(struct capi_ctr *card)
}
}
static void controllercb_resume_output(struct capi_ctr *card)
EXPORT_SYMBOL(capi_ctr_suspend_output);
void capi_ctr_resume_output(struct capi_ctr *card)
{
if (card->blocked) {
printk(KERN_DEBUG "kcapi: card %d resume\n", card->cnr);
......@@ -432,6 +439,8 @@ static void controllercb_resume_output(struct capi_ctr *card)
}
}
EXPORT_SYMBOL(capi_ctr_resume_output);
/* ------------------------------------------------------------- */
int
......@@ -458,12 +467,6 @@ attach_capi_ctr(struct capi_ctr *card)
card->blocked = 0;
card->traceflag = showcapimsgs;
card->ready = controllercb_ready;
card->reseted = controllercb_reseted;
card->suspend_output = controllercb_suspend_output;
card->resume_output = controllercb_resume_output;
card->handle_capimsg = controllercb_handle_capimsg;
sprintf(card->procfn, "capi/controllers/%d", card->cnr);
card->procent = create_proc_entry(card->procfn, 0, 0);
if (card->procent) {
......@@ -484,9 +487,8 @@ EXPORT_SYMBOL(attach_capi_ctr);
int detach_capi_ctr(struct capi_ctr *card)
{
if (card->cardstate != CARD_DETECTED)
controllercb_reseted(card);
capi_ctr_reseted(card);
list_del(&card->driver_list);
ncards--;
if (card->procent) {
......@@ -496,7 +498,6 @@ int detach_capi_ctr(struct capi_ctr *card)
capi_cards[card->cnr - 1] = NULL;
printk(KERN_NOTICE "kcapi: Controller %d: %s unregistered\n",
card->cnr, card->name);
kfree(card);
return 0;
}
......
......@@ -330,7 +330,7 @@ void b1_reset_ctr(struct capi_ctr *ctrl)
memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl);
capi_ctr_reseted(ctrl);
}
void b1_register_appl(struct capi_ctr *ctrl,
......@@ -529,7 +529,7 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
} else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -547,7 +547,7 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -573,11 +573,11 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
case RECEIVE_START:
/* b1_put_byte(card->port, SEND_POLLACK); */
ctrl->resume_output(ctrl);
capi_ctr_resume_output(ctrl);
break;
case RECEIVE_STOP:
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
break;
case RECEIVE_INIT:
......@@ -588,7 +588,7 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
card->name,
cinfo->version[VER_CARDTYPE],
cinfo->version[VER_DRIVER]);
ctrl->ready(ctrl);
capi_ctr_ready(ctrl);
break;
case RECEIVE_TASK_READY:
......
......@@ -475,7 +475,7 @@ static void b1dma_handle_rx(avmcard *card)
} else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -493,7 +493,7 @@ static void b1dma_handle_rx(avmcard *card)
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -523,11 +523,11 @@ static void b1dma_handle_rx(avmcard *card)
#endif
if (!suppress_pollack)
queue_pollack(card);
ctrl->resume_output(ctrl);
capi_ctr_resume_output(ctrl);
break;
case RECEIVE_STOP:
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
break;
case RECEIVE_INIT:
......@@ -538,7 +538,7 @@ static void b1dma_handle_rx(avmcard *card)
card->name,
cinfo->version[VER_CARDTYPE],
cinfo->version[VER_DRIVER]);
ctrl->ready(ctrl);
capi_ctr_ready(ctrl);
break;
case RECEIVE_TASK_READY:
......@@ -740,7 +740,7 @@ void b1dma_reset_ctr(struct capi_ctr *ctrl)
memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl);
capi_ctr_reseted(ctrl);
}
......
......@@ -534,7 +534,7 @@ static void c4_handle_rx(avmcard *card)
} else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -557,7 +557,7 @@ static void c4_handle_rx(avmcard *card)
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -593,16 +593,14 @@ static void c4_handle_rx(avmcard *card)
queue_pollack(card);
for (cidx=0; cidx < card->nr_controllers; cidx++) {
ctrl = &card->ctrlinfo[cidx].capi_ctrl;
if (ctrl)
ctrl->resume_output(ctrl);
capi_ctr_resume_output(ctrl);
}
break;
case RECEIVE_STOP:
for (cidx=0; cidx < card->nr_controllers; cidx++) {
ctrl = &card->ctrlinfo[cidx].capi_ctrl;
if (ctrl)
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
}
break;
......@@ -623,7 +621,7 @@ static void c4_handle_rx(avmcard *card)
card->name,
cinfo->version[VER_CARDTYPE],
cinfo->version[VER_DRIVER]);
ctrl->ready(&cinfo->capi_ctrl);
capi_ctr_ready(&cinfo->capi_ctrl);
break;
case RECEIVE_TASK_READY:
......@@ -675,7 +673,7 @@ static void c4_handle_interrupt(avmcard *card)
avmctrl_info *cinfo = &card->ctrlinfo[i];
memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
cinfo->capi_ctrl.reseted(&cinfo->capi_ctrl);
capi_ctr_reseted(&cinfo->capi_ctrl);
}
card->nlogcontr = 0;
return;
......@@ -888,7 +886,7 @@ void c4_reset_ctr(struct capi_ctr *ctrl)
for (i=0; i < card->nr_controllers; i++) {
cinfo = &card->ctrlinfo[i];
memset(cinfo->version, 0, sizeof(cinfo->version));
cinfo->capi_ctrl.reseted(&cinfo->capi_ctrl);
capi_ctr_reseted(&cinfo->capi_ctrl);
}
card->nlogcontr = 0;
}
......
......@@ -161,7 +161,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
} else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -179,7 +179,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
break;
......@@ -205,11 +205,11 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
case RECEIVE_START:
b1_put_byte(card->port, SEND_POLLACK);
ctrl->resume_output(ctrl);
capi_ctr_resume_output(ctrl);
break;
case RECEIVE_STOP:
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
break;
case RECEIVE_INIT:
......@@ -220,7 +220,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
card->name,
cinfo->version[VER_CARDTYPE],
cinfo->version[VER_DRIVER]);
ctrl->ready(ctrl);
capi_ctr_ready(ctrl);
break;
case RECEIVE_TASK_READY:
......@@ -319,7 +319,7 @@ void t1isa_reset_ctr(struct capi_ctr *ctrl)
memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl);
capi_ctr_reseted(ctrl);
}
static void t1isa_remove(struct pci_dev *pdev)
......
......@@ -53,8 +53,6 @@ static inline int _hycapi_appCheck(int app_id, int ctrl_no)
return ((hycapi_applications[app_id-1].ctrl_mask & (1 << (ctrl_no-1))) != 0);
}
struct capi_driver_interface *hy_di = NULL;
/******************************
Kernel-Capi callback reset_ctr
******************************/
......@@ -68,7 +66,7 @@ hycapi_reset_ctr(struct capi_ctr *ctrl)
printk(KERN_NOTICE "HYCAPI hycapi_reset_ctr\n");
#endif
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl);
capi_ctr_reseted(ctrl);
}
/******************************
......@@ -94,7 +92,7 @@ hycapi_remove_ctr(struct capi_ctr *ctrl)
return;
}
card = cinfo->card;
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
for(i=0; i<CAPI_MAXAPPL;i++) {
if(hycapi_applications[i].listen_req[ctrl->cnr-1]) {
kfree_skb(hycapi_applications[i].listen_req[ctrl->cnr-1]);
......@@ -133,7 +131,7 @@ hycapi_sendmsg_internal(struct capi_ctr *ctrl, struct sk_buff *skb)
/* inform upper layers we're full */
printk(KERN_ERR "HYSDN Card%d: CAPI-buffer overrun!\n",
card->myid);
ctrl->suspend_output(ctrl);
capi_ctr_suspend_output(ctrl);
}
cinfo->tx_skb = skb;
spin_unlock_irq(&cinfo->lock);
......@@ -334,7 +332,7 @@ int hycapi_capi_release(hysdn_card *card)
printk(KERN_NOTICE "hycapi_capi_release\n");
#endif
if(cinfo) {
ctrl = cinfo->capi_ctrl;
ctrl = &cinfo->capi_ctrl;
hycapi_remove_ctr(ctrl);
}
return 0;
......@@ -354,14 +352,9 @@ int hycapi_capi_stop(hysdn_card *card)
printk(KERN_NOTICE "hycapi_capi_stop\n");
#endif
if(cinfo) {
if(cinfo->capi_ctrl) {
ctrl = cinfo->capi_ctrl;
/* ctrl->suspend_output(ctrl); */
ctrl->reseted(ctrl);
} else {
printk(KERN_NOTICE "hycapi_capi_stop: cinfo but no capi_ctrl\n");
}
ctrl = &cinfo->capi_ctrl;
/* ctrl->suspend_output(ctrl); */
capi_ctr_reseted(ctrl);
}
return 0;
}
......@@ -552,11 +545,7 @@ hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len)
if(!cinfo) {
return;
}
ctrl = cinfo->capi_ctrl;
if(!ctrl)
{
return;
}
ctrl = &cinfo->capi_ctrl;
if(len < CAPI_MSG_BASELEN) {
printk(KERN_ERR "HYSDN Card%d: invalid CAPI-message, lenght %d!\n",
card->myid, len);
......@@ -635,7 +624,7 @@ hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len)
default:
break;
}
ctrl->handle_capimsg(ctrl, ApplId, skb);
capi_ctr_handle_message(ctrl, ApplId, skb);
}
/******************************************************************
......@@ -662,7 +651,7 @@ void hycapi_tx_capiack(hysdn_card * card)
cinfo->out_idx = 0; /* wrap around */
if (cinfo->sk_count-- == HYSDN_MAX_CAPI_SKB) /* dec usage count */
cinfo->capi_ctrl->resume_output(cinfo->capi_ctrl);
capi_ctr_resume_output(&cinfo->capi_ctrl);
spin_unlock_irq(&cinfo->lock);
}
......@@ -687,21 +676,6 @@ hycapi_tx_capiget(hysdn_card *card)
}
static struct capi_driver hycapi_driver = {
owner: THIS_MODULE,
name: "hysdn",
revision: "0.0",
load_firmware: hycapi_load_firmware,
reset_ctr: hycapi_reset_ctr,
register_appl: hycapi_register_appl,
release_appl: hycapi_release_appl,
send_message: hycapi_send_message,
procinfo: hycapi_procinfo,
ctr_read_proc: hycapi_read_proc,
};
/**********************************************************
int hycapi_init()
......@@ -711,16 +685,11 @@ attach the capi-driver to the kernel-capi.
int hycapi_init()
{
struct capi_driver *driver;
int i;
if(hy_di) {
printk(KERN_NOTICE "HyDI allready set\n");
return 0;
}
driver = &hycapi_driver;
printk(KERN_NOTICE "HYSDN: Attaching capi-driver\n");
attach_capi_driver(driver);
for(i=0;i<CAPI_MAXAPPL;i++) {
memset(&(hycapi_applications[i]), 0, sizeof(hycapi_appl));
}
......@@ -737,16 +706,6 @@ free some more ressources. Do that later.
void
hycapi_cleanup(void)
{
struct capi_driver *driver;
driver = &hycapi_driver;
if (!hy_di) {
printk(KERN_ERR "HYSDN: no capi-driver to detach (?)\n");
return;
}
printk(KERN_NOTICE "HYSDN: Detaching capi-driver\n");
detach_capi_driver(driver);
hy_di = 0;
return;
}
/********************************************************************
......@@ -761,8 +720,7 @@ static void hycapi_fill_profile(hysdn_card *card)
struct capi_ctr *ctrl = NULL;
cinfo = card->hyctrlinfo;
if(!cinfo) return;
ctrl = cinfo->capi_ctrl;
if(!ctrl) return;
ctrl = &cinfo->capi_ctrl;
strcpy(ctrl->manu, "Hypercope");
ctrl->version.majorversion = 2;
ctrl->version.minorversion = 0;
......@@ -790,6 +748,7 @@ hycapi_capi_create(hysdn_card *card)
{
hycapictrl_info *cinfo = NULL;
struct capi_ctr *ctrl = NULL;
int retval;
#ifdef HYCAPI_PRINTFNAMES
printk(KERN_NOTICE "hycapi_capi_create\n");
#endif
......@@ -817,28 +776,34 @@ hycapi_capi_create(hysdn_card *card)
default: strcpy(cinfo->cardname,"HYSDN ???"); break;
}
cinfo->capi_ctrl = attach_capi_ctr(&hycapi_driver,
cinfo->cardname, cinfo);
ctrl = cinfo->capi_ctrl;
if (!ctrl) {
printk(KERN_ERR "%s: attach controller failed.\n",
hycapi_driver.name);
ctrl = &cinfo->capi_ctrl;
ctrl->driver_name = "hycapi";
ctrl->driverdata = cinfo;
ctrl->register_appl = hycapi_register_appl;
ctrl->release_appl = hycapi_release_appl;
ctrl->send_message = hycapi_send_message;
ctrl->load_firmware = hycapi_load_firmware;
ctrl->reset_ctr = hycapi_reset_ctr;
ctrl->procinfo = hycapi_procinfo;
ctrl->ctr_read_proc = hycapi_read_proc;
strcpy(ctrl->name, cinfo->cardname);
SET_MODULE_OWNER(ctrl);
retval = attach_capi_ctr(ctrl);
if (retval) {
printk(KERN_ERR "hycapi: attach controller failed.\n");
return -EBUSY;
}
/* fill in the blanks: */
hycapi_fill_profile(card);
ctrl->ready(ctrl);
capi_ctr_ready(ctrl);
} else {
/* resume output on stopped ctrl */
ctrl = card->hyctrlinfo->capi_ctrl;
if(ctrl) {
hycapi_fill_profile(card);
ctrl->ready(ctrl);
hycapi_restart_internal(ctrl);
/* ctrl->resume_output(ctrl); */
} else {
printk(KERN_WARNING "HYSDN: No ctrl???? How come?\n");
}
ctrl = &card->hyctrlinfo->capi_ctrl;
hycapi_fill_profile(card);
capi_ctr_ready(ctrl);
hycapi_restart_internal(ctrl);
/* ctrl->resume_output(ctrl); */
}
return 0;
}
......@@ -208,7 +208,7 @@ typedef struct HYSDN_CARD {
char infobuf[128]; /* for function procinfo */
struct HYSDN_CARD *card;
struct capi_ctr *capi_ctrl;
struct capi_ctr capi_ctrl;
struct sk_buff *skbs[HYSDN_MAX_CAPI_SKB];
int in_idx, out_idx; /* indexes to buffer ring */
int sk_count; /* number of buffers currently in ring */
......
......@@ -59,14 +59,6 @@ struct capi_ctr {
capi_profile profile; /* CAPI_GET_PROFILE */
u8 serial[CAPI_SERIAL_LEN]; /* CAPI_GET_SERIAL */
/* functions */
void (*ready)(struct capi_ctr * card);
void (*reseted)(struct capi_ctr * card);
void (*suspend_output)(struct capi_ctr * card);
void (*resume_output)(struct capi_ctr * card);
void (*handle_capimsg)(struct capi_ctr * card,
u16 appl, struct sk_buff *skb);
/* management information for kcapi */
unsigned long nrecvctlpkt;
......@@ -74,7 +66,6 @@ struct capi_ctr {
unsigned long nsentctlpkt;
unsigned long nsentdatapkt;
struct list_head driver_list; /* contrs by driver */
int cnr; /* controller number */
volatile unsigned short cardstate; /* controller state */
volatile int blocked; /* output blocked */
......@@ -87,7 +78,11 @@ struct capi_ctr {
int attach_capi_ctr(struct capi_ctr *);
int detach_capi_ctr(struct capi_ctr *);
void capi_ctr_ready(struct capi_ctr * card);
void capi_ctr_reseted(struct capi_ctr * card);
void capi_ctr_suspend_output(struct capi_ctr * card);
void capi_ctr_resume_output(struct capi_ctr * card);
void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *skb);
// ---------------------------------------------------------------------------
// library functions for use by hardware controller drivers
......
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