Commit 960dc036 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Release AVM CAPI controllers at module unload time

Use the standard new-style pci_driver::remove to unregister
drivers at module unload time.

PCMCIA obviously has its own way of handling removing, the ISA
drivers unregister at module unload time as well.
parent 383a058c
......@@ -1250,30 +1250,6 @@ static int old_capi_manufacturer(unsigned int cmd, void *data)
return retval;
return 0;
case AVMB1_REMOVECARD:
if ((retval = copy_from_user((void *) &rdef, data,
sizeof(avmb1_resetdef))))
return retval;
card = get_capi_ctr_by_nr(rdef.contr);
if (!card)
return -ESRCH;
if (card->cardstate != CARD_DETECTED)
return -EBUSY;
card->driver->remove_ctr(card);
while (cards[rdef.contr]) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ/10); /* 0.1 sec */
if (signal_pending(current))
return -EINTR;
}
return 0;
}
return -EINVAL;
}
......
......@@ -60,9 +60,9 @@ static char *b1pci_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static int b1pci_add_card(struct capi_driver *driver,
struct capicardparams *p,
struct pci_dev *dev)
static int b1pci_probe(struct capi_driver *driver,
struct capicardparams *p,
struct pci_dev *pdev)
{
avmcard *card;
avmctrl_info *cinfo;
......@@ -125,6 +125,7 @@ static int b1pci_add_card(struct capi_driver *driver,
driver->name, card->port, card->irq, card->revision);
}
pci_set_drvdata(pdev, card);
return 0;
err_free_irq:
......@@ -137,19 +138,18 @@ static int b1pci_add_card(struct capi_driver *driver,
return retval;
}
static void b1pci_remove_ctr(struct capi_ctr *ctrl)
static void b1pci_remove(struct pci_dev *pdev)
{
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
avmcard *card = cinfo->card;
avmcard *card = pci_get_drvdata(pdev);
avmctrl_info *cinfo = card->ctrlinfo;
unsigned int port = card->port;
b1_reset(port);
b1_reset(port);
detach_capi_ctr(ctrl);
detach_capi_ctr(cinfo->capi_ctrl);
free_irq(card->irq, card);
release_region(card->port, AVMB1_PORTLEN);
ctrl->driverdata = 0;
b1_free_card(card);
}
......@@ -161,7 +161,6 @@ static struct capi_driver b1pci_driver = {
revision: "0.0",
load_firmware: b1_load_firmware,
reset_ctr: b1_reset_ctr,
remove_ctr: b1pci_remove_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: b1_send_message,
......@@ -169,8 +168,6 @@ static struct capi_driver b1pci_driver = {
procinfo: b1pci_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
......@@ -195,9 +192,9 @@ static char *b1pciv4_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static int b1pciv4_add_card(struct capi_driver *driver,
struct capicardparams *p,
struct pci_dev *dev)
static int b1pciv4_probe(struct capi_driver *driver,
struct capicardparams *p,
struct pci_dev *pdev)
{
avmcard *card;
avmctrl_info *cinfo;
......@@ -210,7 +207,7 @@ static int b1pciv4_add_card(struct capi_driver *driver,
goto err;
}
card->dma = avmcard_dma_alloc(driver->name, dev, 2048+128, 2048+128);
card->dma = avmcard_dma_alloc(driver->name, pdev, 2048+128, 2048+128);
if (!card->dma) {
printk(KERN_WARNING "%s: dma alloc.\n", driver->name);
retval = -ENOMEM;
......@@ -273,6 +270,7 @@ static int b1pciv4_add_card(struct capi_driver *driver,
driver->name, card->port, card->irq,
card->membase, card->revision);
pci_set_drvdata(pdev, card);
return 0;
err_free_irq:
......@@ -290,18 +288,17 @@ static int b1pciv4_add_card(struct capi_driver *driver,
}
static void b1pciv4_remove_ctr(struct capi_ctr *ctrl)
static void b1pciv4_remove(struct pci_dev *pdev)
{
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
avmcard *card = cinfo->card;
avmcard *card = pci_get_drvdata(pdev);
avmctrl_info *cinfo = card->ctrlinfo;
b1dma_reset(card);
detach_capi_ctr(ctrl);
detach_capi_ctr(cinfo->capi_ctrl);
free_irq(card->irq, card);
iounmap(card->mbase);
release_region(card->port, AVMB1_PORTLEN);
ctrl->driverdata = 0;
avmcard_dma_free(card->dma);
b1_free_card(card);
}
......@@ -315,7 +312,6 @@ static struct capi_driver b1pciv4_driver = {
revision: "0.0",
load_firmware: b1dma_load_firmware,
reset_ctr: b1dma_reset_ctr,
remove_ctr: b1pciv4_remove_ctr,
register_appl: b1dma_register_appl,
release_appl: b1dma_release_appl,
send_message: b1dma_send_message,
......@@ -323,42 +319,40 @@ static struct capi_driver b1pciv4_driver = {
procinfo: b1pciv4_procinfo,
ctr_read_proc: b1dmactl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
#endif /* CONFIG_ISDN_DRV_AVMB1_B1PCIV4 */
static int __devinit b1pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
static int __devinit b1pci_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct capi_driver *driver = &b1pci_driver;
struct capicardparams param;
int retval;
if (pci_enable_device(dev) < 0) {
if (pci_enable_device(pdev) < 0) {
printk(KERN_ERR "%s: failed to enable AVM-B1\n",
driver->name);
return -ENODEV;
}
param.irq = dev->irq;
param.irq = pdev->irq;
if (pci_resource_start(dev, 2)) { /* B1 PCI V4 */
if (pci_resource_start(pdev, 2)) { /* B1 PCI V4 */
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
driver = &b1pciv4_driver;
pci_set_master(dev);
pci_set_master(pdev);
#endif
param.membase = pci_resource_start(dev, 0);
param.port = pci_resource_start(dev, 2);
param.membase = pci_resource_start(pdev, 0);
param.port = pci_resource_start(pdev, 2);
printk(KERN_INFO
"%s: PCI BIOS reports AVM-B1 V4 at i/o %#x, irq %d, mem %#x\n",
driver->name, param.port, param.irq, param.membase);
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
retval = b1pciv4_add_card(driver, &param, dev);
retval = b1pciv4_probe(driver, &param, pdev);
#else
retval = b1pci_add_card(driver, &param, dev);
retval = b1pci_probe(driver, &param, pdev);
#endif
if (retval != 0) {
printk(KERN_ERR
......@@ -367,12 +361,12 @@ static int __devinit b1pci_probe(struct pci_dev *dev,
}
} else {
param.membase = 0;
param.port = pci_resource_start(dev, 1);
param.port = pci_resource_start(pdev, 1);
printk(KERN_INFO
"%s: PCI BIOS reports AVM-B1 at i/o %#x, irq %d\n",
driver->name, param.port, param.irq);
retval = b1pci_add_card(driver, &param, dev);
retval = b1pci_probe(driver, &param, pdev);
if (retval != 0) {
printk(KERN_ERR
"%s: no AVM-B1 at i/o %#x, irq %d detected\n",
......@@ -382,10 +376,21 @@ static int __devinit b1pci_probe(struct pci_dev *dev,
return retval;
}
static void __devexit b1pci_pci_remove(struct pci_dev *pdev)
{
avmcard *card = pci_get_drvdata(pdev);
if (card->dma)
b1pciv4_remove(pdev);
else
b1pci_remove(pdev);
}
static struct pci_driver b1pci_pci_driver = {
name: "b1pci",
id_table: b1pci_pci_tbl,
probe: b1pci_probe,
probe: b1pci_pci_probe,
remove: __devexit_p(b1pci_pci_remove),
};
static int __init b1pci_init(void)
......
......@@ -148,7 +148,6 @@ static struct capi_driver b1pcmcia_driver = {
revision: "0.0",
load_firmware: b1_load_firmware,
reset_ctr: b1_reset_ctr,
remove_ctr: b1pcmcia_remove_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: b1_send_message,
......@@ -156,8 +155,6 @@ static struct capi_driver b1pcmcia_driver = {
procinfo: b1pcmcia_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0,
};
/* ------------------------------------------------------------- */
......
......@@ -901,9 +901,9 @@ void c4_reset_ctr(struct capi_ctr *ctrl)
card->nlogcontr = 0;
}
static void c4_remove_ctr(struct capi_ctr *ctrl)
static void c4_remove(struct pci_dev *pdev)
{
avmcard *card = ((avmctrl_info *)(ctrl->driverdata))->card;
avmcard *card = pci_get_drvdata(pdev);
avmctrl_info *cinfo;
int i;
......@@ -920,7 +920,6 @@ static void c4_remove_ctr(struct capi_ctr *ctrl)
free_irq(card->irq, card);
iounmap(card->mbase);
release_region(card->port, AVMB1_PORTLEN);
ctrl->driverdata = 0;
avmcard_dma_free(card->dma);
b1_free_card(card);
}
......@@ -1215,7 +1214,6 @@ static struct capi_driver c2_driver = {
revision: "0.0",
load_firmware: c4_load_firmware,
reset_ctr: c4_reset_ctr,
remove_ctr: c4_remove_ctr,
register_appl: c4_register_appl,
release_appl: c4_release_appl,
send_message: c4_send_message,
......@@ -1223,8 +1221,6 @@ static struct capi_driver c2_driver = {
procinfo: c4_procinfo,
ctr_read_proc: c4_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
static struct capi_driver c4_driver = {
......@@ -1233,7 +1229,6 @@ static struct capi_driver c4_driver = {
revision: "0.0",
load_firmware: c4_load_firmware,
reset_ctr: c4_reset_ctr,
remove_ctr: c4_remove_ctr,
register_appl: c4_register_appl,
release_appl: c4_release_appl,
send_message: c4_send_message,
......@@ -1241,8 +1236,6 @@ static struct capi_driver c4_driver = {
procinfo: c4_procinfo,
ctr_read_proc: c4_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
static int __devinit c4_probe(struct pci_dev *dev,
......@@ -1282,6 +1275,7 @@ static struct pci_driver c4_pci_driver = {
name: "c4",
id_table: c4_pci_tbl,
probe: c4_probe,
remove: c4_remove,
};
static int __init c4_init(void)
......
......@@ -47,7 +47,7 @@ MODULE_LICENSE("GPL");
static int t1pci_add_card(struct capi_driver *driver,
struct capicardparams *p,
struct pci_dev *dev)
struct pci_dev *pdev)
{
avmcard *card;
avmctrl_info *cinfo;
......@@ -60,7 +60,7 @@ static int t1pci_add_card(struct capi_driver *driver,
goto err;
}
card->dma = avmcard_dma_alloc(driver->name, dev, 2048+128, 2048+128);
card->dma = avmcard_dma_alloc(driver->name, pdev, 2048+128, 2048+128);
if (!card->dma) {
printk(KERN_WARNING "%s: no memory.\n", driver->name);
retval = -ENOMEM;
......@@ -125,6 +125,7 @@ static int t1pci_add_card(struct capi_driver *driver,
"%s: AVM T1 PCI at i/o %#x, irq %d, mem %#lx\n",
driver->name, card->port, card->irq, card->membase);
pci_set_drvdata(pdev, card);
return 0;
err_free_irq:
......@@ -143,18 +144,17 @@ static int t1pci_add_card(struct capi_driver *driver,
/* ------------------------------------------------------------- */
static void t1pci_remove_ctr(struct capi_ctr *ctrl)
static void t1pci_remove(struct pci_dev *pdev)
{
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
avmcard *card = cinfo->card;
avmcard *card = pci_get_drvdata(pdev);
avmctrl_info *cinfo = card->ctrlinfo;
b1dma_reset(card);
detach_capi_ctr(ctrl);
detach_capi_ctr(cinfo->capi_ctrl);
free_irq(card->irq, card);
iounmap(card->mbase);
release_region(card->port, AVMB1_PORTLEN);
ctrl->driverdata = 0;
avmcard_dma_free(card->dma);
b1_free_card(card);
}
......@@ -185,7 +185,6 @@ static struct capi_driver t1pci_driver = {
revision: "0.0",
load_firmware: b1dma_load_firmware,
reset_ctr: b1dma_reset_ctr,
remove_ctr: t1pci_remove_ctr,
register_appl: b1dma_register_appl,
release_appl: b1dma_release_appl,
send_message: b1dma_send_message,
......@@ -193,8 +192,6 @@ static struct capi_driver t1pci_driver = {
procinfo: t1pci_procinfo,
ctr_read_proc: b1dmactl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
/* ------------------------------------------------------------- */
......@@ -235,6 +232,7 @@ static struct pci_driver t1pci_pci_driver = {
name: "t1pci",
id_table: t1pci_pci_tbl,
probe: t1pci_probe,
remove: t1pci_remove,
};
static int __init t1pci_init(void)
......
......@@ -693,7 +693,6 @@ static struct capi_driver hycapi_driver = {
revision: "0.0",
load_firmware: hycapi_load_firmware,
reset_ctr: hycapi_reset_ctr,
remove_ctr: hycapi_remove_ctr,
register_appl: hycapi_register_appl,
release_appl: hycapi_release_appl,
send_message: hycapi_send_message,
......
......@@ -66,7 +66,7 @@ typedef struct avmb1_extcarddef {
#define AVMB1_LOAD_AND_CONFIG 3 /* load image and config to card */
#define AVMB1_ADDCARD_WITH_TYPE 4 /* add a new card, with cardtype */
#define AVMB1_GET_CARDINFO 5 /* get cardtype */
#define AVMB1_REMOVECARD 6 /* remove a card (useful for T1) */
#define AVMB1_REMOVECARD 6 /* remove a card - OBSOLETE */
#define AVMB1_REGISTERCARD_IS_OBSOLETE
......
......@@ -80,7 +80,6 @@ struct capi_driver {
char revision[32];
int (*load_firmware)(struct capi_ctr *, capiloaddata *);
void (*reset_ctr)(struct capi_ctr *);
void (*remove_ctr)(struct capi_ctr *);
void (*register_appl)(struct capi_ctr *, __u16 appl,
capi_register_params *);
void (*release_appl)(struct capi_ctr *, __u16 appl);
......
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