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;
}
......
This diff is collapsed.
......@@ -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;
......@@ -382,33 +384,22 @@ 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 */
}
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;
}
card->next = proteon_card_list;
proteon_card_list = card;
card->dev = dev;
}
else
{
printk("KERN_INFO %s: register_trdev() returned non-zero.\n", dev->name);
release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
return -1;
}
/* Enlist in the card list */
card = kmalloc(sizeof(struct proteon_card), GFP_KERNEL);
if (!card)
goto out;
card->next = proteon_card_list;
proteon_card_list = card;
card->dev = 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;
}
/*
......@@ -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;
}
card->next = sk_isa_card_list;
sk_isa_card_list = card;
card->dev = dev;
}
else
{
printk("KERN_INFO %s: register_trdev() returned non-zero.\n", dev->name);
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
return -1;
}
/* Enlist in the card list */
card = kmalloc(sizeof(struct sk_isa_card), GFP_KERNEL);
if (!card)
goto out;
card->next = sk_isa_card_list;
sk_isa_card_list = card;
card->dev = 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;
}
/*
......@@ -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) {
......
This diff is collapsed.
......@@ -112,11 +112,11 @@ static int __init tms_pci_attach(struct pci_dev *pdev, const struct pci_device_i
pci_ioaddr = pci_resource_start (pdev, 0);
/* 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, TMS_PCI_IO_EXTENT, dev->name)) {
ret = -EBUSY;
goto err_out_trdev;
......@@ -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,12 +861,7 @@ 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]);
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