Commit 2e025886 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Usage count for CAPI controllers

We now control rely on ->owner and the upper level to control the
module use count.
parent e79275e2
......@@ -1198,6 +1198,7 @@ static int old_capi_manufacturer(unsigned int cmd, void *data)
return retval;
}
card = get_capi_ctr_by_nr(ldef.contr);
card = capi_ctr_get(card);
if (!card)
return -ESRCH;
if (card->driver->load_firmware == 0) {
......@@ -1231,6 +1232,7 @@ static int old_capi_manufacturer(unsigned int cmd, void *data)
if (retval) {
card->cardstate = CARD_DETECTED;
capi_ctr_put(card);
return retval;
}
......@@ -1239,9 +1241,12 @@ static int old_capi_manufacturer(unsigned int cmd, void *data)
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ/10); /* 0.1 sec */
if (signal_pending(current))
if (signal_pending(current)) {
capi_ctr_put(card);
return -EINTR;
}
}
capi_ctr_put(card);
return 0;
case AVMB1_RESETCARD:
......
......@@ -47,8 +47,6 @@ static void b1isa_remove_ctr(struct capi_ctr *ctrl)
free_irq(card->irq, card);
release_region(card->port, AVMB1_PORTLEN);
b1_free_card(card);
MOD_DEC_USE_COUNT;
}
/* ------------------------------------------------------------- */
......@@ -59,8 +57,6 @@ static int b1isa_add_card(struct capi_driver *driver, struct capicardparams *p)
avmcard *card;
int retval;
MOD_INC_USE_COUNT;
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "b1isa: no memory.\n");
......@@ -127,7 +123,6 @@ static int b1isa_add_card(struct capi_driver *driver, struct capicardparams *p)
err_free:
b1_free_card(card);
err:
MOD_DEC_USE_COUNT;
return retval;
}
......
......@@ -68,8 +68,6 @@ static int b1pci_add_card(struct capi_driver *driver,
avmctrl_info *cinfo;
int retval;
MOD_INC_USE_COUNT;
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
......@@ -136,7 +134,6 @@ static int b1pci_add_card(struct capi_driver *driver,
err_free:
b1_free_card(card);
err:
MOD_DEC_USE_COUNT;
return retval;
}
......@@ -154,8 +151,6 @@ static void b1pci_remove_ctr(struct capi_ctr *ctrl)
release_region(card->port, AVMB1_PORTLEN);
ctrl->driverdata = 0;
b1_free_card(card);
MOD_DEC_USE_COUNT;
}
/* ------------------------------------------------------------- */
......@@ -208,8 +203,6 @@ static int b1pciv4_add_card(struct capi_driver *driver,
avmctrl_info *cinfo;
int retval;
MOD_INC_USE_COUNT;
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
......@@ -293,7 +286,6 @@ static int b1pciv4_add_card(struct capi_driver *driver,
err_free:
b1_free_card(card);
err:
MOD_DEC_USE_COUNT;
return retval;
}
......@@ -312,8 +304,6 @@ static void b1pciv4_remove_ctr(struct capi_ctr *ctrl)
ctrl->driverdata = 0;
avmcard_dma_free(card->dma);
b1_free_card(card);
MOD_DEC_USE_COUNT;
}
/* ------------------------------------------------------------- */
......@@ -405,7 +395,7 @@ static int __init b1pci_init(void)
struct capi_driver *driverv4 = &b1pciv4_driver;
#endif
char *p;
int ncards;
int retval;
MOD_INC_USE_COUNT;
......@@ -434,19 +424,21 @@ static int __init b1pci_init(void)
attach_capi_driver(driverv4);
#endif
ncards = pci_register_driver(&b1pci_pci_driver);
if (ncards) {
retval = pci_module_init(&b1pci_pci_driver);
if (retval < 0)
goto err;
printk(KERN_INFO "%s: %d B1-PCI card(s) detected\n",
driver->name, ncards);
MOD_DEC_USE_COUNT;
return 0;
}
printk(KERN_ERR "%s: NO B1-PCI card detected\n", driver->name);
pci_unregister_driver(&b1pci_pci_driver);
driver->name, retval);
retval = 0;
goto out;
err:
detach_capi_driver(driver);
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
detach_capi_driver(driverv4);
#endif
out:
MOD_DEC_USE_COUNT;
return -ENODEV;
}
......
......@@ -47,8 +47,6 @@ static void b1pcmcia_remove_ctr(struct capi_ctr *ctrl)
detach_capi_ctr(ctrl);
free_irq(card->irq, card);
b1_free_card(card);
MOD_DEC_USE_COUNT;
}
/* ------------------------------------------------------------- */
......@@ -63,8 +61,6 @@ static int b1pcmcia_add_card(struct capi_driver *driver,
char *cardname;
int retval;
MOD_INC_USE_COUNT;
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
......@@ -123,7 +119,6 @@ static int b1pcmcia_add_card(struct capi_driver *driver,
err_free:
b1_free_card(card);
err:
MOD_DEC_USE_COUNT;
return retval;
}
......
......@@ -923,8 +923,6 @@ static void c4_remove_ctr(struct capi_ctr *ctrl)
ctrl->driverdata = 0;
avmcard_dma_free(card->dma);
b1_free_card(card);
MOD_DEC_USE_COUNT;
}
/* ------------------------------------------------------------- */
......@@ -1121,8 +1119,6 @@ static int c4_add_card(struct capi_driver *driver,
int retval;
int i;
MOD_INC_USE_COUNT;
card = b1_alloc_card(nr_controllers);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
......@@ -1208,7 +1204,6 @@ static int c4_add_card(struct capi_driver *driver,
err_free:
b1_free_card(card);
err:
MOD_DEC_USE_COUNT;
return retval;
}
......@@ -1250,7 +1245,7 @@ static struct capi_driver c4_driver = {
add_card: 0, /* no add_card function */
};
static int c4_attach_driver (struct capi_driver * driver)
static void c4_attach_driver (struct capi_driver * driver)
{
char *p;
if ((p = strchr(revision, ':')) != 0 && p[1]) {
......@@ -1263,7 +1258,6 @@ static int c4_attach_driver (struct capi_driver * driver)
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
attach_capi_driver(driver);
return 0;
}
static int __devinit c4_probe(struct pci_dev *dev,
......@@ -1308,35 +1302,28 @@ static struct pci_driver c4_pci_driver = {
static int __init c4_init(void)
{
int retval;
int ncards;
MOD_INC_USE_COUNT;
retval = c4_attach_driver (&c4_driver);
if (retval) {
MOD_DEC_USE_COUNT;
return retval;
}
c4_attach_driver (&c4_driver);
c4_attach_driver (&c2_driver);
retval = c4_attach_driver (&c2_driver);
if (retval) {
MOD_DEC_USE_COUNT;
return retval;
}
retval = pci_module_init(&c4_pci_driver);
if (retval < 0)
goto err;
ncards = pci_register_driver(&c4_pci_driver);
if (ncards) {
printk(KERN_INFO "%s: %d C4/C2 card(s) detected\n",
c4_driver.name, ncards);
MOD_DEC_USE_COUNT;
return 0;
}
printk(KERN_ERR "%s: NO C4/C2 card detected\n", c4_driver.name);
pci_unregister_driver(&c4_pci_driver);
detach_capi_driver(&c4_driver);
c4_driver.name, retval);
retval = 0;
goto out;
err:
detach_capi_driver(&c2_driver);
detach_capi_driver(&c4_driver);
out:
MOD_DEC_USE_COUNT;
return -ENODEV;
return retval;
}
static void __exit c4_exit(void)
......
......@@ -338,8 +338,6 @@ static void t1isa_remove_ctr(struct capi_ctr *ctrl)
free_irq(card->irq, card);
release_region(card->port, AVMB1_PORTLEN);
b1_free_card(card);
MOD_DEC_USE_COUNT;
}
/* ------------------------------------------------------------- */
......@@ -352,8 +350,6 @@ static int t1isa_add_card(struct capi_driver *driver, struct capicardparams *p)
avmcard *card;
int retval;
MOD_INC_USE_COUNT;
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
......@@ -436,7 +432,6 @@ static int t1isa_add_card(struct capi_driver *driver, struct capicardparams *p)
err_free:
b1_free_card(card);
err:
MOD_DEC_USE_COUNT;
return retval;
}
......
......@@ -53,8 +53,6 @@ static int t1pci_add_card(struct capi_driver *driver,
avmctrl_info *cinfo;
int retval;
MOD_INC_USE_COUNT;
card = b1_alloc_card(1);
if (!card) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
......@@ -140,7 +138,6 @@ static int t1pci_add_card(struct capi_driver *driver,
err_free:
b1_free_card(card);
err:
MOD_DEC_USE_COUNT;
return retval;
}
......@@ -160,8 +157,6 @@ static void t1pci_remove_ctr(struct capi_ctr *ctrl)
ctrl->driverdata = 0;
avmcard_dma_free(card->dma);
b1_free_card(card);
MOD_DEC_USE_COUNT;
}
/* ------------------------------------------------------------- */
......@@ -246,7 +241,7 @@ static int __init t1pci_init(void)
{
struct capi_driver *driver = &t1pci_driver;
char *p;
int ncards;
int retval;
MOD_INC_USE_COUNT;
......@@ -260,18 +255,20 @@ static int __init t1pci_init(void)
attach_capi_driver(&t1pci_driver);
ncards = pci_register_driver(&t1pci_pci_driver);
if (ncards) {
retval = pci_register_driver(&t1pci_pci_driver);
if (retval < 0)
goto err;
printk(KERN_INFO "%s: %d T1-PCI card(s) detected\n",
driver->name, ncards);
MOD_DEC_USE_COUNT;
return 0;
}
printk(KERN_ERR "%s: NO T1-PCI card detected\n", driver->name);
pci_unregister_driver(&t1pci_pci_driver);
driver->name, retval);
retval = 0;
goto out;
err:
detach_capi_driver(&t1pci_driver);
out:
MOD_DEC_USE_COUNT;
return -ENODEV;
return retval;
}
static void __exit t1pci_exit(void)
......
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