Commit ee2577f0 authored by Daniel Ritz's avatar Daniel Ritz Committed by Ralf Bächle

[PATCH] alloc_etherdev for nmclan_cs

net_device is no longer allocated as part of the driver's private structure,
instead it's allocated via alloc_netdev. compile tested only since no hardware
against 2.5.73-bk


-daniel

===== nmclan_cs.c 1.14 vs edited =====
parent d3e4b9dd
...@@ -359,7 +359,6 @@ typedef struct _mace_statistics { ...@@ -359,7 +359,6 @@ typedef struct _mace_statistics {
typedef struct _mace_private { typedef struct _mace_private {
dev_link_t link; dev_link_t link;
struct net_device dev;
dev_node_t node; dev_node_t node;
struct net_device_stats linux_stats; /* Linux statistics counters */ struct net_device_stats linux_stats; /* Linux statistics counters */
mace_statistics mace_stats; /* MACE chip statistics counters */ mace_statistics mace_stats; /* MACE chip statistics counters */
...@@ -476,11 +475,12 @@ static dev_link_t *nmclan_attach(void) ...@@ -476,11 +475,12 @@ static dev_link_t *nmclan_attach(void)
flush_stale_links(); flush_stale_links();
/* Create new ethernet device */ /* Create new ethernet device */
lp = kmalloc(sizeof(*lp), GFP_KERNEL); dev = alloc_etherdev(sizeof(mace_private));
if (!lp) return NULL; if (!dev)
memset(lp, 0, sizeof(*lp)); return NULL;
link = &lp->link; dev = &lp->dev; lp = dev->priv;
link->priv = dev->priv = link->irq.Instance = lp; link = &lp->link;
link->priv = dev;
init_timer(&link->release); init_timer(&link->release);
link->release.function = &nmclan_release; link->release.function = &nmclan_release;
...@@ -496,6 +496,7 @@ static dev_link_t *nmclan_attach(void) ...@@ -496,6 +496,7 @@ static dev_link_t *nmclan_attach(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
link->irq.IRQInfo2 |= 1 << irq_list[i]; link->irq.IRQInfo2 |= 1 << irq_list[i];
link->irq.Handler = &mace_interrupt; link->irq.Handler = &mace_interrupt;
link->irq.Instance = dev;
link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.Vcc = 50; link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO; link->conf.IntType = INT_MEMORY_AND_IO;
...@@ -510,7 +511,6 @@ static dev_link_t *nmclan_attach(void) ...@@ -510,7 +511,6 @@ static dev_link_t *nmclan_attach(void)
dev->get_stats = &mace_get_stats; dev->get_stats = &mace_get_stats;
dev->set_multicast_list = &set_multicast_list; dev->set_multicast_list = &set_multicast_list;
dev->do_ioctl = &mace_ioctl; dev->do_ioctl = &mace_ioctl;
ether_setup(dev);
dev->open = &mace_open; dev->open = &mace_open;
dev->stop = &mace_close; dev->stop = &mace_close;
#ifdef HAVE_TX_TIMEOUT #ifdef HAVE_TX_TIMEOUT
...@@ -550,7 +550,7 @@ nmclan_detach ...@@ -550,7 +550,7 @@ nmclan_detach
static void nmclan_detach(dev_link_t *link) static void nmclan_detach(dev_link_t *link)
{ {
mace_private *lp = link->priv; struct net_device *dev = link->priv;
dev_link_t **linkp; dev_link_t **linkp;
DEBUG(0, "nmclan_detach(0x%p)\n", link); DEBUG(0, "nmclan_detach(0x%p)\n", link);
...@@ -576,8 +576,8 @@ static void nmclan_detach(dev_link_t *link) ...@@ -576,8 +576,8 @@ static void nmclan_detach(dev_link_t *link)
/* Unlink device structure, free bits */ /* Unlink device structure, free bits */
*linkp = link->next; *linkp = link->next;
if (link->dev) if (link->dev)
unregister_netdev(&lp->dev); unregister_netdev(dev);
kfree(lp); kfree(dev);
} /* nmclan_detach */ } /* nmclan_detach */
...@@ -710,8 +710,8 @@ while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed ...@@ -710,8 +710,8 @@ while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
static void nmclan_config(dev_link_t *link) static void nmclan_config(dev_link_t *link)
{ {
client_handle_t handle = link->handle; client_handle_t handle = link->handle;
mace_private *lp = link->priv; struct net_device *dev = link->priv;;
struct net_device *dev = &lp->dev; mace_private *lp = dev->priv;
tuple_t tuple; tuple_t tuple;
cisparse_t parse; cisparse_t parse;
u_char buf[64]; u_char buf[64];
...@@ -836,8 +836,7 @@ static int nmclan_event(event_t event, int priority, ...@@ -836,8 +836,7 @@ static int nmclan_event(event_t event, int priority,
event_callback_args_t *args) event_callback_args_t *args)
{ {
dev_link_t *link = args->client_data; dev_link_t *link = args->client_data;
mace_private *lp = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &lp->dev;
DEBUG(1, "nmclan_event(0x%06x)\n", event); DEBUG(1, "nmclan_event(0x%06x)\n", event);
...@@ -1145,8 +1144,8 @@ mace_interrupt ...@@ -1145,8 +1144,8 @@ mace_interrupt
---------------------------------------------------------------------------- */ ---------------------------------------------------------------------------- */
static irqreturn_t mace_interrupt(int irq, void *dev_id, struct pt_regs *regs) static irqreturn_t mace_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{ {
mace_private *lp = (mace_private *)dev_id; struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = &lp->dev; mace_private *lp = dev->priv;
ioaddr_t ioaddr = dev->base_addr; ioaddr_t ioaddr = dev->base_addr;
int status; int status;
int IntrCnt = MACE_MAX_IR_ITERATIONS; int IntrCnt = MACE_MAX_IR_ITERATIONS;
......
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