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,42 +139,56 @@ static void memcpyw(volatile u_short *dest, u_short *src, int len) ...@@ -146,42 +139,56 @@ 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);
struct zorro_dev *z = NULL; static void __devexit ariadne_remove_one(struct zorro_dev *z);
struct net_device *dev;
struct ariadne_private *priv;
int res = -ENODEV; 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 board = z->resource.start;
unsigned long base_addr = board+ARIADNE_LANCE; unsigned long base_addr = board+ARIADNE_LANCE;
unsigned long mem_start = board+ARIADNE_RAM; unsigned long mem_start = board+ARIADNE_RAM;
struct resource *r1, *r2; struct resource *r1, *r2;
struct net_device *dev;
struct ariadne_private *priv;
int err;
r1 = request_mem_region(base_addr, sizeof(struct Am79C960), r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960");
"Am79C960"); if (!r1)
if (!r1) continue; return -EBUSY;
r2 = request_mem_region(mem_start, ARIADNE_RAM_SIZE, "RAM"); r2 = request_mem_region(mem_start, ARIADNE_RAM_SIZE, "RAM");
if (!r2) { if (!r2) {
release_resource(r1); release_resource(r1);
continue; return -EBUSY;
} }
dev = alloc_etherdev(sizeof(struct ariadne_private)); dev = alloc_etherdev(sizeof(struct ariadne_private));
if (dev == NULL) { if (dev == NULL) {
release_resource(r1); release_resource(r1);
release_resource(r2); release_resource(r2);
return -ENOMEM; return -ENOMEM;
} }
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
priv = dev->priv; priv = dev->priv;
r1->name = dev->name; r1->name = dev->name;
r2->name = dev->name; r2->name = dev->name;
priv->dev = dev;
dev->dev_addr[0] = 0x00; dev->dev_addr[0] = 0x00;
dev->dev_addr[1] = 0x60; dev->dev_addr[1] = 0x60;
dev->dev_addr[2] = 0x30; dev->dev_addr[2] = 0x30;
...@@ -205,19 +212,16 @@ static int __init ariadne_probe(void) ...@@ -205,19 +212,16 @@ static int __init ariadne_probe(void)
dev->get_stats = &ariadne_get_stats; dev->get_stats = &ariadne_get_stats;
dev->set_multicast_list = &set_multicast_list; dev->set_multicast_list = &set_multicast_list;
res = register_netdev(dev); err = register_netdev(dev);
if (res) { if (err) {
release_resource(r1); release_resource(r1);
release_resource(r2); release_resource(r2);
free_netdev(dev); free_netdev(dev);
break; return err;
}
#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) {
next = root_ariadne_dev->next_module;
dev = root_ariadne_dev->dev;
unregister_netdev(dev); unregister_netdev(dev);
release_mem_region(ZTWO_PADDR(dev->base_addr), sizeof(struct Am79C960)); release_mem_region(ZTWO_PADDR(dev->base_addr), sizeof(struct Am79C960));
release_mem_region(ZTWO_PADDR(dev->mem_start), ARIADNE_RAM_SIZE); release_mem_region(ZTWO_PADDR(dev->mem_start), ARIADNE_RAM_SIZE);
free_netdev(dev); free_netdev(dev);
root_ariadne_dev = next;
}
#endif
} }
module_init(ariadne_probe); static int __init ariadne_init_module(void)
module_exit(ariadne_cleanup); {
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"); 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