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
*
* Copyright 1995 by Geert Uytterhoeven (geert@linux-m68k.org)
* Peter De Schrijver
* (Peter.DeSchrijver@linux.cc.kuleuven.ac.be)
* Copyright 1995-2003 by Geert Uytterhoeven (geert@linux-m68k.org)
* Peter De Schrijver (p2@mind.be)
*
* ---------------------------------------------------------------------------
*
......@@ -101,8 +100,6 @@ struct ariadne_private {
int dirty_tx; /* The ring entries to be free()ed. */
struct net_device_stats stats;
char tx_full;
struct net_device *dev; /* Backpointer */
struct ariadne_private *next_module;
};
......@@ -117,10 +114,6 @@ struct lancedata {
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 void ariadne_init_ring(struct net_device *dev);
static int ariadne_start_xmit(struct sk_buff *skb, struct net_device *dev);
......@@ -146,42 +139,56 @@ static void memcpyw(volatile u_short *dest, u_short *src, int len)
}
static int __init ariadne_probe(void)
{
struct zorro_dev *z = NULL;
struct net_device *dev;
struct ariadne_private *priv;
int res = -ENODEV;
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 }
};
while ((z = zorro_find_device(ZORRO_PROD_VILLAGE_TRONIC_ARIADNE, z))) {
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)
{
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 ariadne_private *priv;
int err;
r1 = request_mem_region(base_addr, sizeof(struct Am79C960),
"Am79C960");
if (!r1) continue;
r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960");
if (!r1)
return -EBUSY;
r2 = request_mem_region(mem_start, ARIADNE_RAM_SIZE, "RAM");
if (!r2) {
release_resource(r1);
continue;
return -EBUSY;
}
dev = alloc_etherdev(sizeof(struct ariadne_private));
if (dev == NULL) {
release_resource(r1);
release_resource(r2);
return -ENOMEM;
}
SET_MODULE_OWNER(dev);
priv = dev->priv;
r1->name = dev->name;
r2->name = dev->name;
priv->dev = dev;
dev->dev_addr[0] = 0x00;
dev->dev_addr[1] = 0x60;
dev->dev_addr[2] = 0x30;
......@@ -205,19 +212,16 @@ static int __init ariadne_probe(void)
dev->get_stats = &ariadne_get_stats;
dev->set_multicast_list = &set_multicast_list;
res = register_netdev(dev);
if (res) {
err = register_netdev(dev);
if (err) {
release_resource(r1);
release_resource(r2);
free_netdev(dev);
break;
}
#ifdef MODULE
priv->next_module = root_ariadne_dev;
root_ariadne_dev = priv;
#endif
return err;
}
return res;
zorro_set_drvdata(z, dev);
return 0;
}
......@@ -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 ariadne_private *next;
struct net_device *dev;
struct net_device *dev = zorro_get_drvdata(z);
while (root_ariadne_dev) {
next = root_ariadne_dev->next_module;
dev = root_ariadne_dev->dev;
unregister_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);
root_ariadne_dev = next;
}
#endif
}
module_init(ariadne_probe);
module_exit(ariadne_cleanup);
static int __init ariadne_init_module(void)
{
return zorro_module_init(&ariadne_driver);
}
static void __exit ariadne_cleanup_module(void)
{
zorro_unregister_driver(&ariadne_driver);
}
module_init(ariadne_init_module);
module_exit(ariadne_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