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

[PATCH] alloc_etherdev for smc91c92_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

===== smc91c92_cs.c 1.18 vs edited =====
parent ee2577f0
...@@ -113,7 +113,6 @@ static dev_link_t *dev_list; ...@@ -113,7 +113,6 @@ static dev_link_t *dev_list;
struct smc_private { struct smc_private {
dev_link_t link; dev_link_t link;
struct net_device dev;
spinlock_t lock; spinlock_t lock;
u_short manfid; u_short manfid;
u_short cardid; u_short cardid;
...@@ -344,10 +343,13 @@ static dev_link_t *smc91c92_attach(void) ...@@ -344,10 +343,13 @@ static dev_link_t *smc91c92_attach(void)
flush_stale_links(); flush_stale_links();
/* Create new ethernet device */ /* Create new ethernet device */
smc = kmalloc(sizeof(struct smc_private), GFP_KERNEL); dev = alloc_etherdev(sizeof(struct smc_private));
if (!smc) return NULL; if (!dev)
memset(smc, 0, sizeof(struct smc_private)); return NULL;
link = &smc->link; dev = &smc->dev; smc = dev->priv;
link = &smc->link;
link->priv = dev;
spin_lock_init(&smc->lock); spin_lock_init(&smc->lock);
init_timer(&link->release); init_timer(&link->release);
link->release.function = &smc91c92_release; link->release.function = &smc91c92_release;
...@@ -363,6 +365,7 @@ static dev_link_t *smc91c92_attach(void) ...@@ -363,6 +365,7 @@ static dev_link_t *smc91c92_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 = &smc_interrupt; link->irq.Handler = &smc_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;
...@@ -373,7 +376,6 @@ static dev_link_t *smc91c92_attach(void) ...@@ -373,7 +376,6 @@ static dev_link_t *smc91c92_attach(void)
dev->get_stats = &smc_get_stats; dev->get_stats = &smc_get_stats;
dev->set_config = &s9k_config; dev->set_config = &s9k_config;
dev->set_multicast_list = &set_rx_mode; dev->set_multicast_list = &set_rx_mode;
ether_setup(dev);
dev->open = &smc_open; dev->open = &smc_open;
dev->stop = &smc_close; dev->stop = &smc_close;
dev->do_ioctl = &smc_ioctl; dev->do_ioctl = &smc_ioctl;
...@@ -381,7 +383,6 @@ static dev_link_t *smc91c92_attach(void) ...@@ -381,7 +383,6 @@ static dev_link_t *smc91c92_attach(void)
dev->tx_timeout = smc_tx_timeout; dev->tx_timeout = smc_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT; dev->watchdog_timeo = TX_TIMEOUT;
#endif #endif
dev->priv = link->priv = link->irq.Instance = smc;
smc->mii_if.dev = dev; smc->mii_if.dev = dev;
smc->mii_if.mdio_read = mdio_read; smc->mii_if.mdio_read = mdio_read;
...@@ -421,7 +422,7 @@ static dev_link_t *smc91c92_attach(void) ...@@ -421,7 +422,7 @@ static dev_link_t *smc91c92_attach(void)
static void smc91c92_detach(dev_link_t *link) static void smc91c92_detach(dev_link_t *link)
{ {
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
dev_link_t **linkp; dev_link_t **linkp;
DEBUG(0, "smc91c92_detach(0x%p)\n", link); DEBUG(0, "smc91c92_detach(0x%p)\n", link);
...@@ -447,8 +448,8 @@ static void smc91c92_detach(dev_link_t *link) ...@@ -447,8 +448,8 @@ static void smc91c92_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(&smc->dev); unregister_netdev(dev);
kfree(smc); kfree(dev);
} /* smc91c92_detach */ } /* smc91c92_detach */
...@@ -502,7 +503,8 @@ static int get_tuple(int fn, client_handle_t handle, tuple_t *tuple, ...@@ -502,7 +503,8 @@ static int get_tuple(int fn, client_handle_t handle, tuple_t *tuple,
static int mhz_3288_power(dev_link_t *link) static int mhz_3288_power(dev_link_t *link)
{ {
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct smc_private *smc = dev->priv;
u_char tmp; u_char tmp;
/* Read the ISR twice... */ /* Read the ISR twice... */
...@@ -523,8 +525,8 @@ static int mhz_3288_power(dev_link_t *link) ...@@ -523,8 +525,8 @@ static int mhz_3288_power(dev_link_t *link)
static int mhz_mfc_config(dev_link_t *link) static int mhz_mfc_config(dev_link_t *link)
{ {
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev; struct smc_private *smc = dev->priv;
tuple_t tuple; tuple_t tuple;
cisparse_t parse; cisparse_t parse;
u_char buf[255]; u_char buf[255];
...@@ -590,8 +592,7 @@ static int mhz_mfc_config(dev_link_t *link) ...@@ -590,8 +592,7 @@ static int mhz_mfc_config(dev_link_t *link)
static int mhz_setup(dev_link_t *link) static int mhz_setup(dev_link_t *link)
{ {
client_handle_t handle = link->handle; client_handle_t handle = link->handle;
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev;
tuple_t tuple; tuple_t tuple;
cisparse_t parse; cisparse_t parse;
u_char buf[255], *station_addr; u_char buf[255], *station_addr;
...@@ -638,8 +639,8 @@ static int mhz_setup(dev_link_t *link) ...@@ -638,8 +639,8 @@ static int mhz_setup(dev_link_t *link)
static void mot_config(dev_link_t *link) static void mot_config(dev_link_t *link)
{ {
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev; struct smc_private *smc = dev->priv;
ioaddr_t ioaddr = dev->base_addr; ioaddr_t ioaddr = dev->base_addr;
ioaddr_t iouart = link->io.BasePort2; ioaddr_t iouart = link->io.BasePort2;
...@@ -659,8 +660,7 @@ static void mot_config(dev_link_t *link) ...@@ -659,8 +660,7 @@ static void mot_config(dev_link_t *link)
static int mot_setup(dev_link_t *link) static int mot_setup(dev_link_t *link)
{ {
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev;
ioaddr_t ioaddr = dev->base_addr; ioaddr_t ioaddr = dev->base_addr;
int i, wait, loop; int i, wait, loop;
u_int addr; u_int addr;
...@@ -694,8 +694,7 @@ static int mot_setup(dev_link_t *link) ...@@ -694,8 +694,7 @@ static int mot_setup(dev_link_t *link)
static int smc_config(dev_link_t *link) static int smc_config(dev_link_t *link)
{ {
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev;
tuple_t tuple; tuple_t tuple;
cisparse_t parse; cisparse_t parse;
u_char buf[255]; u_char buf[255];
...@@ -727,8 +726,7 @@ static int smc_config(dev_link_t *link) ...@@ -727,8 +726,7 @@ static int smc_config(dev_link_t *link)
static int smc_setup(dev_link_t *link) static int smc_setup(dev_link_t *link)
{ {
client_handle_t handle = link->handle; client_handle_t handle = link->handle;
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev;
tuple_t tuple; tuple_t tuple;
cisparse_t parse; cisparse_t parse;
cistpl_lan_node_id_t *node_id; cistpl_lan_node_id_t *node_id;
...@@ -755,7 +753,6 @@ static int smc_setup(dev_link_t *link) ...@@ -755,7 +753,6 @@ static int smc_setup(dev_link_t *link)
return 0; return 0;
} }
} }
/* Try the third string in the Version 1 Version/ID tuple. */ /* Try the third string in the Version 1 Version/ID tuple. */
tuple.DesiredTuple = CISTPL_VERS_1; tuple.DesiredTuple = CISTPL_VERS_1;
if (first_tuple(handle, &tuple, &parse) != CS_SUCCESS) if (first_tuple(handle, &tuple, &parse) != CS_SUCCESS)
...@@ -771,8 +768,7 @@ static int smc_setup(dev_link_t *link) ...@@ -771,8 +768,7 @@ static int smc_setup(dev_link_t *link)
static int osi_config(dev_link_t *link) static int osi_config(dev_link_t *link)
{ {
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev;
static ioaddr_t com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; static ioaddr_t com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
int i, j; int i, j;
...@@ -806,8 +802,7 @@ static int osi_config(dev_link_t *link) ...@@ -806,8 +802,7 @@ static int osi_config(dev_link_t *link)
static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid) static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid)
{ {
client_handle_t handle = link->handle; client_handle_t handle = link->handle;
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev;
tuple_t tuple; tuple_t tuple;
u_char buf[255]; u_char buf[255];
int i; int i;
...@@ -862,8 +857,7 @@ static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid) ...@@ -862,8 +857,7 @@ static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid)
static int check_sig(dev_link_t *link) static int check_sig(dev_link_t *link)
{ {
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev;
ioaddr_t ioaddr = dev->base_addr; ioaddr_t ioaddr = dev->base_addr;
int width; int width;
u_short s; u_short s;
...@@ -921,8 +915,8 @@ if (ret != CS_SUCCESS) { cs_error(link->handle, svc, ret); goto label; } ...@@ -921,8 +915,8 @@ if (ret != CS_SUCCESS) { cs_error(link->handle, svc, ret); goto label; }
static void smc91c92_config(dev_link_t *link) static void smc91c92_config(dev_link_t *link)
{ {
client_handle_t handle = link->handle; client_handle_t handle = link->handle;
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev; struct smc_private *smc = dev->priv;
tuple_t tuple; tuple_t tuple;
cisparse_t parse; cisparse_t parse;
u_short buf[32]; u_short buf[32];
...@@ -1090,7 +1084,6 @@ static void smc91c92_config(dev_link_t *link) ...@@ -1090,7 +1084,6 @@ static void smc91c92_config(dev_link_t *link)
static void smc91c92_release(u_long arg) static void smc91c92_release(u_long arg)
{ {
dev_link_t *link = (dev_link_t *)arg; dev_link_t *link = (dev_link_t *)arg;
struct smc_private *smc = link->priv;
DEBUG(0, "smc91c92_release(0x%p)\n", link); DEBUG(0, "smc91c92_release(0x%p)\n", link);
...@@ -1105,6 +1098,8 @@ static void smc91c92_release(u_long arg) ...@@ -1105,6 +1098,8 @@ static void smc91c92_release(u_long arg)
CardServices(ReleaseIO, link->handle, &link->io); CardServices(ReleaseIO, link->handle, &link->io);
CardServices(ReleaseIRQ, link->handle, &link->irq); CardServices(ReleaseIRQ, link->handle, &link->irq);
if (link->win) { if (link->win) {
struct net_device *dev = link->priv;
struct smc_private *smc = dev->priv;
iounmap(smc->base); iounmap(smc->base);
CardServices(ReleaseWindow, link->win); CardServices(ReleaseWindow, link->win);
} }
...@@ -1126,8 +1121,8 @@ static int smc91c92_event(event_t event, int priority, ...@@ -1126,8 +1121,8 @@ static int smc91c92_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;
struct smc_private *smc = link->priv; struct net_device *dev = link->priv;
struct net_device *dev = &smc->dev; struct smc_private *smc = dev->priv;
int i; int i;
DEBUG(1, "smc91c92_event(0x%06x)\n", event); DEBUG(1, "smc91c92_event(0x%06x)\n", event);
...@@ -1302,7 +1297,7 @@ static int smc_open(struct net_device *dev) ...@@ -1302,7 +1297,7 @@ static int smc_open(struct net_device *dev)
smc_reset(dev); smc_reset(dev);
init_timer(&smc->media); init_timer(&smc->media);
smc->media.function = &media_check; smc->media.function = &media_check;
smc->media.data = (u_long)smc; smc->media.data = (u_long) dev;
smc->media.expires = jiffies + HZ; smc->media.expires = jiffies + HZ;
add_timer(&smc->media); add_timer(&smc->media);
...@@ -1576,8 +1571,8 @@ static void smc_eph_irq(struct net_device *dev) ...@@ -1576,8 +1571,8 @@ static void smc_eph_irq(struct net_device *dev)
static irqreturn_t smc_interrupt(int irq, void *dev_id, struct pt_regs *regs) static irqreturn_t smc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{ {
struct smc_private *smc = dev_id; struct net_device *dev = dev_id;
struct net_device *dev = &smc->dev; struct smc_private *smc = dev->priv;
ioaddr_t ioaddr; ioaddr_t ioaddr;
u_short saved_bank, saved_pointer, mask, status; u_short saved_bank, saved_pointer, mask, status;
unsigned int handled = 1; unsigned int handled = 1;
...@@ -1967,8 +1962,8 @@ static void smc_reset(struct net_device *dev) ...@@ -1967,8 +1962,8 @@ static void smc_reset(struct net_device *dev)
static void media_check(u_long arg) static void media_check(u_long arg)
{ {
struct smc_private *smc = (struct smc_private *)(arg); struct net_device *dev = (struct net_device *) arg;
struct net_device *dev = &smc->dev; struct smc_private *smc = dev->priv;
ioaddr_t ioaddr = dev->base_addr; ioaddr_t ioaddr = dev->base_addr;
u_short i, media, saved_bank; u_short i, media, saved_bank;
u_short link; u_short link;
......
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