Commit 1c21cb91 authored by Andrew Morton's avatar Andrew Morton Committed by Jeff Garzik

[PATCH] m68k: Amiga Ariadne Ethernet new driver model

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

Ariadne Ethernet: Convert to the new driver model
parent fc638fe2
/* /*
* Amiga Linux/m68k Ariadne Ethernet Driver * Amiga Linux/m68k Ariadne Ethernet Driver
* *
* Copyright 1995 by Geert Uytterhoeven (geert@linux-m68k.org) * Copyright 1995-2003 by Geert Uytterhoeven (geert@linux-m68k.org)
* Peter De Schrijver * Peter De Schrijver (p2@mind.be)
* (Peter.DeSchrijver@linux.cc.kuleuven.ac.be)
* *
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
* *
...@@ -101,8 +100,6 @@ struct ariadne_private { ...@@ -101,8 +100,6 @@ struct ariadne_private {
int dirty_tx; /* The ring entries to be free()ed. */ int dirty_tx; /* The ring entries to be free()ed. */
struct net_device_stats stats; struct net_device_stats stats;
char tx_full; char tx_full;
struct net_device *dev; /* Backpointer */
struct ariadne_private *next_module;
}; };
...@@ -117,10 +114,6 @@ struct lancedata { ...@@ -117,10 +114,6 @@ struct lancedata {
u_short rx_buff[RX_RING_SIZE][PKT_BUF_SIZE/sizeof(u_short)]; u_short rx_buff[RX_RING_SIZE][PKT_BUF_SIZE/sizeof(u_short)];
}; };
#ifdef MODULE
static struct ariadne_private *root_ariadne_dev;
#endif
static int ariadne_open(struct net_device *dev); static int ariadne_open(struct net_device *dev);
static void ariadne_init_ring(struct net_device *dev); static void ariadne_init_ring(struct net_device *dev);
static int ariadne_start_xmit(struct sk_buff *skb, struct net_device *dev); static int ariadne_start_xmit(struct sk_buff *skb, struct net_device *dev);
...@@ -146,78 +139,89 @@ static void memcpyw(volatile u_short *dest, u_short *src, int len) ...@@ -146,78 +139,89 @@ static void memcpyw(volatile u_short *dest, u_short *src, int len)
} }
static int __init ariadne_probe(void) static int __devinit ariadne_init_one(struct zorro_dev *z,
const struct zorro_device_id *ent);
static void __devexit ariadne_remove_one(struct zorro_dev *z);
static struct zorro_device_id ariadne_zorro_tbl[] __devinitdata = {
{ ZORRO_PROD_VILLAGE_TRONIC_ARIADNE },
{ 0 }
};
static struct zorro_driver ariadne_driver = {
.name = "ariadne",
.id_table = ariadne_zorro_tbl,
.probe = ariadne_init_one,
.remove = __devexit_p(ariadne_remove_one),
};
static int __devinit ariadne_init_one(struct zorro_dev *z,
const struct zorro_device_id *ent)
{ {
struct zorro_dev *z = NULL; unsigned long board = z->resource.start;
unsigned long base_addr = board+ARIADNE_LANCE;
unsigned long mem_start = board+ARIADNE_RAM;
struct resource *r1, *r2;
struct net_device *dev; struct net_device *dev;
struct ariadne_private *priv; struct ariadne_private *priv;
int res = -ENODEV; int err;
while ((z = zorro_find_device(ZORRO_PROD_VILLAGE_TRONIC_ARIADNE, z))) { r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960");
unsigned long board = z->resource.start; if (!r1)
unsigned long base_addr = board+ARIADNE_LANCE; return -EBUSY;
unsigned long mem_start = board+ARIADNE_RAM; r2 = request_mem_region(mem_start, ARIADNE_RAM_SIZE, "RAM");
struct resource *r1, *r2; if (!r2) {
release_resource(r1);
r1 = request_mem_region(base_addr, sizeof(struct Am79C960), return -EBUSY;
"Am79C960"); }
if (!r1) continue;
r2 = request_mem_region(mem_start, ARIADNE_RAM_SIZE, "RAM");
if (!r2) {
release_resource(r1);
continue;
}
dev = alloc_etherdev(sizeof(struct ariadne_private)); dev = alloc_etherdev(sizeof(struct ariadne_private));
if (dev == NULL) {
release_resource(r1);
release_resource(r2);
return -ENOMEM;
}
if (dev == NULL) { SET_MODULE_OWNER(dev);
release_resource(r1); priv = dev->priv;
release_resource(r2);
return -ENOMEM; r1->name = dev->name;
} r2->name = dev->name;
SET_MODULE_OWNER(dev);
priv = dev->priv; dev->dev_addr[0] = 0x00;
dev->dev_addr[1] = 0x60;
r1->name = dev->name; dev->dev_addr[2] = 0x30;
r2->name = dev->name; dev->dev_addr[3] = (z->rom.er_SerialNumber>>16) & 0xff;
dev->dev_addr[4] = (z->rom.er_SerialNumber>>8) & 0xff;
priv->dev = dev; dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff;
dev->dev_addr[0] = 0x00; printk("%s: Ariadne at 0x%08lx, Ethernet Address "
dev->dev_addr[1] = 0x60; "%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, board,
dev->dev_addr[2] = 0x30; dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3] = (z->rom.er_SerialNumber>>16) & 0xff; dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
dev->dev_addr[4] = (z->rom.er_SerialNumber>>8) & 0xff;
dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff; dev->base_addr = ZTWO_VADDR(base_addr);
printk("%s: Ariadne at 0x%08lx, Ethernet Address " dev->mem_start = ZTWO_VADDR(mem_start);
"%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, board, dev->mem_end = dev->mem_start+ARIADNE_RAM_SIZE;
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); dev->open = &ariadne_open;
dev->stop = &ariadne_close;
dev->base_addr = ZTWO_VADDR(base_addr); dev->hard_start_xmit = &ariadne_start_xmit;
dev->mem_start = ZTWO_VADDR(mem_start); dev->tx_timeout = &ariadne_tx_timeout;
dev->mem_end = dev->mem_start+ARIADNE_RAM_SIZE; dev->watchdog_timeo = 5*HZ;
dev->get_stats = &ariadne_get_stats;
dev->open = &ariadne_open; dev->set_multicast_list = &set_multicast_list;
dev->stop = &ariadne_close;
dev->hard_start_xmit = &ariadne_start_xmit; err = register_netdev(dev);
dev->tx_timeout = &ariadne_tx_timeout; if (err) {
dev->watchdog_timeo = 5*HZ; release_resource(r1);
dev->get_stats = &ariadne_get_stats; release_resource(r2);
dev->set_multicast_list = &set_multicast_list; free_netdev(dev);
return err;
res = register_netdev(dev);
if (res) {
release_resource(r1);
release_resource(r2);
free_netdev(dev);
break;
}
#ifdef MODULE
priv->next_module = root_ariadne_dev;
root_ariadne_dev = priv;
#endif
} }
return res; zorro_set_drvdata(z, dev);
return 0;
} }
...@@ -846,25 +850,27 @@ static void set_multicast_list(struct net_device *dev) ...@@ -846,25 +850,27 @@ static void set_multicast_list(struct net_device *dev)
} }
static void __exit ariadne_cleanup(void) static void __devexit ariadne_remove_one(struct zorro_dev *z)
{ {
#ifdef MODULE struct net_device *dev = zorro_get_drvdata(z);
struct ariadne_private *next;
struct net_device *dev;
while (root_ariadne_dev) { unregister_netdev(dev);
next = root_ariadne_dev->next_module; release_mem_region(ZTWO_PADDR(dev->base_addr), sizeof(struct Am79C960));
dev = root_ariadne_dev->dev; release_mem_region(ZTWO_PADDR(dev->mem_start), ARIADNE_RAM_SIZE);
unregister_netdev(dev); free_netdev(dev);
release_mem_region(ZTWO_PADDR(dev->base_addr), sizeof(struct Am79C960)); }
release_mem_region(ZTWO_PADDR(dev->mem_start), ARIADNE_RAM_SIZE);
free_netdev(dev); static int __init ariadne_init_module(void)
root_ariadne_dev = next; {
} return zorro_module_init(&ariadne_driver);
#endif }
static void __exit ariadne_cleanup_module(void)
{
zorro_unregister_driver(&ariadne_driver);
} }
module_init(ariadne_probe); module_init(ariadne_init_module);
module_exit(ariadne_cleanup); module_exit(ariadne_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