Commit 7bb73f7b authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: export callbacks directly

Just EXPORT_SYMBOL() the callbacks, instead of passing them to the
drivers in a struct.
parent e9123b30
......@@ -980,7 +980,7 @@ static void controllercb_resume_output(struct capi_ctr *card)
struct capi_ctr *
drivercb_attach_ctr(struct capi_driver *driver, char *name, void *driverdata)
attach_capi_ctr(struct capi_driver *driver, char *name, void *driverdata)
{
struct capi_ctr *card;
int i;
......@@ -1026,7 +1026,9 @@ drivercb_attach_ctr(struct capi_driver *driver, char *name, void *driverdata)
return card;
}
static int drivercb_detach_ctr(struct capi_ctr *card)
EXPORT_SYMBOL(attach_capi_ctr);
int detach_capi_ctr(struct capi_ctr *card)
{
struct capi_driver *driver = card->driver;
......@@ -1049,6 +1051,8 @@ static int drivercb_detach_ctr(struct capi_ctr *card)
return 0;
}
EXPORT_SYMBOL(detach_capi_ctr);
/* ------------------------------------------------------------- */
/* fallback if no driver read_proc function defined by driver */
......@@ -1071,17 +1075,14 @@ static int driver_read_proc(char *page, char **start, off_t off,
/* ------------------------------------------------------------- */
static struct capi_driver_interface di = {
drivercb_attach_ctr,
drivercb_detach_ctr,
};
struct capi_driver_interface *attach_capi_driver(struct capi_driver *driver)
void attach_capi_driver(struct capi_driver *driver)
{
INIT_LIST_HEAD(&driver->contr_head);
spin_lock(&drivers_lock);
list_add_tail(&driver->driver_list, &drivers);
spin_unlock(&drivers_lock);
printk(KERN_NOTICE "kcapi: driver %s attached\n", driver->name);
sprintf(driver->procfn, "capi/drivers/%s", driver->name);
driver->procent = create_proc_entry(driver->procfn, 0, 0);
......@@ -1095,9 +1096,10 @@ struct capi_driver_interface *attach_capi_driver(struct capi_driver *driver)
}
driver->procent->data = driver;
}
return &di;
}
EXPORT_SYMBOL(attach_capi_driver);
void detach_capi_driver(struct capi_driver *driver)
{
spin_lock(&drivers_lock);
......@@ -1111,6 +1113,8 @@ void detach_capi_driver(struct capi_driver *driver)
}
}
EXPORT_SYMBOL(detach_capi_driver);
/* ------------------------------------------------------------- */
/* -------- CAPI2.0 Interface ---------------------------------- */
/* ------------------------------------------------------------- */
......@@ -1627,6 +1631,8 @@ struct capi_interface *attach_capi_interface(struct capi_interface_user *userp)
return &avmb1_interface;
}
EXPORT_SYMBOL(attach_capi_interface);
int detach_capi_interface(struct capi_interface_user *userp)
{
spin_lock(&users_lock);
......@@ -1635,15 +1641,12 @@ int detach_capi_interface(struct capi_interface_user *userp)
return 0;
}
EXPORT_SYMBOL(detach_capi_interface);
/* ------------------------------------------------------------- */
/* -------- Init & Cleanup ------------------------------------- */
/* ------------------------------------------------------------- */
EXPORT_SYMBOL(attach_capi_interface);
EXPORT_SYMBOL(detach_capi_interface);
EXPORT_SYMBOL(attach_capi_driver);
EXPORT_SYMBOL(detach_capi_driver);
/*
* init / exit functions
*/
......
......@@ -34,10 +34,6 @@ MODULE_LICENSE("GPL");
/* ------------------------------------------------------------- */
static struct capi_driver_interface *di;
/* ------------------------------------------------------------- */
static void b1isa_remove_ctr(struct capi_ctr *ctrl)
{
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
......@@ -47,7 +43,7 @@ static void b1isa_remove_ctr(struct capi_ctr *ctrl)
b1_reset(port);
b1_reset(port);
di->detach_ctr(ctrl);
detach_capi_ctr(ctrl);
free_irq(card->irq, card);
release_region(card->port, AVMB1_PORTLEN);
b1_free_card(card);
......@@ -111,7 +107,7 @@ static int b1isa_add_card(struct capi_driver *driver, struct capicardparams *p)
b1_reset(card->port);
b1_getrevision(card);
cinfo->capi_ctrl = di->attach_ctr(driver, card->name, cinfo);
cinfo->capi_ctrl = attach_capi_ctr(driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_ERR "b1isa: attach controller failed.\n");
retval = -EBUSY;
......@@ -175,7 +171,6 @@ static int __init b1isa_init(void)
{
struct capi_driver *driver = &b1isa_driver;
char *p;
int retval = 0;
MOD_INC_USE_COUNT;
......@@ -188,15 +183,9 @@ static int __init b1isa_init(void)
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
di = attach_capi_driver(driver);
if (!di) {
printk(KERN_ERR "%s: failed to attach capi_driver\n",
driver->name);
retval = -EIO;
}
attach_capi_driver(driver);
MOD_DEC_USE_COUNT;
return retval;
return 0;
}
static void __exit b1isa_exit(void)
......
......@@ -42,10 +42,6 @@ MODULE_LICENSE("GPL");
/* ------------------------------------------------------------- */
static struct capi_driver_interface *di;
/* ------------------------------------------------------------- */
static char *b1pci_procinfo(struct capi_ctr *ctrl)
{
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
......@@ -113,7 +109,7 @@ static int b1pci_add_card(struct capi_driver *driver,
goto err_release_region;
}
cinfo->capi_ctrl = di->attach_ctr(driver, card->name, cinfo);
cinfo->capi_ctrl = attach_capi_ctr(driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_ERR "%s: attach controller failed.\n",
driver->name);
......@@ -153,7 +149,7 @@ static void b1pci_remove_ctr(struct capi_ctr *ctrl)
b1_reset(port);
b1_reset(port);
di->detach_ctr(ctrl);
detach_capi_ctr(ctrl);
free_irq(card->irq, card);
release_region(card->port, AVMB1_PORTLEN);
ctrl->driverdata = 0;
......@@ -185,10 +181,6 @@ static struct capi_driver b1pci_driver = {
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
/* ------------------------------------------------------------- */
static struct capi_driver_interface *div4;
/* ------------------------------------------------------------- */
static char *b1pciv4_procinfo(struct capi_ctr *ctrl)
{
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
......@@ -275,7 +267,7 @@ static int b1pciv4_add_card(struct capi_driver *driver,
goto err_unmap;
}
cinfo->capi_ctrl = div4->attach_ctr(driver, card->name, cinfo);
cinfo->capi_ctrl = attach_capi_ctr(driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_ERR "%s: attach controller failed.\n", driver->name);
retval = -EBUSY;
......@@ -313,7 +305,7 @@ static void b1pciv4_remove_ctr(struct capi_ctr *ctrl)
b1dma_reset(card);
div4->detach_ctr(ctrl);
detach_capi_ctr(ctrl);
free_irq(card->irq, card);
iounmap(card->mbase);
release_region(card->port, AVMB1_PORTLEN);
......@@ -434,25 +426,12 @@ static int __init b1pci_init(void)
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
di = attach_capi_driver(driver);
if (!di) {
printk(KERN_ERR "%s: failed to attach capi_driver\n",
driver->name);
MOD_DEC_USE_COUNT;
return -ENODEV;
}
attach_capi_driver(driver);
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
printk(KERN_INFO "%s: revision %s\n", driverv4->name, driverv4->revision);
div4 = attach_capi_driver(driverv4);
if (!div4) {
detach_capi_driver(driver);
printk(KERN_ERR "%s: failed to attach capi_driver\n",
driverv4->name);
MOD_DEC_USE_COUNT;
return -ENODEV;
}
attach_capi_driver(driverv4);
#endif
ncards = pci_register_driver(&b1pci_pci_driver);
......
......@@ -35,10 +35,6 @@ MODULE_LICENSE("GPL");
/* ------------------------------------------------------------- */
static struct capi_driver_interface *di;
/* ------------------------------------------------------------- */
static void b1pcmcia_remove_ctr(struct capi_ctr *ctrl)
{
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
......@@ -48,7 +44,7 @@ static void b1pcmcia_remove_ctr(struct capi_ctr *ctrl)
b1_reset(port);
b1_reset(port);
di->detach_ctr(ctrl);
detach_capi_ctr(ctrl);
free_irq(card->irq, card);
b1_free_card(card);
......@@ -103,7 +99,7 @@ static int b1pcmcia_add_card(struct capi_driver *driver,
b1_reset(card->port);
b1_getrevision(card);
cinfo->capi_ctrl = di->attach_ctr(driver, card->name, cinfo);
cinfo->capi_ctrl = attach_capi_ctr(driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_ERR "%s: attach controller failed.\n",
driver->name);
......@@ -227,13 +223,8 @@ static int __init b1pcmcia_init(void)
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
di = attach_capi_driver(driver);
attach_capi_driver(driver);
if (!di) {
printk(KERN_ERR "%s: failed to attach capi_driver\n",
driver->name);
retval = -EIO;
}
MOD_DEC_USE_COUNT;
return retval;
}
......
......@@ -52,10 +52,6 @@ MODULE_PARM(suppress_pollack, "0-1i");
/* ------------------------------------------------------------- */
static struct capi_driver_interface *di;
/* ------------------------------------------------------------- */
static void c4_dispatch_tx(avmcard *card);
/* ------------------------------------------------------------- */
......@@ -912,7 +908,7 @@ static void c4_remove_ctr(struct capi_ctr *ctrl)
for (i=0; i < 4; i++) {
cinfo = &card->ctrlinfo[i];
if (cinfo->capi_ctrl) {
di->detach_ctr(cinfo->capi_ctrl);
detach_capi_ctr(cinfo->capi_ctrl);
cinfo->capi_ctrl = NULL;
}
}
......@@ -1162,13 +1158,13 @@ static int c4_add_card(struct capi_driver *driver,
for (i=0; i < nr_controllers ; i++) {
cinfo = &card->ctrlinfo[i];
cinfo->capi_ctrl = di->attach_ctr(driver, card->name, cinfo);
cinfo->capi_ctrl = attach_capi_ctr(driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_ERR "%s: attach controller failed (%d).\n",
driver->name, i);
for (i--; i >= 0; i--) {
cinfo = &card->ctrlinfo[i];
di->detach_ctr(cinfo->capi_ctrl);
detach_capi_ctr(cinfo->capi_ctrl);
}
goto err_free_irq;
}
......@@ -1247,13 +1243,7 @@ static int c4_attach_driver (struct capi_driver * driver)
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
di = attach_capi_driver(driver);
if (!di) {
printk(KERN_ERR "%s: failed to attach capi_driver\n",
driver->name);
MOD_DEC_USE_COUNT;
return -ENODEV;
}
attach_capi_driver(driver);
return 0;
}
......
......@@ -35,10 +35,6 @@ MODULE_LICENSE("GPL");
/* ------------------------------------------------------------- */
static struct capi_driver_interface *di;
/* ------------------------------------------------------------- */
static int hema_irq_table[16] =
{0,
0,
......@@ -331,7 +327,7 @@ static void t1isa_remove_ctr(struct capi_ctr *ctrl)
b1_reset(port);
t1_reset(port);
di->detach_ctr(ctrl);
detach_capi_ctr(ctrl);
free_irq(card->irq, card);
release_region(card->port, AVMB1_PORTLEN);
b1_free_card(card);
......@@ -412,7 +408,7 @@ static int t1isa_add_card(struct capi_driver *driver, struct capicardparams *p)
t1_disable_irq(card->port);
b1_reset(card->port);
cinfo->capi_ctrl = di->attach_ctr(driver, card->name, cinfo);
cinfo->capi_ctrl = attach_capi_ctr(driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_ERR "%s: attach controller failed.\n",
driver->name);
......@@ -517,13 +513,7 @@ static int __init t1isa_init(void)
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
di = attach_capi_driver(driver);
if (!di) {
printk(KERN_ERR "%s: failed to attach capi_driver\n",
driver->name);
retval = -EIO;
}
attach_capi_driver(driver);
MOD_DEC_USE_COUNT;
return retval;
......
......@@ -45,10 +45,6 @@ MODULE_LICENSE("GPL");
/* ------------------------------------------------------------- */
static struct capi_driver_interface *di;
/* ------------------------------------------------------------- */
static int t1pci_add_card(struct capi_driver *driver,
struct capicardparams *p,
struct pci_dev *dev)
......@@ -119,7 +115,7 @@ static int t1pci_add_card(struct capi_driver *driver,
goto err_unmap;
}
cinfo->capi_ctrl = di->attach_ctr(driver, card->name, cinfo);
cinfo->capi_ctrl = attach_capi_ctr(driver, card->name, cinfo);
if (!cinfo->capi_ctrl) {
printk(KERN_ERR "%s: attach controller failed.\n", driver->name);
retval = -EBUSY;
......@@ -157,7 +153,7 @@ static void t1pci_remove_ctr(struct capi_ctr *ctrl)
b1dma_reset(card);
di->detach_ctr(ctrl);
detach_capi_ctr(ctrl);
free_irq(card->irq, card);
iounmap(card->mbase);
release_region(card->port, AVMB1_PORTLEN);
......@@ -262,13 +258,7 @@ static int __init t1pci_init(void)
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
di = attach_capi_driver(&t1pci_driver);
if (!di) {
printk(KERN_ERR "%s: failed to attach capi_driver\n",
driver->name);
MOD_DEC_USE_COUNT;
return -EIO;
}
attach_capi_driver(&t1pci_driver);
ncards = pci_register_driver(&t1pci_pci_driver);
if (ncards) {
......
......@@ -98,7 +98,7 @@ hycapi_remove_ctr(struct capi_ctr *ctrl)
hycapi_applications[i].listen_req[ctrl->cnr-1] = NULL;
}
}
hy_di->detach_ctr(ctrl);
detach_capi_ctr(ctrl);
ctrl->driverdata = 0;
kfree(card->hyctrlinfo);
......@@ -699,11 +699,8 @@ int hycapi_init()
}
driver = &hycapi_driver;
printk(KERN_NOTICE "HYSDN: Attaching capi-driver\n");
hy_di = attach_capi_driver(driver);
if (!hy_di) {
printk(KERN_ERR "HYCAPI: failed to attach capi_driver\n");
return(-1);
}
attach_capi_driver(driver);
for(i=0;i<CAPI_MAXAPPL;i++) {
memset(&(hycapi_applications[i]), 0, sizeof(hycapi_appl));
}
......@@ -799,8 +796,8 @@ hycapi_capi_create(hysdn_card *card)
default: strcpy(cinfo->cardname,"HYSDN ???"); break;
}
cinfo->capi_ctrl = hy_di->attach_ctr(&hycapi_driver,
cinfo->cardname, cinfo);
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",
......
......@@ -75,11 +75,6 @@ struct capi_ctr {
char procfn[128];
};
struct capi_driver_interface {
struct capi_ctr *(*attach_ctr)(struct capi_driver *driver, char *name, void *data);
int (*detach_ctr)(struct capi_ctr *);
};
struct capi_driver {
struct module *owner;
char name[32]; /* driver name */
......@@ -108,7 +103,10 @@ struct capi_driver {
char procfn[128];
};
struct capi_driver_interface *attach_capi_driver(struct capi_driver *driver);
void attach_capi_driver(struct capi_driver *driver);
void detach_capi_driver(struct capi_driver *driver);
struct capi_ctr *attach_capi_ctr(struct capi_driver *driver, char *name, void *data);
int detach_capi_ctr(struct capi_ctr *);
#endif /* __CAPILLI_H__ */
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