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;
} }
......
...@@ -221,11 +221,11 @@ struct streamer_private *dev_streamer=NULL; ...@@ -221,11 +221,11 @@ struct streamer_private *dev_streamer=NULL;
static int __devinit streamer_init_one(struct pci_dev *pdev, static int __devinit streamer_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
struct net_device *dev=NULL; struct net_device *dev;
struct streamer_private *streamer_priv; struct streamer_private *streamer_priv;
__u32 pio_start, pio_end, pio_flags, pio_len; __u32 pio_start, pio_end, pio_flags, pio_len;
__u32 mmio_start, mmio_end, mmio_flags, mmio_len; __u32 mmio_start, mmio_end, mmio_flags, mmio_len;
int rc=0; int rc = 0;
static int card_no=-1; static int card_no=-1;
u16 pcr; u16 pcr;
u8 cls = 0; u8 cls = 0;
...@@ -235,26 +235,28 @@ static int __devinit streamer_init_one(struct pci_dev *pdev, ...@@ -235,26 +235,28 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
#endif #endif
card_no++; card_no++;
dev=init_trdev(dev, sizeof(*streamer_priv)); dev = alloc_trdev(sizeof(*streamer_priv));
if(dev==NULL) { if (dev==NULL) {
printk(KERN_ERR "lanstreamer: out of memory.\n"); printk(KERN_ERR "lanstreamer: out of memory.\n");
return -ENOMEM; return -ENOMEM;
} }
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
streamer_priv=dev->priv; streamer_priv = dev->priv;
#if STREAMER_NETWORK_MONITOR #if STREAMER_NETWORK_MONITOR
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
if (!dev_streamer) { if (!dev_streamer)
create_proc_read_entry("net/streamer_tr",0,0,streamer_proc_info,NULL); create_proc_read_entry("net/streamer_tr", 0, 0,
} streamer_proc_info, NULL);
streamer_priv->next=dev_streamer; streamer_priv->next = dev_streamer;
dev_streamer=streamer_priv; dev_streamer = streamer_priv;
#endif #endif
#endif #endif
if(pci_set_dma_mask(pdev, 0xFFFFFFFF)) { if (pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
printk(KERN_ERR "%s: No suitable PCI mapping available.\n", dev->name); printk(KERN_ERR "%s: No suitable PCI mapping available.\n",
dev->name);
rc = -ENODEV; rc = -ENODEV;
goto err_out; goto err_out;
} }
...@@ -285,20 +287,23 @@ static int __devinit streamer_init_one(struct pci_dev *pdev, ...@@ -285,20 +287,23 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
#endif #endif
if (!request_region(pio_start, pio_len, "lanstreamer")) { if (!request_region(pio_start, pio_len, "lanstreamer")) {
printk(KERN_ERR "lanstreamer: unable to get pci io addr %x\n",pio_start); printk(KERN_ERR "lanstreamer: unable to get pci io addr %x\n",
pio_start);
rc= -EBUSY; rc= -EBUSY;
goto err_out; goto err_out;
} }
if (!request_mem_region(mmio_start, mmio_len, "lanstreamer")) { if (!request_mem_region(mmio_start, mmio_len, "lanstreamer")) {
printk(KERN_ERR "lanstreamer: unable to get pci mmio addr %x\n",mmio_start); printk(KERN_ERR "lanstreamer: unable to get pci mmio addr %x\n",
mmio_start);
rc= -EBUSY; rc= -EBUSY;
goto err_out_free_pio; goto err_out_free_pio;
} }
streamer_priv->streamer_mmio=ioremap(mmio_start, mmio_len); streamer_priv->streamer_mmio=ioremap(mmio_start, mmio_len);
if (streamer_priv->streamer_mmio == NULL) { if (streamer_priv->streamer_mmio == NULL) {
printk(KERN_ERR "lanstreamer: unable to remap MMIO %x\n",mmio_start); printk(KERN_ERR "lanstreamer: unable to remap MMIO %x\n",
mmio_start);
rc= -EIO; rc= -EIO;
goto err_out_free_mmio; goto err_out_free_mmio;
} }
...@@ -322,7 +327,7 @@ static int __devinit streamer_init_one(struct pci_dev *pdev, ...@@ -322,7 +327,7 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
dev->base_addr=pio_start; dev->base_addr=pio_start;
streamer_priv->streamer_card_name = (char *)pdev->resource[0].name; streamer_priv->streamer_card_name = (char *)pdev->resource[0].name;
streamer_priv->pci_dev=pdev; streamer_priv->pci_dev = pdev;
if ((pkt_buf_sz[card_no] < 100) || (pkt_buf_sz[card_no] > 18000)) if ((pkt_buf_sz[card_no] < 100) || (pkt_buf_sz[card_no] > 18000))
streamer_priv->pkt_buf_sz = PKT_BUF_SZ; streamer_priv->pkt_buf_sz = PKT_BUF_SZ;
...@@ -364,17 +369,21 @@ static int __devinit streamer_init_one(struct pci_dev *pdev, ...@@ -364,17 +369,21 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
streamer_priv->streamer_mmio, streamer_priv->streamer_mmio,
dev->irq); dev->irq);
if (!streamer_reset(dev)) { if (streamer_reset(dev))
goto err_out_unmap;
rc = register_netdev(dev);
if (rc)
goto err_out_unmap;
return 0; return 0;
}
err_out_unmap;
iounmap(streamer_priv->streamer_mmio); iounmap(streamer_priv->streamer_mmio);
err_out_free_mmio: err_out_free_mmio:
release_mem_region(mmio_start, mmio_len); release_mem_region(mmio_start, mmio_len);
err_out_free_pio: err_out_free_pio:
release_region(pio_start, pio_len); release_region(pio_start, pio_len);
err_out: err_out:
unregister_trdev(dev);
kfree(dev); kfree(dev);
#if STREAMER_DEBUG #if STREAMER_DEBUG
printk("lanstreamer: Exit error %x\n",rc); printk("lanstreamer: Exit error %x\n",rc);
...@@ -382,8 +391,10 @@ static int __devinit streamer_init_one(struct pci_dev *pdev, ...@@ -382,8 +391,10 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
return rc; return rc;
} }
static void __devexit streamer_remove_one(struct pci_dev *pdev) { static void __devexit streamer_remove_one(struct pci_dev *pdev)
{
struct net_device *dev=pci_get_drvdata(pdev); struct net_device *dev=pci_get_drvdata(pdev);
struct streamer_private **p = &dev_streamer, **next;
struct streamer_private *streamer_priv; struct streamer_private *streamer_priv;
#if STREAMER_DEBUG #if STREAMER_DEBUG
...@@ -403,27 +414,20 @@ static void __devexit streamer_remove_one(struct pci_dev *pdev) { ...@@ -403,27 +414,20 @@ static void __devexit streamer_remove_one(struct pci_dev *pdev) {
#if STREAMER_NETWORK_MONITOR #if STREAMER_NETWORK_MONITOR
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
{ for (p = &dev_streamer; *p; p = next) {
struct streamer_private *slast; next = &(*p)->next;
struct streamer_private *scurrent; if (*p == streamer_priv) {
if (streamer_priv == dev_streamer) { *p = *next;
dev_streamer=dev_streamer->next;
} else {
for(slast=scurrent=dev_streamer; dev_streamer; slast=scurrent, scurrent=scurrent->next) {
if (scurrent == streamer_priv) {
slast->next=scurrent->next;
break; break;
} }
} }
} if (!dev_streamer)
if (!dev_streamer) {
remove_proc_entry("net/streamer_tr", NULL); remove_proc_entry("net/streamer_tr", NULL);
}
}
#endif #endif
#endif #endif
unregister_trdev(dev); unregister_netdev(dev);
/* shouldn't we do iounmap here? */
release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev,0)); release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev,0));
release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev,1)); release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev,1));
kfree(dev); kfree(dev);
......
...@@ -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;
...@@ -383,32 +385,21 @@ static int __init madgemc_probe(void) ...@@ -383,32 +385,21 @@ 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 {
printk("madgemc: register_trdev() returned non-zero.\n");
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++; slot++;
continue; /* successful, try to find another */ 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 */ /* Enlist in the card list */
card = kmalloc(sizeof(struct proteon_card), GFP_KERNEL); card = kmalloc(sizeof(struct proteon_card), GFP_KERNEL);
if (!card) { if (!card)
unregister_trdev(dev); goto out;
release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
return -1;
}
card->next = proteon_card_list; card->next = proteon_card_list;
proteon_card_list = card; proteon_card_list = card;
card->dev = dev; card->dev = dev;
} return 0;
else out:
{
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); free_dma(dev->dma);
out2:
free_irq(dev->irq, dev);
out3:
tmsdev_term(dev); tmsdev_term(dev);
out4:
release_region(dev->base_addr, PROTEON_IO_EXTENT);
return -1; return -1;
}
return 0;
} }
/* /*
...@@ -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 */ /* Enlist in the card list */
card = kmalloc(sizeof(struct sk_isa_card), GFP_KERNEL); card = kmalloc(sizeof(struct sk_isa_card), GFP_KERNEL);
if (!card) { if (!card)
unregister_trdev(dev); goto out;
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
return -1;
}
card->next = sk_isa_card_list; card->next = sk_isa_card_list;
sk_isa_card_list = card; sk_isa_card_list = card;
card->dev = dev; card->dev = dev;
} return 0;
else out:
{
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); free_dma(dev->dma);
out2:
free_irq(dev->irq, dev);
out3:
tmsdev_term(dev); tmsdev_term(dev);
out4:
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
return -1; return -1;
}
return 0;
} }
/* /*
...@@ -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,7 +112,7 @@ static int __init tms_pci_attach(struct pci_dev *pdev, const struct pci_device_i ...@@ -112,7 +112,7 @@ 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);
...@@ -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,11 +861,6 @@ static void __exit lane_module_cleanup(void) ...@@ -861,11 +861,6 @@ 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)
if (priv->is_trdev)
unregister_trdev(dev_lec[i]);
else
#endif
unregister_netdev(dev_lec[i]); 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