Commit b72b407a authored by Andrew Morton's avatar Andrew Morton Committed by Jeff Garzik

[PATCH] m68k: Amiga Hydra Ethernet new driver model

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

Hydra Ethernet: Convert to the new driver model
parent 1c21cb91
......@@ -44,10 +44,10 @@
#define WORDSWAP(a) ((((a)>>8)&0xff) | ((a)<<8))
static struct net_device *root_hydra_dev;
static int __init hydra_probe(void);
static int __init hydra_init(unsigned long board);
static int __devinit hydra_init_one(struct zorro_dev *z,
const struct zorro_device_id *ent);
static int __devinit hydra_init(struct zorro_dev *z);
static int hydra_open(struct net_device *dev);
static int hydra_close(struct net_device *dev);
static void hydra_reset_8390(struct net_device *dev);
......@@ -57,34 +57,38 @@ static void hydra_block_input(struct net_device *dev, int count,
struct sk_buff *skb, int ring_offset);
static void hydra_block_output(struct net_device *dev, int count,
const unsigned char *buf, int start_page);
static void __exit hydra_cleanup(void);
static int __init hydra_probe(void)
static void __devexit hydra_remove_one(struct zorro_dev *z);
static struct zorro_device_id hydra_zorro_tbl[] __devinitdata = {
{ ZORRO_PROD_HYDRA_SYSTEMS_AMIGANET },
{ 0 }
};
static struct zorro_driver hydra_driver = {
.name = "hydra",
.id_table = hydra_zorro_tbl,
.probe = hydra_init_one,
.remove = __devexit_p(hydra_remove_one),
};
static int __devinit hydra_init_one(struct zorro_dev *z,
const struct zorro_device_id *ent)
{
struct zorro_dev *z = NULL;
unsigned long board;
int err = -ENODEV;
while ((z = zorro_find_device(ZORRO_PROD_HYDRA_SYSTEMS_AMIGANET, z))) {
board = z->resource.start;
if (!request_mem_region(board, 0x10000, "Hydra"))
continue;
if ((err = hydra_init(ZTWO_VADDR(board)))) {
release_mem_region(board, 0x10000);
return err;
}
err = 0;
}
if (err == -ENODEV)
printk("No Hydra ethernet card found.\n");
int err;
return err;
if (!request_mem_region(z->resource.start, 0x10000, "Hydra"))
return -EBUSY;
if ((err = hydra_init(z))) {
release_mem_region(z->resource.start, 0x10000);
return -EBUSY;
}
return 0;
}
static int __init hydra_init(unsigned long board)
static int __devinit hydra_init(struct zorro_dev *z)
{
struct net_device *dev;
unsigned long board = ZTWO_VADDR(z->resource.start);
unsigned long ioaddr = board+HYDRA_NIC_BASE;
const char name[] = "NE2000";
int start_page, stop_page;
......@@ -119,7 +123,7 @@ static int __init hydra_init(unsigned long board)
return -EAGAIN;
}
printk("%s: hydra at 0x%08lx, address %02x:%02x:%02x:%02x:%02x:%02x (hydra.c " HYDRA_VERSION ")\n", dev->name, ZTWO_PADDR(board),
printk("%s: hydra at 0x%08lx, address %02x:%02x:%02x:%02x:%02x:%02x (hydra.c " HYDRA_VERSION ")\n", dev->name, z->resource.start,
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
......@@ -143,13 +147,16 @@ static int __init hydra_init(unsigned long board)
root_hydra_dev = dev;
#endif
NS8390_init(dev, 0);
err = register_netdev(dev);
if (!err)
return 0;
err = register_netdev(dev);
if (err) {
free_irq(IRQ_AMIGA_PORTS, dev);
free_netdev(dev);
return err;
}
zorro_set_drvdata(z, dev);
return 0;
}
static int hydra_open(struct net_device *dev)
......@@ -220,20 +227,27 @@ static void hydra_block_output(struct net_device *dev, int count,
z_memcpy_toio(mem_base+((start_page - NESM_START_PG)<<8), buf, count);
}
static void __exit hydra_cleanup(void)
static void __devexit hydra_remove_one(struct zorro_dev *z)
{
struct net_device *dev, *next;
struct net_device *dev = zorro_get_drvdata(z);
while ((dev = root_hydra_dev)) {
next = (struct net_device *)(ei_status.priv);
unregister_netdev(dev);
free_irq(IRQ_AMIGA_PORTS, dev);
release_mem_region(ZTWO_PADDR(dev->base_addr)-HYDRA_NIC_BASE, 0x10000);
free_netdev(dev);
root_hydra_dev = next;
}
}
module_init(hydra_probe);
module_exit(hydra_cleanup);
static int __init hydra_init_module(void)
{
return zorro_module_init(&hydra_driver);
}
static void __exit hydra_cleanup_module(void)
{
zorro_unregister_driver(&hydra_driver);
}
module_init(hydra_init_module);
module_exit(hydra_cleanup_module);
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