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) {
......
...@@ -143,7 +143,6 @@ static int smctr_hardware_send_packet(struct net_device *dev, ...@@ -143,7 +143,6 @@ static int smctr_hardware_send_packet(struct net_device *dev,
/* I */ /* I */
static int smctr_init_acbs(struct net_device *dev); static int smctr_init_acbs(struct net_device *dev);
static int smctr_init_adapter(struct net_device *dev); static int smctr_init_adapter(struct net_device *dev);
static int __init smctr_init_card(struct net_device *dev);
static int smctr_init_card_real(struct net_device *dev); static int smctr_init_card_real(struct net_device *dev);
static int smctr_init_rx_bdbs(struct net_device *dev); static int smctr_init_rx_bdbs(struct net_device *dev);
static int smctr_init_rx_fcbs(struct net_device *dev); static int smctr_init_rx_fcbs(struct net_device *dev);
...@@ -541,25 +540,18 @@ static int smctr_chk_mca(struct net_device *dev) ...@@ -541,25 +540,18 @@ static int smctr_chk_mca(struct net_device *dev)
dev->irq = 15; dev->irq = 15;
break; break;
} }
if(request_irq(dev->irq, smctr_interrupt, SA_SHIRQ, smctr_name, dev)) if (request_irq(dev->irq, smctr_interrupt, SA_SHIRQ, smctr_name, dev)) {
return (-ENODEV); release_region(dev->base_addr, SMCTR_IO_EXTENT);
return -ENODEV;
}
/* Get RAM base */ /* Get RAM base */
r3 = mca_read_stored_pos(tp->slot_num, 3); r3 = mca_read_stored_pos(tp->slot_num, 3);
if(r3 & 0x8)
{
if(r3 & 0x80)
tp->ram_base = ((__u32)(r3 & 0x7) << 13) + 0xFD0000;
else
tp->ram_base = ((__u32)(r3 & 0x7) << 13) + 0x0D0000;
}
else
{
if(r3 & 0x80)
tp->ram_base = ((__u32)(r3 & 0x7) << 13) + 0xFC0000;
else
tp->ram_base = ((__u32)(r3 & 0x7) << 13) + 0x0C0000; tp->ram_base = ((__u32)(r3 & 0x7) << 13) + 0x0C0000;
} if (r3 & 0x8)
tp->ram_base += 0x010000;
if (r3 & 0x80)
tp->ram_base += 0xF00000;
/* Get Ram Size */ /* Get Ram Size */
r3 &= 0x30; r3 &= 0x30;
...@@ -570,27 +562,25 @@ static int smctr_chk_mca(struct net_device *dev) ...@@ -570,27 +562,25 @@ static int smctr_chk_mca(struct net_device *dev)
tp->board_id |= TOKEN_MEDIA; tp->board_id |= TOKEN_MEDIA;
r4 = mca_read_stored_pos(tp->slot_num, 4); r4 = mca_read_stored_pos(tp->slot_num, 4);
if(r4 & 0x8) tp->rom_base = ((__u32)(r4 & 0x7) << 13) + 0x0C0000;
tp->rom_base = ((__u32)(r4 & 0x7) << 13) + 0xD0000; if (r4 & 0x8)
else tp->rom_base += 0x010000;
tp->rom_base = ((__u32)(r4 & 0x7) << 13) + 0xC0000;
/* Get ROM size. */ /* Get ROM size. */
r4 >>= 4; r4 >>= 4;
if(r4 == 0) switch (r4) {
case 0:
tp->rom_size = CNFG_SIZE_8KB; tp->rom_size = CNFG_SIZE_8KB;
else break;
{ case 1:
if(r4 == 1)
tp->rom_size = CNFG_SIZE_16KB; tp->rom_size = CNFG_SIZE_16KB;
else break;
{ case 2:
if(r4 == 2)
tp->rom_size = CNFG_SIZE_32KB; tp->rom_size = CNFG_SIZE_32KB;
else break;
default:
tp->rom_size = ROM_DISABLE; tp->rom_size = ROM_DISABLE;
} }
}
/* Get Media Type. */ /* Get Media Type. */
r5 = mca_read_stored_pos(tp->slot_num, 5); r5 = mca_read_stored_pos(tp->slot_num, 5);
...@@ -953,12 +943,19 @@ static int __init smctr_chk_isa(struct net_device *dev) ...@@ -953,12 +943,19 @@ static int __init smctr_chk_isa(struct net_device *dev)
__u8 r1, r2, b, chksum = 0; __u8 r1, r2, b, chksum = 0;
__u16 r; __u16 r;
int i; int i;
int err = -ENODEV;
if(smctr_debug > 10) if(smctr_debug > 10)
printk(KERN_DEBUG "%s: smctr_chk_isa %#4x\n", dev->name, ioaddr); printk(KERN_DEBUG "%s: smctr_chk_isa %#4x\n", dev->name, ioaddr);
if((ioaddr & 0x1F) != 0) if((ioaddr & 0x1F) != 0)
return (-ENODEV); goto out;
/* Grab the region so that no one else tries to probe our ioports. */
if (!request_region(ioaddr, SMCTR_IO_EXTENT, smctr_name)) {
err = -EBUSY;
goto out;
}
/* Checksum SMC node address */ /* Checksum SMC node address */
for(i = 0; i < 8; i++) for(i = 0; i < 8; i++)
...@@ -967,17 +964,14 @@ static int __init smctr_chk_isa(struct net_device *dev) ...@@ -967,17 +964,14 @@ static int __init smctr_chk_isa(struct net_device *dev)
chksum += b; chksum += b;
} }
if(chksum != NODE_ADDR_CKSUM) if (chksum != NODE_ADDR_CKSUM)
return (-ENODEV); /* Adapter Not Found */ goto out2;
/* Grab the region so that no one else tries to probe our ioports. */
request_region(ioaddr, SMCTR_IO_EXTENT, smctr_name);
b = inb(ioaddr + BDID); b = inb(ioaddr + BDID);
if(b != BRD_ID_8115T) if(b != BRD_ID_8115T)
{ {
printk(KERN_ERR "%s: The adapter found is not supported\n", dev->name); printk(KERN_ERR "%s: The adapter found is not supported\n", dev->name);
return (-1); goto out2;
} }
/* Check for 8115T Board ID */ /* Check for 8115T Board ID */
...@@ -990,7 +984,7 @@ static int __init smctr_chk_isa(struct net_device *dev) ...@@ -990,7 +984,7 @@ static int __init smctr_chk_isa(struct net_device *dev)
/* value of RegF adds up the sum to 0xFF */ /* value of RegF adds up the sum to 0xFF */
if((r2 != 0xFF) && (r2 != 0xEE)) if((r2 != 0xFF) && (r2 != 0xEE))
return (-1); goto out2;
/* Get adapter ID */ /* Get adapter ID */
tp->board_id = smctr_get_boardid(dev, 0); tp->board_id = smctr_get_boardid(dev, 0);
...@@ -1077,11 +1071,11 @@ static int __init smctr_chk_isa(struct net_device *dev) ...@@ -1077,11 +1071,11 @@ static int __init smctr_chk_isa(struct net_device *dev)
default: default:
printk(KERN_ERR "%s: No IRQ found aborting\n", dev->name); printk(KERN_ERR "%s: No IRQ found aborting\n", dev->name);
return(-1); goto out2;
} }
if(request_irq(dev->irq, smctr_interrupt, SA_SHIRQ, smctr_name, dev)) if (request_irq(dev->irq, smctr_interrupt, SA_SHIRQ, smctr_name, dev))
return (-ENODEV); goto out2;
/* Get 58x Rom Base */ /* Get 58x Rom Base */
r1 = inb(ioaddr + CNFG_BIO_583); r1 = inb(ioaddr + CNFG_BIO_583);
...@@ -1157,12 +1151,18 @@ static int __init smctr_chk_isa(struct net_device *dev) ...@@ -1157,12 +1151,18 @@ static int __init smctr_chk_isa(struct net_device *dev)
if(smctr_read_584_chksum(ioaddr)) if(smctr_read_584_chksum(ioaddr))
{ {
printk(KERN_ERR "%s: EEPROM Checksum Failure\n", dev->name); printk(KERN_ERR "%s: EEPROM Checksum Failure\n", dev->name);
return(-1); goto out3;
} }
*/ */
} }
return (0); return (0);
out3:
free_irq(dev->irq, dev);
out2:
release_region(ioaddr, SMCTR_IO_EXTENT);
out:
return err;
} }
static int __init smctr_get_boardid(struct net_device *dev, int mca) static int __init smctr_get_boardid(struct net_device *dev, int mca)
...@@ -1650,15 +1650,6 @@ static int smctr_init_adapter(struct net_device *dev) ...@@ -1650,15 +1650,6 @@ static int smctr_init_adapter(struct net_device *dev)
return (0); return (0);
} }
/* Dummy function */
static int __init smctr_init_card(struct net_device *dev)
{
if(smctr_debug > 10)
printk(KERN_DEBUG "%s: smctr_init_card\n", dev->name);
return (0);
}
static int smctr_init_card_real(struct net_device *dev) static int smctr_init_card_real(struct net_device *dev)
{ {
struct net_local *tp = (struct net_local *)dev->priv; struct net_local *tp = (struct net_local *)dev->priv;
...@@ -3608,8 +3599,14 @@ static int smctr_open_tr(struct net_device *dev) ...@@ -3608,8 +3599,14 @@ static int smctr_open_tr(struct net_device *dev)
int __init smctr_probe (struct net_device *dev) int __init smctr_probe (struct net_device *dev)
{ {
int i; int i;
int base_addr = dev ? dev->base_addr : 0; int base_addr;
#ifndef MODULE
netdev_boot_setup_check(dev);
tr_setup(dev);
#endif
base_addr = dev->base_addr;
if(base_addr > 0x1ff) /* Check a single specified location. */ if(base_addr > 0x1ff) /* Check a single specified location. */
return (smctr_probe1(dev, base_addr)); return (smctr_probe1(dev, base_addr));
else if(base_addr != 0) /* Don't probe at all. */ else if(base_addr != 0) /* Don't probe at all. */
...@@ -3618,8 +3615,6 @@ int __init smctr_probe (struct net_device *dev) ...@@ -3618,8 +3615,6 @@ int __init smctr_probe (struct net_device *dev)
for(i = 0; smctr_portlist[i]; i++) for(i = 0; smctr_portlist[i]; i++)
{ {
int ioaddr = smctr_portlist[i]; int ioaddr = smctr_portlist[i];
if(check_region(ioaddr, SMCTR_IO_EXTENT))
continue;
if (!smctr_probe1(dev, ioaddr)) if (!smctr_probe1(dev, ioaddr))
return (0); return (0);
} }
...@@ -3627,6 +3622,20 @@ int __init smctr_probe (struct net_device *dev) ...@@ -3627,6 +3622,20 @@ int __init smctr_probe (struct net_device *dev)
return (-ENODEV); return (-ENODEV);
} }
static void cleanup_card(struct net_device *dev)
{
#ifdef CONFIG_MCA
struct net_local *tp = (struct net_local *)dev->priv;
if (tp->slot_num)
mca_mark_as_unused(tp->slot_num);
#endif
release_region(dev->base_addr, SMCTR_IO_EXTENT);
if (dev->irq)
free_irq(dev->irq, dev);
if (dev->priv)
kfree(dev->priv);
}
static int __init smctr_probe1(struct net_device *dev, int ioaddr) static int __init smctr_probe1(struct net_device *dev, int ioaddr)
{ {
static unsigned version_printed; static unsigned version_printed;
...@@ -3637,12 +3646,6 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr) ...@@ -3637,12 +3646,6 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr)
if(smctr_debug && version_printed++ == 0) if(smctr_debug && version_printed++ == 0)
printk(version); printk(version);
#ifndef MODULE
dev = init_trdev(dev, 0);
if(dev == NULL)
return (-ENOMEM);
#endif
/* Setup this devices private information structure */ /* Setup this devices private information structure */
tp = (struct net_local *)kmalloc(sizeof(struct net_local), tp = (struct net_local *)kmalloc(sizeof(struct net_local),
GFP_KERNEL); GFP_KERNEL);
...@@ -3677,8 +3680,9 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr) ...@@ -3677,8 +3680,9 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr)
if(err != UCODE_PRESENT && err != SUCCESS) if(err != UCODE_PRESENT && err != SUCCESS)
{ {
printk(KERN_ERR "%s: Firmware load failed (%d)\n", dev->name, err); printk(KERN_ERR "%s: Firmware load failed (%d)\n", dev->name, err);
cleanup_card(dev);
err = -EIO; err = -EIO;
goto out_tp; goto out;
} }
/* Allow user to specify ring speed on module insert. */ /* Allow user to specify ring speed on module insert. */
...@@ -3692,8 +3696,6 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr) ...@@ -3692,8 +3696,6 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr)
(unsigned int)dev->base_addr, (unsigned int)dev->base_addr,
dev->irq, tp->rom_base, tp->ram_base); dev->irq, tp->rom_base, tp->ram_base);
/* AKPM: there's no point in this */
dev->init = smctr_init_card;
dev->open = smctr_open; dev->open = smctr_open;
dev->stop = smctr_close; dev->stop = smctr_close;
dev->hard_start_xmit = smctr_send_packet; dev->hard_start_xmit = smctr_send_packet;
...@@ -5689,33 +5691,31 @@ int init_module(void) ...@@ -5689,33 +5691,31 @@ int init_module(void)
{ {
int i; int i;
for(i = 0; i < SMCTR_MAX_ADAPTERS; i++) for(i = 0; i < SMCTR_MAX_ADAPTERS; i++) {
{ struct net_device *dev = alloc_trdev(0);
irq[i] = 0; irq[i] = 0;
mem[i] = 0; mem[i] = 0;
dev_smctr[i] = NULL; if (!dev)
dev_smctr[i] = init_trdev(dev_smctr[i], 0); return -ENOMEM;
if(dev_smctr[i] == NULL) dev->base_addr = io[i];
return (-ENOMEM); dev->irq = irq[i];
dev->mem_start = mem[i];
dev_smctr[i]->base_addr = io[i];
dev_smctr[i]->irq = irq[i]; if (smctr_probe(dev) != 0) {
dev_smctr[i]->mem_start = mem[i]; kfree(dev);
dev_smctr[i]->init = &smctr_probe; if (i == 0) {
printk(KERN_ERR "%s: smctr_probe failed.\n",
if(register_trdev(dev_smctr[i]) != 0)
{
kfree(dev_smctr[i]);
dev_smctr[i] = NULL;
if(i == 0)
{
printk(KERN_ERR "%s: register_trdev() returned (<0).\n",
cardname); cardname);
return (-EIO); return -EIO;
} }
else return 0;
return (0); }
if (register_netdev(dev) != 0) {
cleanup_card(dev);
kfree(dev);
continue;
} }
dev_smctr[i] = dev;
} }
return (0); return (0);
...@@ -5725,25 +5725,12 @@ void cleanup_module(void) ...@@ -5725,25 +5725,12 @@ void cleanup_module(void)
{ {
int i; int i;
for(i = 0; i < SMCTR_MAX_ADAPTERS; i++) for(i = 0; i < SMCTR_MAX_ADAPTERS; i++) {
{ struct net_device *dev = dev_smctr[i];
if(dev_smctr[i]) if (dev) {
{ unregister_netdev(dev);
#ifdef CONFIG_MCA cleanup_card(dev);
struct net_local *tp kfree(dev);
= (struct net_local *)dev_smctr[i]->priv;
if(tp->slot_num)
mca_mark_as_unused(tp->slot_num);
#endif
unregister_trdev(dev_smctr[i]);
release_region(dev_smctr[i]->base_addr,
SMCTR_IO_EXTENT);
if(dev_smctr[i]->irq)
free_irq(dev_smctr[i]->irq, dev_smctr[i]);
if(dev_smctr[i]->priv)
kfree(dev_smctr[i]->priv);
kfree(dev_smctr[i]);
dev_smctr[i] = NULL;
} }
} }
} }
......
...@@ -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