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)
netif_stop_queue(dev) ;
xl_freemem(dev) ;
free_irq(dev->irq,dev);
unregister_trdev(dev) ;
unregister_netdev(dev) ;
kfree(dev) ;
xl_reset(dev) ;
writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ;
......@@ -1783,7 +1783,7 @@ static void __devexit xl_remove_one (struct pci_dev *pdev)
struct net_device *dev = pci_get_drvdata(pdev);
struct xl_private *xl_priv=(struct xl_private *)dev->priv;
unregister_trdev(dev);
unregister_netdev(dev);
iounmap(xl_priv->xl_mmio) ;
pci_release_regions(pdev) ;
pci_set_drvdata(pdev,NULL) ;
......
......@@ -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. */
dev = init_trdev(NULL, 0);
dev = alloc_trdev(0);
if (!dev)
return -ENOMEM;
SET_MODULE_OWNER(dev);
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
dev->open = abyss_open;
dev->stop = abyss_close;
ret = register_trdev(dev);
pci_set_drvdata(pdev, dev);
ret = register_netdev(dev);
if (ret)
goto err_out_tmsdev;
pci_set_drvdata(pdev, dev);
return 0;
err_out_tmsdev:
pci_set_drvdata(pdev, NULL);
tmsdev_term(dev);
err_out_irq:
free_irq(pdev->irq, dev);
err_out_region:
release_region(pci_ioaddr, ABYSS_IO_EXTENT);
err_out_trdev:
unregister_netdev(dev);
kfree(dev);
return ret;
}
......
......@@ -221,11 +221,11 @@ struct streamer_private *dev_streamer=NULL;
static int __devinit streamer_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct net_device *dev=NULL;
struct net_device *dev;
struct streamer_private *streamer_priv;
__u32 pio_start, pio_end, pio_flags, pio_len;
__u32 mmio_start, mmio_end, mmio_flags, mmio_len;
int rc=0;
int rc = 0;
static int card_no=-1;
u16 pcr;
u8 cls = 0;
......@@ -235,26 +235,28 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
#endif
card_no++;
dev=init_trdev(dev, sizeof(*streamer_priv));
if(dev==NULL) {
dev = alloc_trdev(sizeof(*streamer_priv));
if (dev==NULL) {
printk(KERN_ERR "lanstreamer: out of memory.\n");
return -ENOMEM;
}
SET_MODULE_OWNER(dev);
streamer_priv=dev->priv;
streamer_priv = dev->priv;
#if STREAMER_NETWORK_MONITOR
#ifdef CONFIG_PROC_FS
if (!dev_streamer) {
create_proc_read_entry("net/streamer_tr",0,0,streamer_proc_info,NULL);
}
streamer_priv->next=dev_streamer;
dev_streamer=streamer_priv;
if (!dev_streamer)
create_proc_read_entry("net/streamer_tr", 0, 0,
streamer_proc_info, NULL);
streamer_priv->next = dev_streamer;
dev_streamer = streamer_priv;
#endif
#endif
if(pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
printk(KERN_ERR "%s: No suitable PCI mapping available.\n", dev->name);
if (pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
printk(KERN_ERR "%s: No suitable PCI mapping available.\n",
dev->name);
rc = -ENODEV;
goto err_out;
}
......@@ -285,20 +287,23 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
#endif
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;
goto err_out;
}
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;
goto err_out_free_pio;
}
streamer_priv->streamer_mmio=ioremap(mmio_start, mmio_len);
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;
goto err_out_free_mmio;
}
......@@ -322,7 +327,7 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
dev->base_addr=pio_start;
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))
streamer_priv->pkt_buf_sz = PKT_BUF_SZ;
......@@ -364,17 +369,21 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
streamer_priv->streamer_mmio,
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;
}
err_out_unmap;
iounmap(streamer_priv->streamer_mmio);
err_out_free_mmio:
release_mem_region(mmio_start, mmio_len);
err_out_free_pio:
release_region(pio_start, pio_len);
err_out:
unregister_trdev(dev);
kfree(dev);
#if STREAMER_DEBUG
printk("lanstreamer: Exit error %x\n",rc);
......@@ -382,8 +391,10 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
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 streamer_private **p = &dev_streamer, **next;
struct streamer_private *streamer_priv;
#if STREAMER_DEBUG
......@@ -403,27 +414,20 @@ static void __devexit streamer_remove_one(struct pci_dev *pdev) {
#if STREAMER_NETWORK_MONITOR
#ifdef CONFIG_PROC_FS
{
struct streamer_private *slast;
struct streamer_private *scurrent;
if (streamer_priv == dev_streamer) {
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;
for (p = &dev_streamer; *p; p = next) {
next = &(*p)->next;
if (*p == streamer_priv) {
*p = *next;
break;
}
}
}
if (!dev_streamer) {
if (!dev_streamer)
remove_proc_entry("net/streamer_tr", NULL);
}
}
#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_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev,1));
kfree(dev);
......
......@@ -177,12 +177,14 @@ static int __init madgemc_probe(void)
if (versionprinted++ == 0)
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");
if (madgemc_card_list)
return 0;
return -1;
}
SET_MODULE_OWNER(dev);
dev->dma = 0;
......@@ -195,7 +197,7 @@ static int __init madgemc_probe(void)
card = kmalloc(sizeof(struct madgemc_card), GFP_KERNEL);
if (card==NULL) {
printk("madgemc: unable to allocate card struct\n");
kfree(dev); /* release_trdev? */
kfree(dev);
if (madgemc_card_list)
return 0;
return -1;
......@@ -331,7 +333,7 @@ static int __init madgemc_probe(void)
*/
outb(0, dev->base_addr + MC_CONTROL_REG0); /* sanity */
madgemc_setsifsel(dev, 1);
if(request_irq(dev->irq, madgemc_interrupt, SA_SHIRQ,
if (request_irq(dev->irq, madgemc_interrupt, SA_SHIRQ,
"madgemc", dev))
goto getout;
......@@ -383,32 +385,21 @@ static int __init madgemc_probe(void)
dev->open = madgemc_open;
dev->stop = madgemc_close;
if (register_trdev(dev) == 0) {
if (register_netdev(dev) == 0) {
/* Enlist in the card list */
card->next = madgemc_card_list;
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++;
continue; /* successful, try to find another */
}
free_irq(dev->irq, dev);
getout:
release_region(dev->base_addr-MADGEMC_SIF_OFFSET,
MADGEMC_IO_EXTENT);
getout1:
kfree(card);
kfree(dev); /* release_trdev? */
kfree(dev);
slot++;
}
......@@ -779,7 +770,7 @@ static void __exit madgemc_exit(void)
while (madgemc_card_list) {
dev = madgemc_card_list->dev;
unregister_trdev(dev);
unregister_netdev(dev);
release_region(dev->base_addr-MADGEMC_SIF_OFFSET, MADGEMC_IO_EXTENT);
free_irq(dev->irq, dev);
tmsdev_term(dev);
......
......@@ -1773,7 +1773,7 @@ static void __devexit olympic_remove_one(struct pci_dev *pdev)
strcat(proc_name,dev->name) ;
remove_proc_entry(proc_name,NULL);
}
unregister_trdev(dev) ;
unregister_netdev(dev) ;
iounmap(olympic_priv->olympic_mmio) ;
iounmap(olympic_priv->olympic_lap) ;
pci_release_regions(pdev) ;
......
......@@ -121,6 +121,11 @@ int __init proteon_probe(struct net_device *dev)
int i,j;
struct proteon_card *card;
#ifndef MODULE
netdev_boot_setup_check(dev);
tr_setup(dev);
#endif
SET_MODULE_OWNER(dev);
if (!dev->base_addr)
{
......@@ -158,20 +163,8 @@ int __init proteon_probe(struct net_device *dev)
if (versionprinted++ == 0)
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))
{
release_region(dev->base_addr, PROTEON_IO_EXTENT);
return -1;
}
goto out4;
dev->base_addr &= ~3;
......@@ -211,9 +204,7 @@ int __init proteon_probe(struct net_device *dev)
if(irqlist[j] == 0)
{
printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name);
release_region(dev->base_addr, PROTEON_IO_EXTENT);
tmsdev_term(dev);
return -1;
goto out3;
}
}
else
......@@ -225,18 +216,14 @@ int __init proteon_probe(struct net_device *dev)
{
printk(KERN_INFO "%s: Illegal IRQ %d specified\n",
dev->name, dev->irq);
release_region(dev->base_addr, PROTEON_IO_EXTENT);
tmsdev_term(dev);
return -1;
goto out3;
}
if (request_irq(dev->irq, tms380tr_interrupt, 0,
cardname, dev))
{
printk(KERN_INFO "%s: Selected IRQ %d not available\n",
dev->name, dev->irq);
release_region(dev->base_addr, PROTEON_IO_EXTENT);
tmsdev_term(dev);
return -1;
goto out3;
}
}
......@@ -252,10 +239,7 @@ int __init proteon_probe(struct net_device *dev)
if(dmalist[j] == 0)
{
printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name);
release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
goto out2;
}
}
else
......@@ -267,52 +251,36 @@ int __init proteon_probe(struct net_device *dev)
{
printk(KERN_INFO "%s: Illegal DMA %d specified\n",
dev->name, dev->dma);
release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
goto out2;
}
if (request_dma(dev->dma, cardname))
{
printk(KERN_INFO "%s: Selected DMA %d not available\n",
dev->name, dev->dma);
release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
goto out2;
}
}
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
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);
if (!card) {
unregister_trdev(dev);
release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
return -1;
}
if (!card)
goto out;
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);
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;
}
return 0;
}
/*
......@@ -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(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 i, num;
struct net_device *dev;
num = 0;
if (io[0])
{ /* Only probe addresses from command line */
dev = init_trdev(NULL, 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))
{
if (io[0]) { /* Only probe addresses from command line */
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
if (io[i] && setup_card(io[i], irq[i], dma[i]) == 0)
num++;
dev = init_trdev(NULL, 0);
if (!dev)
goto partial;
}
}
unregister_netdev(dev);
kfree(dev);
}
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))
{
} else {
for(i = 0; num < ISATR_MAX_ADAPTERS && portlist[i]; i++) {
if (setup_card(portlist[i], irq[i], dma[i]))
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);
/* Probe for cards. */
if (num == 0) {
......
......@@ -141,6 +141,11 @@ int __init sk_isa_probe(struct net_device *dev)
int i,j;
struct sk_isa_card *card;
#ifndef MODULE
netdev_boot_setup_check(dev);
tr_setup(dev);
#endif
SET_MODULE_OWNER(dev);
if (!dev->base_addr)
{
......@@ -178,20 +183,8 @@ int __init sk_isa_probe(struct net_device *dev)
if (versionprinted++ == 0)
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))
{
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
return -1;
}
goto out4;
dev->base_addr &= ~3;
......@@ -231,9 +224,7 @@ int __init sk_isa_probe(struct net_device *dev)
if(irqlist[j] == 0)
{
printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name);
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
tmsdev_term(dev);
return -1;
goto out3;
}
}
else
......@@ -245,18 +236,14 @@ int __init sk_isa_probe(struct net_device *dev)
{
printk(KERN_INFO "%s: Illegal IRQ %d specified\n",
dev->name, dev->irq);
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
tmsdev_term(dev);
return -1;
goto out3;
}
if (request_irq(dev->irq, tms380tr_interrupt, 0,
isa_cardname, dev))
{
printk(KERN_INFO "%s: Selected IRQ %d not available\n",
dev->name, dev->irq);
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
tmsdev_term(dev);
return -1;
goto out3;
}
}
......@@ -272,10 +259,7 @@ int __init sk_isa_probe(struct net_device *dev)
if(dmalist[j] == 0)
{
printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name);
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
goto out2;
}
}
else
......@@ -287,52 +271,36 @@ int __init sk_isa_probe(struct net_device *dev)
{
printk(KERN_INFO "%s: Illegal DMA %d specified\n",
dev->name, dev->dma);
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
goto out2;
}
if (request_dma(dev->dma, isa_cardname))
{
printk(KERN_INFO "%s: Selected DMA %d not available\n",
dev->name, dev->dma);
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev);
tmsdev_term(dev);
return -1;
goto out2;
}
}
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
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);
if (!card) {
unregister_trdev(dev);
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
return -1;
}
if (!card)
goto out;
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);
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;
}
return 0;
}
/*
......@@ -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(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 i, num;
struct net_device *dev;
num = 0;
if (io[0])
{ /* Only probe addresses from command line */
dev = init_trdev(NULL, 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))
{
if (io[0]) { /* Only probe addresses from command line */
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
if (io[i] && setup_card(io[i], irq[i], dma[i]) == 0)
num++;
dev = init_trdev(NULL, 0);
if (!dev)
goto partial;
}
}
unregister_netdev(dev);
kfree(dev);
}
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))
{
} else {
for(i = 0; num < ISATR_MAX_ADAPTERS && portlist[i]; i++) {
if (setup_card(portlist[i], irq[i], dma[i]))
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);
/* Probe for cards. */
if (num == 0) {
......
......@@ -143,7 +143,6 @@ static int smctr_hardware_send_packet(struct net_device *dev,
/* I */
static int smctr_init_acbs(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_rx_bdbs(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)
dev->irq = 15;
break;
}
if(request_irq(dev->irq, smctr_interrupt, SA_SHIRQ, smctr_name, dev))
return (-ENODEV);
if (request_irq(dev->irq, smctr_interrupt, SA_SHIRQ, smctr_name, dev)) {
release_region(dev->base_addr, SMCTR_IO_EXTENT);
return -ENODEV;
}
/* Get RAM base */
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;
}
if (r3 & 0x8)
tp->ram_base += 0x010000;
if (r3 & 0x80)
tp->ram_base += 0xF00000;
/* Get Ram Size */
r3 &= 0x30;
......@@ -570,27 +562,25 @@ static int smctr_chk_mca(struct net_device *dev)
tp->board_id |= TOKEN_MEDIA;
r4 = mca_read_stored_pos(tp->slot_num, 4);
if(r4 & 0x8)
tp->rom_base = ((__u32)(r4 & 0x7) << 13) + 0xD0000;
else
tp->rom_base = ((__u32)(r4 & 0x7) << 13) + 0xC0000;
tp->rom_base = ((__u32)(r4 & 0x7) << 13) + 0x0C0000;
if (r4 & 0x8)
tp->rom_base += 0x010000;
/* Get ROM size. */
r4 >>= 4;
if(r4 == 0)
switch (r4) {
case 0:
tp->rom_size = CNFG_SIZE_8KB;
else
{
if(r4 == 1)
break;
case 1:
tp->rom_size = CNFG_SIZE_16KB;
else
{
if(r4 == 2)
break;
case 2:
tp->rom_size = CNFG_SIZE_32KB;
else
break;
default:
tp->rom_size = ROM_DISABLE;
}
}
/* Get Media Type. */
r5 = mca_read_stored_pos(tp->slot_num, 5);
......@@ -953,12 +943,19 @@ static int __init smctr_chk_isa(struct net_device *dev)
__u8 r1, r2, b, chksum = 0;
__u16 r;
int i;
int err = -ENODEV;
if(smctr_debug > 10)
printk(KERN_DEBUG "%s: smctr_chk_isa %#4x\n", dev->name, ioaddr);
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 */
for(i = 0; i < 8; i++)
......@@ -967,17 +964,14 @@ static int __init smctr_chk_isa(struct net_device *dev)
chksum += b;
}
if(chksum != NODE_ADDR_CKSUM)
return (-ENODEV); /* Adapter Not Found */
/* Grab the region so that no one else tries to probe our ioports. */
request_region(ioaddr, SMCTR_IO_EXTENT, smctr_name);
if (chksum != NODE_ADDR_CKSUM)
goto out2;
b = inb(ioaddr + BDID);
if(b != BRD_ID_8115T)
{
printk(KERN_ERR "%s: The adapter found is not supported\n", dev->name);
return (-1);
goto out2;
}
/* Check for 8115T Board ID */
......@@ -990,7 +984,7 @@ static int __init smctr_chk_isa(struct net_device *dev)
/* value of RegF adds up the sum to 0xFF */
if((r2 != 0xFF) && (r2 != 0xEE))
return (-1);
goto out2;
/* Get adapter ID */
tp->board_id = smctr_get_boardid(dev, 0);
......@@ -1077,11 +1071,11 @@ static int __init smctr_chk_isa(struct net_device *dev)
default:
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))
return (-ENODEV);
if (request_irq(dev->irq, smctr_interrupt, SA_SHIRQ, smctr_name, dev))
goto out2;
/* Get 58x Rom Base */
r1 = inb(ioaddr + CNFG_BIO_583);
......@@ -1157,12 +1151,18 @@ static int __init smctr_chk_isa(struct net_device *dev)
if(smctr_read_584_chksum(ioaddr))
{
printk(KERN_ERR "%s: EEPROM Checksum Failure\n", dev->name);
return(-1);
goto out3;
}
*/
}
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)
......@@ -1650,15 +1650,6 @@ static int smctr_init_adapter(struct net_device *dev)
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)
{
struct net_local *tp = (struct net_local *)dev->priv;
......@@ -3608,8 +3599,14 @@ static int smctr_open_tr(struct net_device *dev)
int __init smctr_probe (struct net_device *dev)
{
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. */
return (smctr_probe1(dev, base_addr));
else if(base_addr != 0) /* Don't probe at all. */
......@@ -3618,8 +3615,6 @@ int __init smctr_probe (struct net_device *dev)
for(i = 0; smctr_portlist[i]; i++)
{
int ioaddr = smctr_portlist[i];
if(check_region(ioaddr, SMCTR_IO_EXTENT))
continue;
if (!smctr_probe1(dev, ioaddr))
return (0);
}
......@@ -3627,6 +3622,20 @@ int __init smctr_probe (struct net_device *dev)
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 unsigned version_printed;
......@@ -3637,12 +3646,6 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr)
if(smctr_debug && version_printed++ == 0)
printk(version);
#ifndef MODULE
dev = init_trdev(dev, 0);
if(dev == NULL)
return (-ENOMEM);
#endif
/* Setup this devices private information structure */
tp = (struct net_local *)kmalloc(sizeof(struct net_local),
GFP_KERNEL);
......@@ -3677,8 +3680,9 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr)
if(err != UCODE_PRESENT && err != SUCCESS)
{
printk(KERN_ERR "%s: Firmware load failed (%d)\n", dev->name, err);
cleanup_card(dev);
err = -EIO;
goto out_tp;
goto out;
}
/* Allow user to specify ring speed on module insert. */
......@@ -3692,8 +3696,6 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr)
(unsigned int)dev->base_addr,
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->stop = smctr_close;
dev->hard_start_xmit = smctr_send_packet;
......@@ -5689,33 +5691,31 @@ int init_module(void)
{
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;
mem[i] = 0;
dev_smctr[i] = NULL;
dev_smctr[i] = init_trdev(dev_smctr[i], 0);
if(dev_smctr[i] == NULL)
return (-ENOMEM);
dev_smctr[i]->base_addr = io[i];
dev_smctr[i]->irq = irq[i];
dev_smctr[i]->mem_start = mem[i];
dev_smctr[i]->init = &smctr_probe;
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",
if (!dev)
return -ENOMEM;
dev->base_addr = io[i];
dev->irq = irq[i];
dev->mem_start = mem[i];
if (smctr_probe(dev) != 0) {
kfree(dev);
if (i == 0) {
printk(KERN_ERR "%s: smctr_probe failed.\n",
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);
......@@ -5725,25 +5725,12 @@ void cleanup_module(void)
{
int i;
for(i = 0; i < SMCTR_MAX_ADAPTERS; i++)
{
if(dev_smctr[i])
{
#ifdef CONFIG_MCA
struct net_local *tp
= (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;
for(i = 0; i < SMCTR_MAX_ADAPTERS; i++) {
struct net_device *dev = dev_smctr[i];
if (dev) {
unregister_netdev(dev);
cleanup_card(dev);
kfree(dev);
}
}
}
......
......@@ -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);
/* At this point we have found a valid card. */
dev = init_trdev(NULL, 0);
dev = alloc_trdev(0);
if (!dev)
return -ENOMEM;
SET_MODULE_OWNER(dev);
......@@ -163,22 +163,22 @@ static int __init tms_pci_attach(struct pci_dev *pdev, const struct pci_device_i
dev->open = tms380tr_open;
dev->stop = tms380tr_close;
pci_set_drvdata(pdev, dev);
ret = register_trdev(dev);
ret = register_netdev(dev);
if (ret)
goto err_out_tmsdev;
pci_set_drvdata(pdev, dev);
return 0;
err_out_tmsdev:
pci_set_drvdata(pdev, NULL);
tmsdev_term(dev);
err_out_irq:
free_irq(pdev->irq, dev);
err_out_region:
release_region(pci_ioaddr, TMS_PCI_IO_EXTENT);
err_out_trdev:
unregister_netdev(dev);
kfree(dev);
return ret;
}
......
......@@ -1751,30 +1751,29 @@ lcs_new_device(struct ccwgroup_device *ccwgdev)
#ifdef CONFIG_NET_ETHERNET
case LCS_FRAME_TYPE_ENET:
card->lan_type_trans = eth_type_trans;
dev = init_etherdev(NULL,0);
dev = alloc_etherdev(0);
break;
#endif
#ifdef CONFIG_TR
case LCS_FRAME_TYPE_TR:
card->lan_type_trans = tr_type_trans;
dev = init_trdev(NULL,0);
dev = alloc_trdev(0);
break;
#endif
#ifdef CONFIG_FDDI
case LCS_FRAME_TYPE_FDDI:
card->lan_type_trans = fddi_type_trans;
dev = init_fddidev(NULL,0);
dev = alloc_fddidev(0);
break;
#endif
default:
LCS_DBF_TEXT(3, setup, "errinit");
PRINT_ERR("LCS: Initialization failed\n");
PRINT_ERR("LCS: No device found!\n");
lcs_cleanup_channel(&card->read);
lcs_cleanup_channel(&card->write);
lcs_free_card(card);
return -ENODEV;
goto out;
}
if (!dev)
goto out;
memcpy(dev->dev_addr, card->mac, LCS_MAC_LENGTH);
card->dev = dev;
dev->priv = card;
......@@ -1787,9 +1786,16 @@ lcs_new_device(struct ccwgroup_device *ccwgdev)
#endif
dev->get_stats = lcs_getstats;
SET_MODULE_OWNER(&tun->dev);
if (register_netdev(dev) != 0)
goto out;
netif_stop_queue(dev);
lcs_stopcard(card);
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)
for (i = 0; i < MAX_LEC_ITF; i++) {
if (dev_lec[i] != NULL) {
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]);
kfree(dev_lec[i]);
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