Commit abd63124 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] m68k: Amiga Zorro8390 Ethernet new driver model

From: Geert Uytterhoeven <geert@linux-m68k.org>

Zorro8390 Ethernet: Convert to the new driver model
parent a33161f5
...@@ -59,9 +59,6 @@ ...@@ -59,9 +59,6 @@
#define WORDSWAP(a) ((((a)>>8)&0xff) | ((a)<<8)) #define WORDSWAP(a) ((((a)>>8)&0xff) | ((a)<<8))
#ifdef MODULE
static struct net_device *root_zorro8390_dev;
#endif
static const struct card_info { static const struct card_info {
zorro_id id; zorro_id id;
...@@ -72,9 +69,11 @@ static const struct card_info { ...@@ -72,9 +69,11 @@ static const struct card_info {
{ ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, "X-Surf", 0x8600 }, { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, "X-Surf", 0x8600 },
}; };
static int __init zorro8390_probe(void); static int __devinit zorro8390_init_one(struct zorro_dev *z,
static int __init zorro8390_init(struct net_device *dev, unsigned long board, const struct zorro_device_id *ent);
const char *name, unsigned long ioaddr); static int __devinit zorro8390_init(struct net_device *dev,
unsigned long board, const char *name,
unsigned long ioaddr);
static int zorro8390_open(struct net_device *dev); static int zorro8390_open(struct net_device *dev);
static int zorro8390_close(struct net_device *dev); static int zorro8390_close(struct net_device *dev);
static void zorro8390_reset_8390(struct net_device *dev); static void zorro8390_reset_8390(struct net_device *dev);
...@@ -85,22 +84,31 @@ static void zorro8390_block_input(struct net_device *dev, int count, ...@@ -85,22 +84,31 @@ static void zorro8390_block_input(struct net_device *dev, int count,
static void zorro8390_block_output(struct net_device *dev, const int count, static void zorro8390_block_output(struct net_device *dev, const int count,
const unsigned char *buf, const unsigned char *buf,
const int start_page); const int start_page);
static void __exit zorro8390_cleanup(void); static void __devexit zorro8390_remove_one(struct zorro_dev *z);
static struct zorro_device_id zorro8390_zorro_tbl[] __devinitdata = {
{ ZORRO_PROD_VILLAGE_TRONIC_ARIADNE2, },
{ ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, },
{ 0 }
};
static struct zorro_driver zorro8390_driver = {
.name = "zorro8390",
.id_table = zorro8390_zorro_tbl,
.probe = zorro8390_init_one,
.remove = __devexit_p(zorro8390_remove_one),
};
static int __init zorro8390_probe(void) static int __devinit zorro8390_init_one(struct zorro_dev *z,
const struct zorro_device_id *ent)
{ {
struct net_device *dev; struct net_device *dev;
struct zorro_dev *z = NULL;
unsigned long board, ioaddr; unsigned long board, ioaddr;
int err = -ENODEV; int err, i;
int i;
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
for (i = ARRAY_SIZE(cards)-1; i >= 0; i--) for (i = ARRAY_SIZE(cards)-1; i >= 0; i--)
if (z->id == cards[i].id) if (z->id == cards[i].id)
break; break;
if (i < 0)
continue;
board = z->resource.start; board = z->resource.start;
ioaddr = board+cards[i].offset; ioaddr = board+cards[i].offset;
dev = alloc_ei_netdev(); dev = alloc_ei_netdev();
...@@ -109,7 +117,7 @@ static int __init zorro8390_probe(void) ...@@ -109,7 +117,7 @@ static int __init zorro8390_probe(void)
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
if (!request_mem_region(ioaddr, NE_IO_EXTENT*2, dev->name)) { if (!request_mem_region(ioaddr, NE_IO_EXTENT*2, dev->name)) {
free_netdev(dev); free_netdev(dev);
continue; return -EBUSY;
} }
if ((err = zorro8390_init(dev, board, cards[i].name, if ((err = zorro8390_init(dev, board, cards[i].name,
ZTWO_VADDR(ioaddr)))) { ZTWO_VADDR(ioaddr)))) {
...@@ -117,16 +125,13 @@ static int __init zorro8390_probe(void) ...@@ -117,16 +125,13 @@ static int __init zorro8390_probe(void)
free_netdev(dev); free_netdev(dev);
return err; return err;
} }
err = 0; zorro_set_drvdata(z, dev);
} return 0;
if (err == -ENODEV)
printk("No Ariadne II or X-Surf ethernet card found.\n");
return err;
} }
static int __init zorro8390_init(struct net_device *dev, unsigned long board, static int __devinit zorro8390_init(struct net_device *dev,
const char *name, unsigned long ioaddr) unsigned long board, const char *name,
unsigned long ioaddr)
{ {
int i; int i;
int err; int err;
...@@ -222,10 +227,6 @@ static int __init zorro8390_init(struct net_device *dev, unsigned long board, ...@@ -222,10 +227,6 @@ static int __init zorro8390_init(struct net_device *dev, unsigned long board,
ei_status.reg_offset = zorro8390_offsets; ei_status.reg_offset = zorro8390_offsets;
dev->open = &zorro8390_open; dev->open = &zorro8390_open;
dev->stop = &zorro8390_close; dev->stop = &zorro8390_close;
#ifdef MODULE
ei_status.priv = (unsigned long)root_zorro8390_dev;
root_zorro8390_dev = dev;
#endif
NS8390_init(dev, 0); NS8390_init(dev, 0);
err = register_netdev(dev); err = register_netdev(dev);
if (err) if (err)
...@@ -401,23 +402,27 @@ static void zorro8390_block_output(struct net_device *dev, int count, ...@@ -401,23 +402,27 @@ static void zorro8390_block_output(struct net_device *dev, int count,
return; return;
} }
static void __exit zorro8390_cleanup(void) static void __devexit zorro8390_remove_one(struct zorro_dev *z)
{ {
#ifdef MODULE struct net_device *dev = zorro_get_drvdata(z);
struct net_device *dev, *next;
while ((dev = root_zorro8390_dev)) {
next = (struct net_device *)(ei_status.priv);
unregister_netdev(dev); unregister_netdev(dev);
free_irq(IRQ_AMIGA_PORTS, dev); free_irq(IRQ_AMIGA_PORTS, dev);
release_mem_region(ZTWO_PADDR(dev->base_addr), NE_IO_EXTENT*2); release_mem_region(ZTWO_PADDR(dev->base_addr), NE_IO_EXTENT*2);
free_netdev(dev); free_netdev(dev);
root_zorro8390_dev = next;
}
#endif
} }
module_init(zorro8390_probe); static int __init zorro8390_init_module(void)
module_exit(zorro8390_cleanup); {
return zorro_module_init(&zorro8390_driver);
}
static void __exit zorro8390_cleanup_module(void)
{
zorro_unregister_driver(&zorro8390_driver);
}
module_init(zorro8390_init_module);
module_exit(zorro8390_cleanup_module);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
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