Commit c1c5774f authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: AVM CAPI drivers: Common revision parsing

Use common function for setting the revision strings.
parent 2e025886
...@@ -537,6 +537,7 @@ static inline void b1_setinterrupt(unsigned int base, unsigned irq, ...@@ -537,6 +537,7 @@ static inline void b1_setinterrupt(unsigned int base, unsigned irq,
} }
/* b1.c */ /* b1.c */
void b1_set_revision(struct capi_driver *driver, char *rev);
avmcard *b1_alloc_card(int nr_controllers); avmcard *b1_alloc_card(int nr_controllers);
void b1_free_card(avmcard *card); void b1_free_card(avmcard *card);
int b1_detect(unsigned int base, enum avmcardtype cardtype); int b1_detect(unsigned int base, enum avmcardtype cardtype);
...@@ -561,7 +562,6 @@ avmcard_dmainfo *avmcard_dma_alloc(char *name, struct pci_dev *, ...@@ -561,7 +562,6 @@ avmcard_dmainfo *avmcard_dma_alloc(char *name, struct pci_dev *,
long rsize, long ssize); long rsize, long ssize);
void avmcard_dma_free(avmcard_dmainfo *); void avmcard_dma_free(avmcard_dmainfo *);
/* b1dma.c */ /* b1dma.c */
int b1pciv4_detect(avmcard *card); int b1pciv4_detect(avmcard *card);
int t1pci_detect(avmcard *card); int t1pci_detect(avmcard *card);
......
...@@ -59,6 +59,21 @@ int b1_irq_table[16] = ...@@ -59,6 +59,21 @@ int b1_irq_table[16] =
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
void b1_set_revision(struct capi_driver *driver, char *rev)
{
char *p;
if ((p = strchr(rev, ':')) != 0 && p[1]) {
strncpy(driver->revision, p + 2, sizeof(driver->revision));
driver->revision[sizeof(driver->revision)-1] = 0;
if ((p = strchr(driver->revision, '$')) != 0 && p > driver->revision)
*(p-1) = 0;
}
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
}
/* ------------------------------------------------------------- */
avmcard *b1_alloc_card(int nr_controllers) avmcard *b1_alloc_card(int nr_controllers)
{ {
avmcard *card; avmcard *card;
...@@ -763,6 +778,7 @@ EXPORT_SYMBOL(avmcard_dma_free); ...@@ -763,6 +778,7 @@ EXPORT_SYMBOL(avmcard_dma_free);
EXPORT_SYMBOL(b1_irq_table); EXPORT_SYMBOL(b1_irq_table);
EXPORT_SYMBOL(b1_set_revision);
EXPORT_SYMBOL(b1_alloc_card); EXPORT_SYMBOL(b1_alloc_card);
EXPORT_SYMBOL(b1_free_card); EXPORT_SYMBOL(b1_free_card);
EXPORT_SYMBOL(b1_detect); EXPORT_SYMBOL(b1_detect);
......
...@@ -164,21 +164,11 @@ static struct capi_driver b1isa_driver = { ...@@ -164,21 +164,11 @@ static struct capi_driver b1isa_driver = {
static int __init b1isa_init(void) static int __init b1isa_init(void)
{ {
struct capi_driver *driver = &b1isa_driver;
char *p;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
if ((p = strchr(revision, ':')) != 0 && p[1]) { b1_set_revision(&b1isa_driver, revision);
strncpy(driver->revision, p + 2, sizeof(driver->revision)); attach_capi_driver(&b1isa_driver);
driver->revision[sizeof(driver->revision)-1] = 0;
if ((p = strchr(driver->revision, '$')) != 0 && p > driver->revision)
*(p-1) = 0;
}
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
attach_capi_driver(driver);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
......
...@@ -390,38 +390,16 @@ static struct pci_driver b1pci_pci_driver = { ...@@ -390,38 +390,16 @@ static struct pci_driver b1pci_pci_driver = {
static int __init b1pci_init(void) static int __init b1pci_init(void)
{ {
struct capi_driver *driver = &b1pci_driver;
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
struct capi_driver *driverv4 = &b1pciv4_driver;
#endif
char *p;
int retval; int retval;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
if ((p = strchr(revision, ':')) != 0 && p[1]) { b1_set_revision(&b1pci_driver, revision);
strncpy(driver->revision, p + 2, sizeof(driver->revision)); attach_capi_driver(&b1pci_driver);
driver->revision[sizeof(driver->revision)-1] = 0;
if ((p = strchr(driver->revision, '$')) != 0 && p > driver->revision)
*(p-1) = 0;
}
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
if ((p = strchr(revision, ':')) != 0 && p[1]) {
strncpy(driverv4->revision, p + 2, sizeof(driverv4->revision));
driverv4->revision[sizeof(driverv4->revision)-1] = 0;
if ((p = strchr(driverv4->revision, '$')) != 0 && p > driverv4->revision)
*(p-1) = 0;
}
#endif
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
attach_capi_driver(driver);
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4 #ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
printk(KERN_INFO "%s: revision %s\n", driverv4->name, driverv4->revision); b1_set_revision(&b1pciv4_driver, revision);
attach_capi_driver(&b1pciv4_driver);
attach_capi_driver(driverv4);
#endif #endif
retval = pci_module_init(&b1pci_pci_driver); retval = pci_module_init(&b1pci_pci_driver);
...@@ -429,23 +407,24 @@ static int __init b1pci_init(void) ...@@ -429,23 +407,24 @@ static int __init b1pci_init(void)
goto err; goto err;
printk(KERN_INFO "%s: %d B1-PCI card(s) detected\n", printk(KERN_INFO "%s: %d B1-PCI card(s) detected\n",
driver->name, retval); b1pci_driver.name, retval);
retval = 0; retval = 0;
goto out; goto out;
err: err:
detach_capi_driver(driver); detach_capi_driver(&b1pci_driver);
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4 #ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
detach_capi_driver(driverv4); detach_capi_driver(&b1pciv4_driver);
#endif #endif
out: out:
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return -ENODEV; return retval;
} }
static void __exit b1pci_exit(void) static void __exit b1pci_exit(void)
{ {
pci_unregister_driver(&b1pci_pci_driver); pci_unregister_driver(&b1pci_pci_driver);
detach_capi_driver(&b1pci_driver); detach_capi_driver(&b1pci_driver);
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4 #ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
detach_capi_driver(&b1pciv4_driver); detach_capi_driver(&b1pciv4_driver);
......
...@@ -203,25 +203,13 @@ EXPORT_SYMBOL(b1pcmcia_delcard); ...@@ -203,25 +203,13 @@ EXPORT_SYMBOL(b1pcmcia_delcard);
static int __init b1pcmcia_init(void) static int __init b1pcmcia_init(void)
{ {
struct capi_driver *driver = &b1pcmcia_driver;
char *p;
int retval = 0;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
if ((p = strchr(revision, ':')) != 0 && p[1]) { b1_set_revision(&b1pcmcia_driver, revision);
strncpy(driver->revision, p + 2, sizeof(driver->revision)); attach_capi_driver(&b1pcmcia_driver);
driver->revision[sizeof(driver->revision)-1] = 0;
if ((p = strchr(driver->revision, '$')) != 0 && p > driver->revision)
*(p-1) = 0;
}
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
attach_capi_driver(driver);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return retval; return 0;
} }
static void __exit b1pcmcia_exit(void) static void __exit b1pcmcia_exit(void)
......
...@@ -1245,21 +1245,6 @@ static struct capi_driver c4_driver = { ...@@ -1245,21 +1245,6 @@ static struct capi_driver c4_driver = {
add_card: 0, /* no add_card function */ add_card: 0, /* no add_card function */
}; };
static void c4_attach_driver (struct capi_driver * driver)
{
char *p;
if ((p = strchr(revision, ':')) != 0 && p[1]) {
strncpy(driver->revision, p + 2, sizeof(driver->revision));
driver->revision[sizeof(driver->revision)-1] = 0;
if ((p = strchr(driver->revision, '$')) != 0 && p > driver->revision)
*(p-1) = 0;
}
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
attach_capi_driver(driver);
}
static int __devinit c4_probe(struct pci_dev *dev, static int __devinit c4_probe(struct pci_dev *dev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
...@@ -1305,8 +1290,11 @@ static int __init c4_init(void) ...@@ -1305,8 +1290,11 @@ static int __init c4_init(void)
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
c4_attach_driver (&c4_driver); b1_set_revision(&c2_driver, revision);
c4_attach_driver (&c2_driver); attach_capi_driver(&c2_driver);
b1_set_revision(&c4_driver, revision);
attach_capi_driver(&c4_driver);
retval = pci_module_init(&c4_pci_driver); retval = pci_module_init(&c4_pci_driver);
if (retval < 0) if (retval < 0)
......
...@@ -516,30 +516,18 @@ static struct capi_driver t1isa_driver = { ...@@ -516,30 +516,18 @@ static struct capi_driver t1isa_driver = {
static int __init t1isa_init(void) static int __init t1isa_init(void)
{ {
struct capi_driver *driver = &t1isa_driver;
char *p;
int retval = 0;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
if ((p = strchr(revision, ':')) != 0 && p[1]) { b1_set_revision(&t1isa_driver, revision);
strncpy(driver->revision, p + 2, sizeof(driver->revision)); attach_capi_driver(&t1isa_driver);
driver->revision[sizeof(driver->revision)-1] = 0;
if ((p = strchr(driver->revision, '$')) != 0 && p > driver->revision)
*(p-1) = 0;
}
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
attach_capi_driver(driver);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return retval; return 0;
} }
static void __exit t1isa_exit(void) static void __exit t1isa_exit(void)
{ {
detach_capi_driver(&t1isa_driver); detach_capi_driver(&t1isa_driver);
} }
module_init(t1isa_init); module_init(t1isa_init);
......
...@@ -239,20 +239,11 @@ static struct pci_driver t1pci_pci_driver = { ...@@ -239,20 +239,11 @@ static struct pci_driver t1pci_pci_driver = {
static int __init t1pci_init(void) static int __init t1pci_init(void)
{ {
struct capi_driver *driver = &t1pci_driver;
char *p;
int retval; int retval;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
if ((p = strchr(revision, ':')) != 0 && p[1]) { b1_set_revision(&t1pci_driver, revision);
strncpy(driver->revision, p + 2, sizeof(driver->revision) - 1);
if ((p = strchr(driver->revision, '$')) != 0 && p > driver->revision)
*(p-1) = 0;
}
printk(KERN_INFO "%s: revision %s\n", driver->name, driver->revision);
attach_capi_driver(&t1pci_driver); attach_capi_driver(&t1pci_driver);
retval = pci_register_driver(&t1pci_pci_driver); retval = pci_register_driver(&t1pci_pci_driver);
...@@ -260,7 +251,7 @@ static int __init t1pci_init(void) ...@@ -260,7 +251,7 @@ static int __init t1pci_init(void)
goto err; goto err;
printk(KERN_INFO "%s: %d T1-PCI card(s) detected\n", printk(KERN_INFO "%s: %d T1-PCI card(s) detected\n",
driver->name, retval); t1pci_driver.name, retval);
retval = 0; retval = 0;
goto out; goto out;
......
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