Commit 73098660 authored by Alexander Viro's avatar Alexander Viro Committed by David S. Miller

[NET]: Convert most tokenring drivers away from...

[NET]: Convert most tokenring drivers away from {init,register,unregister}_trdev, only ibmtr remains.
parent aa5e7682
...@@ -1129,7 +1129,7 @@ static irqreturn_t xl_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -1129,7 +1129,7 @@ static irqreturn_t xl_interrupt(int irq, void *dev_id, struct pt_regs *regs)
netif_stop_queue(dev) ; netif_stop_queue(dev) ;
xl_freemem(dev) ; xl_freemem(dev) ;
free_irq(dev->irq,dev); free_irq(dev->irq,dev);
unregister_trdev(dev) ; unregister_netdev(dev) ;
kfree(dev) ; kfree(dev) ;
xl_reset(dev) ; xl_reset(dev) ;
writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ; writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ;
...@@ -1783,7 +1783,7 @@ static void __devexit xl_remove_one (struct pci_dev *pdev) ...@@ -1783,7 +1783,7 @@ static void __devexit xl_remove_one (struct pci_dev *pdev)
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
struct xl_private *xl_priv=(struct xl_private *)dev->priv; struct xl_private *xl_priv=(struct xl_private *)dev->priv;
unregister_trdev(dev); unregister_netdev(dev);
iounmap(xl_priv->xl_mmio) ; iounmap(xl_priv->xl_mmio) ;
pci_release_regions(pdev) ; pci_release_regions(pdev) ;
pci_set_drvdata(pdev,NULL) ; pci_set_drvdata(pdev,NULL) ;
......
...@@ -112,9 +112,10 @@ static int __init abyss_attach(struct pci_dev *pdev, const struct pci_device_id ...@@ -112,9 +112,10 @@ static int __init abyss_attach(struct pci_dev *pdev, const struct pci_device_id
/* At this point we have found a valid card. */ /* At this point we have found a valid card. */
dev = init_trdev(NULL, 0); dev = alloc_trdev(0);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
if (!request_region(pci_ioaddr, ABYSS_IO_EXTENT, dev->name)) { if (!request_region(pci_ioaddr, ABYSS_IO_EXTENT, dev->name)) {
...@@ -165,21 +166,21 @@ static int __init abyss_attach(struct pci_dev *pdev, const struct pci_device_id ...@@ -165,21 +166,21 @@ static int __init abyss_attach(struct pci_dev *pdev, const struct pci_device_id
dev->open = abyss_open; dev->open = abyss_open;
dev->stop = abyss_close; dev->stop = abyss_close;
ret = register_trdev(dev); pci_set_drvdata(pdev, dev);
ret = register_netdev(dev);
if (ret) if (ret)
goto err_out_tmsdev; goto err_out_tmsdev;
pci_set_drvdata(pdev, dev);
return 0; return 0;
err_out_tmsdev: err_out_tmsdev:
pci_set_drvdata(pdev, NULL);
tmsdev_term(dev); tmsdev_term(dev);
err_out_irq: err_out_irq:
free_irq(pdev->irq, dev); free_irq(pdev->irq, dev);
err_out_region: err_out_region:
release_region(pci_ioaddr, ABYSS_IO_EXTENT); release_region(pci_ioaddr, ABYSS_IO_EXTENT);
err_out_trdev: err_out_trdev:
unregister_netdev(dev);
kfree(dev); kfree(dev);
return ret; return ret;
} }
......
This diff is collapsed.
...@@ -177,12 +177,14 @@ static int __init madgemc_probe(void) ...@@ -177,12 +177,14 @@ static int __init madgemc_probe(void)
if (versionprinted++ == 0) if (versionprinted++ == 0)
printk("%s", version); printk("%s", version);
if ((dev = init_trdev(NULL, 0))==NULL) { dev = alloc_trdev(0);
if (dev == NULL) {
printk("madgemc: unable to allocate dev space\n"); printk("madgemc: unable to allocate dev space\n");
if (madgemc_card_list) if (madgemc_card_list)
return 0; return 0;
return -1; return -1;
} }
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
dev->dma = 0; dev->dma = 0;
...@@ -195,7 +197,7 @@ static int __init madgemc_probe(void) ...@@ -195,7 +197,7 @@ static int __init madgemc_probe(void)
card = kmalloc(sizeof(struct madgemc_card), GFP_KERNEL); card = kmalloc(sizeof(struct madgemc_card), GFP_KERNEL);
if (card==NULL) { if (card==NULL) {
printk("madgemc: unable to allocate card struct\n"); printk("madgemc: unable to allocate card struct\n");
kfree(dev); /* release_trdev? */ kfree(dev);
if (madgemc_card_list) if (madgemc_card_list)
return 0; return 0;
return -1; return -1;
...@@ -331,7 +333,7 @@ static int __init madgemc_probe(void) ...@@ -331,7 +333,7 @@ static int __init madgemc_probe(void)
*/ */
outb(0, dev->base_addr + MC_CONTROL_REG0); /* sanity */ outb(0, dev->base_addr + MC_CONTROL_REG0); /* sanity */
madgemc_setsifsel(dev, 1); madgemc_setsifsel(dev, 1);
if(request_irq(dev->irq, madgemc_interrupt, SA_SHIRQ, if (request_irq(dev->irq, madgemc_interrupt, SA_SHIRQ,
"madgemc", dev)) "madgemc", dev))
goto getout; goto getout;
...@@ -382,33 +384,22 @@ static int __init madgemc_probe(void) ...@@ -382,33 +384,22 @@ static int __init madgemc_probe(void)
dev->open = madgemc_open; dev->open = madgemc_open;
dev->stop = madgemc_close; dev->stop = madgemc_close;
if (register_trdev(dev) == 0) { if (register_netdev(dev) == 0) {
/* Enlist in the card list */ /* Enlist in the card list */
card->next = madgemc_card_list; card->next = madgemc_card_list;
madgemc_card_list = card; madgemc_card_list = card;
} else { slot++;
printk("madgemc: register_trdev() returned non-zero.\n"); continue; /* successful, try to find another */
release_region(dev->base_addr-MADGEMC_SIF_OFFSET,
MADGEMC_IO_EXTENT);
kfree(card);
tmsdev_term(dev);
kfree(dev);
if (madgemc_card_list)
return 0;
return -1;
} }
slot++;
continue; /* successful, try to find another */
free_irq(dev->irq, dev);
getout: getout:
release_region(dev->base_addr-MADGEMC_SIF_OFFSET, release_region(dev->base_addr-MADGEMC_SIF_OFFSET,
MADGEMC_IO_EXTENT); MADGEMC_IO_EXTENT);
getout1: getout1:
kfree(card); kfree(card);
kfree(dev); /* release_trdev? */ kfree(dev);
slot++; slot++;
} }
...@@ -779,7 +770,7 @@ static void __exit madgemc_exit(void) ...@@ -779,7 +770,7 @@ static void __exit madgemc_exit(void)
while (madgemc_card_list) { while (madgemc_card_list) {
dev = madgemc_card_list->dev; dev = madgemc_card_list->dev;
unregister_trdev(dev); unregister_netdev(dev);
release_region(dev->base_addr-MADGEMC_SIF_OFFSET, MADGEMC_IO_EXTENT); release_region(dev->base_addr-MADGEMC_SIF_OFFSET, MADGEMC_IO_EXTENT);
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
tmsdev_term(dev); tmsdev_term(dev);
......
...@@ -1773,7 +1773,7 @@ static void __devexit olympic_remove_one(struct pci_dev *pdev) ...@@ -1773,7 +1773,7 @@ static void __devexit olympic_remove_one(struct pci_dev *pdev)
strcat(proc_name,dev->name) ; strcat(proc_name,dev->name) ;
remove_proc_entry(proc_name,NULL); remove_proc_entry(proc_name,NULL);
} }
unregister_trdev(dev) ; unregister_netdev(dev) ;
iounmap(olympic_priv->olympic_mmio) ; iounmap(olympic_priv->olympic_mmio) ;
iounmap(olympic_priv->olympic_lap) ; iounmap(olympic_priv->olympic_lap) ;
pci_release_regions(pdev) ; pci_release_regions(pdev) ;
......
...@@ -121,6 +121,11 @@ int __init proteon_probe(struct net_device *dev) ...@@ -121,6 +121,11 @@ int __init proteon_probe(struct net_device *dev)
int i,j; int i,j;
struct proteon_card *card; struct proteon_card *card;
#ifndef MODULE
netdev_boot_setup_check(dev);
tr_setup(dev);
#endif
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
if (!dev->base_addr) if (!dev->base_addr)
{ {
...@@ -158,20 +163,8 @@ int __init proteon_probe(struct net_device *dev) ...@@ -158,20 +163,8 @@ int __init proteon_probe(struct net_device *dev)
if (versionprinted++ == 0) if (versionprinted++ == 0)
printk(KERN_DEBUG "%s", version); printk(KERN_DEBUG "%s", version);
#ifndef MODULE
dev = init_trdev(dev, 0);
if (!dev)
{
release_region(dev->base_addr, PROTEON_IO_EXTENT);
return -1;
}
#endif
if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL)) if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL))
{ goto out4;
release_region(dev->base_addr, PROTEON_IO_EXTENT);
return -1;
}
dev->base_addr &= ~3; dev->base_addr &= ~3;
...@@ -211,9 +204,7 @@ int __init proteon_probe(struct net_device *dev) ...@@ -211,9 +204,7 @@ int __init proteon_probe(struct net_device *dev)
if(irqlist[j] == 0) if(irqlist[j] == 0)
{ {
printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name); printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name);
release_region(dev->base_addr, PROTEON_IO_EXTENT); goto out3;
tmsdev_term(dev);
return -1;
} }
} }
else else
...@@ -225,18 +216,14 @@ int __init proteon_probe(struct net_device *dev) ...@@ -225,18 +216,14 @@ int __init proteon_probe(struct net_device *dev)
{ {
printk(KERN_INFO "%s: Illegal IRQ %d specified\n", printk(KERN_INFO "%s: Illegal IRQ %d specified\n",
dev->name, dev->irq); dev->name, dev->irq);
release_region(dev->base_addr, PROTEON_IO_EXTENT); goto out3;
tmsdev_term(dev);
return -1;
} }
if (request_irq(dev->irq, tms380tr_interrupt, 0, if (request_irq(dev->irq, tms380tr_interrupt, 0,
cardname, dev)) cardname, dev))
{ {
printk(KERN_INFO "%s: Selected IRQ %d not available\n", printk(KERN_INFO "%s: Selected IRQ %d not available\n",
dev->name, dev->irq); dev->name, dev->irq);
release_region(dev->base_addr, PROTEON_IO_EXTENT); goto out3;
tmsdev_term(dev);
return -1;
} }
} }
...@@ -252,10 +239,7 @@ int __init proteon_probe(struct net_device *dev) ...@@ -252,10 +239,7 @@ int __init proteon_probe(struct net_device *dev)
if(dmalist[j] == 0) if(dmalist[j] == 0)
{ {
printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name); printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name);
release_region(dev->base_addr, PROTEON_IO_EXTENT); goto out2;
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
} }
} }
else else
...@@ -267,52 +251,36 @@ int __init proteon_probe(struct net_device *dev) ...@@ -267,52 +251,36 @@ int __init proteon_probe(struct net_device *dev)
{ {
printk(KERN_INFO "%s: Illegal DMA %d specified\n", printk(KERN_INFO "%s: Illegal DMA %d specified\n",
dev->name, dev->dma); dev->name, dev->dma);
release_region(dev->base_addr, PROTEON_IO_EXTENT); goto out2;
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
} }
if (request_dma(dev->dma, cardname)) if (request_dma(dev->dma, cardname))
{ {
printk(KERN_INFO "%s: Selected DMA %d not available\n", printk(KERN_INFO "%s: Selected DMA %d not available\n",
dev->name, dev->dma); dev->name, dev->dma);
release_region(dev->base_addr, PROTEON_IO_EXTENT); goto out2;
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
} }
} }
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n", printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
dev->name, dev->base_addr, dev->irq, dev->dma); dev->name, dev->base_addr, dev->irq, dev->dma);
if (register_trdev(dev) == 0) /* Enlist in the card list */
{ card = kmalloc(sizeof(struct proteon_card), GFP_KERNEL);
/* Enlist in the card list */ if (!card)
card = kmalloc(sizeof(struct proteon_card), GFP_KERNEL); goto out;
if (!card) { card->next = proteon_card_list;
unregister_trdev(dev); proteon_card_list = card;
release_region(dev->base_addr, PROTEON_IO_EXTENT); card->dev = dev;
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
return -1;
}
card->next = proteon_card_list;
proteon_card_list = card;
card->dev = dev;
}
else
{
printk("KERN_INFO %s: register_trdev() returned non-zero.\n", dev->name);
release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
return -1;
}
return 0; return 0;
out:
free_dma(dev->dma);
out2:
free_irq(dev->irq, dev);
out3:
tmsdev_term(dev);
out4:
release_region(dev->base_addr, PROTEON_IO_EXTENT);
return -1;
} }
/* /*
...@@ -402,64 +370,51 @@ MODULE_PARM(io, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i"); ...@@ -402,64 +370,51 @@ MODULE_PARM(io, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
MODULE_PARM(irq, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i"); MODULE_PARM(irq, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
MODULE_PARM(dma, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i"); MODULE_PARM(dma, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
static int __init setup_card(unsigned long io, unsigned irq, unsigned char dma)
{
int res = -ENOMEM;
struct proteon_card *this_card;
struct net_device *dev = alloc_trdev(0);
if (dev) {
dev->base_addr = io;
dev->irq = irq;
dev->dma = dma;
res = -ENODEV;
if (proteon_probe(dev) == 0) {
res = register_netdev(dev);
if (!res)
return 0;
release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
this_card = proteon_card_list;
proteon_card_list = this_card->next;
kfree(this_card);
}
kfree(dev);
}
return res;
}
int init_module(void) int init_module(void)
{ {
int i, num; int i, num;
struct net_device *dev; struct net_device *dev;
num = 0; num = 0;
if (io[0]) if (io[0]) { /* Only probe addresses from command line */
{ /* Only probe addresses from command line */ for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
dev = init_trdev(NULL, 0); if (io[i] && setup_card(io[i], irq[i], dma[i]) == 0)
if (!dev)
return (-ENOMEM);
for (i = 0; i < ISATR_MAX_ADAPTERS; i++)
{
if (io[i] == 0)
continue;
dev->base_addr = io[i];
dev->irq = irq[i];
dev->dma = dma[i];
if (!proteon_probe(dev))
{
num++; num++;
dev = init_trdev(NULL, 0);
if (!dev)
goto partial;
}
} }
unregister_netdev(dev); } else {
kfree(dev); for(i = 0; num < ISATR_MAX_ADAPTERS && portlist[i]; i++) {
} if (setup_card(portlist[i], irq[i], dma[i]))
else
{
dev = init_trdev(NULL, 0);
if (!dev)
return (-ENOMEM);
for(i = 0; portlist[i]; i++)
{
if (num >= ISATR_MAX_ADAPTERS)
continue;
dev->base_addr = portlist[i];
dev->irq = irq[num];
dev->dma = dma[num];
if (!proteon_probe(dev))
{
num++; num++;
dev = init_trdev(NULL, 0);
if (!dev)
goto partial;
}
} }
unregister_netdev(dev);
kfree(dev);
} }
partial:
printk(KERN_NOTICE "proteon.c: %d cards found.\n", num); printk(KERN_NOTICE "proteon.c: %d cards found.\n", num);
/* Probe for cards. */ /* Probe for cards. */
if (num == 0) { if (num == 0) {
......
...@@ -141,6 +141,11 @@ int __init sk_isa_probe(struct net_device *dev) ...@@ -141,6 +141,11 @@ int __init sk_isa_probe(struct net_device *dev)
int i,j; int i,j;
struct sk_isa_card *card; struct sk_isa_card *card;
#ifndef MODULE
netdev_boot_setup_check(dev);
tr_setup(dev);
#endif
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
if (!dev->base_addr) if (!dev->base_addr)
{ {
...@@ -178,20 +183,8 @@ int __init sk_isa_probe(struct net_device *dev) ...@@ -178,20 +183,8 @@ int __init sk_isa_probe(struct net_device *dev)
if (versionprinted++ == 0) if (versionprinted++ == 0)
printk(KERN_DEBUG "%s", version); printk(KERN_DEBUG "%s", version);
#ifndef MODULE
dev = init_trdev(dev, 0);
if (!dev)
{
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
return -1;
}
#endif
if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL)) if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL))
{ goto out4;
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
return -1;
}
dev->base_addr &= ~3; dev->base_addr &= ~3;
...@@ -231,9 +224,7 @@ int __init sk_isa_probe(struct net_device *dev) ...@@ -231,9 +224,7 @@ int __init sk_isa_probe(struct net_device *dev)
if(irqlist[j] == 0) if(irqlist[j] == 0)
{ {
printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name); printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name);
release_region(dev->base_addr, SK_ISA_IO_EXTENT); goto out3;
tmsdev_term(dev);
return -1;
} }
} }
else else
...@@ -245,18 +236,14 @@ int __init sk_isa_probe(struct net_device *dev) ...@@ -245,18 +236,14 @@ int __init sk_isa_probe(struct net_device *dev)
{ {
printk(KERN_INFO "%s: Illegal IRQ %d specified\n", printk(KERN_INFO "%s: Illegal IRQ %d specified\n",
dev->name, dev->irq); dev->name, dev->irq);
release_region(dev->base_addr, SK_ISA_IO_EXTENT); goto out3;
tmsdev_term(dev);
return -1;
} }
if (request_irq(dev->irq, tms380tr_interrupt, 0, if (request_irq(dev->irq, tms380tr_interrupt, 0,
isa_cardname, dev)) isa_cardname, dev))
{ {
printk(KERN_INFO "%s: Selected IRQ %d not available\n", printk(KERN_INFO "%s: Selected IRQ %d not available\n",
dev->name, dev->irq); dev->name, dev->irq);
release_region(dev->base_addr, SK_ISA_IO_EXTENT); goto out3;
tmsdev_term(dev);
return -1;
} }
} }
...@@ -272,10 +259,7 @@ int __init sk_isa_probe(struct net_device *dev) ...@@ -272,10 +259,7 @@ int __init sk_isa_probe(struct net_device *dev)
if(dmalist[j] == 0) if(dmalist[j] == 0)
{ {
printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name); printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name);
release_region(dev->base_addr, SK_ISA_IO_EXTENT); goto out2;
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
} }
} }
else else
...@@ -287,52 +271,36 @@ int __init sk_isa_probe(struct net_device *dev) ...@@ -287,52 +271,36 @@ int __init sk_isa_probe(struct net_device *dev)
{ {
printk(KERN_INFO "%s: Illegal DMA %d specified\n", printk(KERN_INFO "%s: Illegal DMA %d specified\n",
dev->name, dev->dma); dev->name, dev->dma);
release_region(dev->base_addr, SK_ISA_IO_EXTENT); goto out2;
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
} }
if (request_dma(dev->dma, isa_cardname)) if (request_dma(dev->dma, isa_cardname))
{ {
printk(KERN_INFO "%s: Selected DMA %d not available\n", printk(KERN_INFO "%s: Selected DMA %d not available\n",
dev->name, dev->dma); dev->name, dev->dma);
release_region(dev->base_addr, SK_ISA_IO_EXTENT); goto out2;
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
} }
} }
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n", printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
dev->name, dev->base_addr, dev->irq, dev->dma); dev->name, dev->base_addr, dev->irq, dev->dma);
if (register_trdev(dev) == 0) /* Enlist in the card list */
{ card = kmalloc(sizeof(struct sk_isa_card), GFP_KERNEL);
/* Enlist in the card list */ if (!card)
card = kmalloc(sizeof(struct sk_isa_card), GFP_KERNEL); goto out;
if (!card) { card->next = sk_isa_card_list;
unregister_trdev(dev); sk_isa_card_list = card;
release_region(dev->base_addr, SK_ISA_IO_EXTENT); card->dev = dev;
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
return -1;
}
card->next = sk_isa_card_list;
sk_isa_card_list = card;
card->dev = dev;
}
else
{
printk("KERN_INFO %s: register_trdev() returned non-zero.\n", dev->name);
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
return -1;
}
return 0; return 0;
out:
free_dma(dev->dma);
out2:
free_irq(dev->irq, dev);
out3:
tmsdev_term(dev);
out4:
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
return -1;
} }
/* /*
...@@ -415,64 +383,51 @@ MODULE_PARM(io, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i"); ...@@ -415,64 +383,51 @@ MODULE_PARM(io, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
MODULE_PARM(irq, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i"); MODULE_PARM(irq, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
MODULE_PARM(dma, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i"); MODULE_PARM(dma, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
static int __init setup_card(unsigned long io, unsigned irq, unsigned char dma)
{
int res = -ENOMEM;
struct sk_isa_card *this_card;
struct net_device *dev = alloc_trdev(0);
if (dev) {
dev->base_addr = io;
dev->irq = irq;
dev->dma = dma;
res = -ENODEV;
if (sk_isa_probe(dev) == 0) {
res = register_netdev(dev);
if (!res)
return 0;
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
this_card = sk_isa_card_list;
sk_isa_card_list = this_card->next;
kfree(this_card);
}
kfree(dev);
}
return res;
}
int init_module(void) int init_module(void)
{ {
int i, num; int i, num;
struct net_device *dev; struct net_device *dev;
num = 0; num = 0;
if (io[0]) if (io[0]) { /* Only probe addresses from command line */
{ /* Only probe addresses from command line */ for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
dev = init_trdev(NULL, 0); if (io[i] && setup_card(io[i], irq[i], dma[i]) == 0)
if (!dev)
return (-ENOMEM);
for (i = 0; i < ISATR_MAX_ADAPTERS; i++)
{
if (io[i] == 0)
continue;
dev->base_addr = io[i];
dev->irq = irq[i];
dev->dma = dma[i];
if (!sk_isa_probe(dev))
{
num++; num++;
dev = init_trdev(NULL, 0);
if (!dev)
goto partial;
}
} }
unregister_netdev(dev); } else {
kfree(dev); for(i = 0; num < ISATR_MAX_ADAPTERS && portlist[i]; i++) {
} if (setup_card(portlist[i], irq[i], dma[i]))
else
{
dev = init_trdev(NULL, 0);
if (!dev)
return (-ENOMEM);
for(i = 0; portlist[i]; i++)
{
if (num >= ISATR_MAX_ADAPTERS)
continue;
dev->base_addr = portlist[i];
dev->irq = irq[num];
dev->dma = dma[num];
if (!sk_isa_probe(dev))
{
num++; num++;
dev = init_trdev(NULL, 0);
if (!dev)
goto partial;
}
} }
unregister_netdev(dev);
kfree(dev);
} }
partial:
printk(KERN_NOTICE "skisa.c: %d cards found.\n", num); printk(KERN_NOTICE "skisa.c: %d cards found.\n", num);
/* Probe for cards. */ /* Probe for cards. */
if (num == 0) { if (num == 0) {
......
This diff is collapsed.
...@@ -112,11 +112,11 @@ static int __init tms_pci_attach(struct pci_dev *pdev, const struct pci_device_i ...@@ -112,11 +112,11 @@ static int __init tms_pci_attach(struct pci_dev *pdev, const struct pci_device_i
pci_ioaddr = pci_resource_start (pdev, 0); pci_ioaddr = pci_resource_start (pdev, 0);
/* At this point we have found a valid card. */ /* At this point we have found a valid card. */
dev = init_trdev(NULL, 0); dev = alloc_trdev(0);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
if (!request_region(pci_ioaddr, TMS_PCI_IO_EXTENT, dev->name)) { if (!request_region(pci_ioaddr, TMS_PCI_IO_EXTENT, dev->name)) {
ret = -EBUSY; ret = -EBUSY;
goto err_out_trdev; goto err_out_trdev;
...@@ -163,22 +163,22 @@ static int __init tms_pci_attach(struct pci_dev *pdev, const struct pci_device_i ...@@ -163,22 +163,22 @@ static int __init tms_pci_attach(struct pci_dev *pdev, const struct pci_device_i
dev->open = tms380tr_open; dev->open = tms380tr_open;
dev->stop = tms380tr_close; dev->stop = tms380tr_close;
pci_set_drvdata(pdev, dev);
ret = register_trdev(dev); ret = register_netdev(dev);
if (ret) if (ret)
goto err_out_tmsdev; goto err_out_tmsdev;
pci_set_drvdata(pdev, dev);
return 0; return 0;
err_out_tmsdev: err_out_tmsdev:
pci_set_drvdata(pdev, NULL);
tmsdev_term(dev); tmsdev_term(dev);
err_out_irq: err_out_irq:
free_irq(pdev->irq, dev); free_irq(pdev->irq, dev);
err_out_region: err_out_region:
release_region(pci_ioaddr, TMS_PCI_IO_EXTENT); release_region(pci_ioaddr, TMS_PCI_IO_EXTENT);
err_out_trdev: err_out_trdev:
unregister_netdev(dev);
kfree(dev); kfree(dev);
return ret; return ret;
} }
......
...@@ -1751,30 +1751,29 @@ lcs_new_device(struct ccwgroup_device *ccwgdev) ...@@ -1751,30 +1751,29 @@ lcs_new_device(struct ccwgroup_device *ccwgdev)
#ifdef CONFIG_NET_ETHERNET #ifdef CONFIG_NET_ETHERNET
case LCS_FRAME_TYPE_ENET: case LCS_FRAME_TYPE_ENET:
card->lan_type_trans = eth_type_trans; card->lan_type_trans = eth_type_trans;
dev = init_etherdev(NULL,0); dev = alloc_etherdev(0);
break; break;
#endif #endif
#ifdef CONFIG_TR #ifdef CONFIG_TR
case LCS_FRAME_TYPE_TR: case LCS_FRAME_TYPE_TR:
card->lan_type_trans = tr_type_trans; card->lan_type_trans = tr_type_trans;
dev = init_trdev(NULL,0); dev = alloc_trdev(0);
break; break;
#endif #endif
#ifdef CONFIG_FDDI #ifdef CONFIG_FDDI
case LCS_FRAME_TYPE_FDDI: case LCS_FRAME_TYPE_FDDI:
card->lan_type_trans = fddi_type_trans; card->lan_type_trans = fddi_type_trans;
dev = init_fddidev(NULL,0); dev = alloc_fddidev(0);
break; break;
#endif #endif
default: default:
LCS_DBF_TEXT(3, setup, "errinit"); LCS_DBF_TEXT(3, setup, "errinit");
PRINT_ERR("LCS: Initialization failed\n"); PRINT_ERR("LCS: Initialization failed\n");
PRINT_ERR("LCS: No device found!\n"); PRINT_ERR("LCS: No device found!\n");
lcs_cleanup_channel(&card->read); goto out;
lcs_cleanup_channel(&card->write);
lcs_free_card(card);
return -ENODEV;
} }
if (!dev)
goto out;
memcpy(dev->dev_addr, card->mac, LCS_MAC_LENGTH); memcpy(dev->dev_addr, card->mac, LCS_MAC_LENGTH);
card->dev = dev; card->dev = dev;
dev->priv = card; dev->priv = card;
...@@ -1787,9 +1786,16 @@ lcs_new_device(struct ccwgroup_device *ccwgdev) ...@@ -1787,9 +1786,16 @@ lcs_new_device(struct ccwgroup_device *ccwgdev)
#endif #endif
dev->get_stats = lcs_getstats; dev->get_stats = lcs_getstats;
SET_MODULE_OWNER(&tun->dev); SET_MODULE_OWNER(&tun->dev);
if (register_netdev(dev) != 0)
goto out;
netif_stop_queue(dev); netif_stop_queue(dev);
lcs_stopcard(card); lcs_stopcard(card);
return 0; return 0;
out:
lcs_cleanup_channel(&card->read);
lcs_cleanup_channel(&card->write);
lcs_free_card(card);
return -ENODEV;
} }
/** /**
......
...@@ -861,12 +861,7 @@ static void __exit lane_module_cleanup(void) ...@@ -861,12 +861,7 @@ static void __exit lane_module_cleanup(void)
for (i = 0; i < MAX_LEC_ITF; i++) { for (i = 0; i < MAX_LEC_ITF; i++) {
if (dev_lec[i] != NULL) { if (dev_lec[i] != NULL) {
priv = (struct lec_priv *)dev_lec[i]->priv; priv = (struct lec_priv *)dev_lec[i]->priv;
#if defined(CONFIG_TR) unregister_netdev(dev_lec[i]);
if (priv->is_trdev)
unregister_trdev(dev_lec[i]);
else
#endif
unregister_netdev(dev_lec[i]);
kfree(dev_lec[i]); kfree(dev_lec[i]);
dev_lec[i] = NULL; dev_lec[i] = NULL;
} }
......
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