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

[PATCH] m68k: Amiga A2065 Ethernet new driver model

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

A2065 Ethernet: Convert to the new driver model
parent dd6143d3
/*
* Amiga Linux/68k A2065 Ethernet Driver
*
* (C) Copyright 1995 by Geert Uytterhoeven <geert@linux-m68k.org>
* (C) Copyright 1995-2003 by Geert Uytterhoeven <geert@linux-m68k.org>
*
* Fixes and tips by:
* - Janos Farkas (CHEXUM@sparta.banki.hu)
......@@ -130,14 +130,8 @@ struct lance_private {
int burst_sizes; /* ledma SBus burst sizes */
#endif
struct timer_list multicast_timer;
struct net_device *dev; /* Backpointer */
struct lance_private *next_module;
};
#ifdef MODULE
static struct lance_private *root_a2065_dev;
#endif
#define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\
lp->tx_old+lp->tx_ring_mod_mask-lp->tx_new:\
lp->tx_old - lp->tx_new-1)
......@@ -704,25 +698,33 @@ static void lance_set_multicast (struct net_device *dev)
netif_wake_queue(dev);
}
static int __init a2065_probe(void)
static int __devinit a2065_init_one(struct zorro_dev *z,
const struct zorro_device_id *ent);
static void __devexit a2065_remove_one(struct zorro_dev *z);
static struct zorro_device_id a2065_zorro_tbl[] __devinitdata = {
{ ZORRO_PROD_CBM_A2065_1 },
{ ZORRO_PROD_CBM_A2065_2 },
{ ZORRO_PROD_AMERISTAR_A2065 },
{ 0 }
};
static struct zorro_driver a2065_driver = {
.name = "a2065",
.id_table = a2065_zorro_tbl,
.probe = a2065_init_one,
.remove = __devexit_p(a2065_remove_one),
};
static int __devinit a2065_init_one(struct zorro_dev *z,
const struct zorro_device_id *ent)
{
struct zorro_dev *z = NULL;
struct net_device *dev;
struct lance_private *priv;
int res = -ENODEV;
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
unsigned long board, base_addr, mem_start;
struct resource *r1, *r2;
int is_cbm;
if (z->id == ZORRO_PROD_CBM_A2065_1 ||
z->id == ZORRO_PROD_CBM_A2065_2)
is_cbm = 1;
else if (z->id == ZORRO_PROD_AMERISTAR_A2065)
is_cbm = 0;
else
continue;
int err;
board = z->resource.start;
base_addr = board+A2065_LANCE;
......@@ -730,29 +732,29 @@ static int __init a2065_probe(void)
r1 = request_mem_region(base_addr, sizeof(struct lance_regs),
"Am7990");
if (!r1) continue;
if (!r1)
return -EBUSY;
r2 = request_mem_region(mem_start, A2065_RAM_SIZE, "RAM");
if (!r2) {
release_resource(r1);
continue;
return -EBUSY;
}
dev = alloc_etherdev(sizeof(struct lance_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;
if (is_cbm) { /* Commodore */
if (z->id != ZORRO_PROD_AMERISTAR_A2065) { /* Commodore */
dev->dev_addr[1] = 0x80;
dev->dev_addr[2] = 0x10;
} else { /* Ameristar */
......@@ -796,41 +798,41 @@ static int __init a2065_probe(void)
priv->multicast_timer.function =
(void (*)(unsigned long)) &lance_set_multicast;
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_a2065_dev;
root_a2065_dev = priv;
#endif
return err;
}
return res;
zorro_set_drvdata(z, dev);
return 0;
}
static void __exit a2065_cleanup(void)
static void __devexit a2065_remove_one(struct zorro_dev *z)
{
#ifdef MODULE
struct lance_private *next;
struct net_device *dev;
struct net_device *dev = zorro_get_drvdata(z);
while (root_a2065_dev) {
next = root_a2065_dev->next_module;
dev = root_a2065_dev->dev;
unregister_netdev(dev);
release_mem_region(ZTWO_PADDR(dev->base_addr),
sizeof(struct lance_regs));
release_mem_region(ZTWO_PADDR(dev->mem_start), A2065_RAM_SIZE);
free_netdev(dev);
root_a2065_dev = next;
}
#endif
}
module_init(a2065_probe);
module_exit(a2065_cleanup);
static int __init a2065_init_module(void)
{
return zorro_module_init(&a2065_driver);
}
static void __exit a2065_cleanup_module(void)
{
zorro_unregister_driver(&a2065_driver);
}
module_init(a2065_init_module);
module_exit(a2065_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