Commit b6d4364c authored by Stephen Hemminger's avatar Stephen Hemminger

[PATCH] update arcnet/pcmcia driver

Redo of earlier patch to get rid of MOD_INC/DEC and use alloc_netdev.
This is against 2.6.0-test5 bk latest.
parent b3ec1ec0
...@@ -145,6 +145,20 @@ typedef struct com20020_dev_t { ...@@ -145,6 +145,20 @@ typedef struct com20020_dev_t {
dev_node_t node; dev_node_t node;
} com20020_dev_t; } com20020_dev_t;
static void com20020_setup(struct net_device *dev)
{
struct arcnet_local *lp = dev->priv;
lp->timeout = timeout;
lp->backplane = backplane;
lp->clockp = clockp;
lp->clockm = clockm & 3;
lp->hw.owner = THIS_MODULE;
/* fill in our module parameters as defaults */
dev->dev_addr[0] = node;
}
/*====================================================================== /*======================================================================
com20020_attach() creates an "instance" of the driver, allocating com20020_attach() creates an "instance" of the driver, allocating
...@@ -173,18 +187,14 @@ static dev_link_t *com20020_attach(void) ...@@ -173,18 +187,14 @@ static dev_link_t *com20020_attach(void)
if (!info) if (!info)
goto fail_alloc_info; goto fail_alloc_info;
lp = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL); dev = alloc_netdev(sizeof(struct arcnet_local), "arc%d",
if (!lp) com20020_setup);
goto fail_alloc_lp;
dev = dev_alloc("arc%d", &ret);
if (!dev) if (!dev)
goto fail_alloc_dev; goto fail_alloc_dev;
memset(info, 0, sizeof(struct com20020_dev_t)); memset(info, 0, sizeof(struct com20020_dev_t));
memset(lp, 0, sizeof(struct arcnet_local));
memset(link, 0, sizeof(struct dev_link_t)); memset(link, 0, sizeof(struct dev_link_t));
dev->priv = lp; lp = dev->priv;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
link->io.NumPorts1 = 16; link->io.NumPorts1 = 16;
...@@ -201,13 +211,6 @@ static dev_link_t *com20020_attach(void) ...@@ -201,13 +211,6 @@ static dev_link_t *com20020_attach(void)
link->conf.IntType = INT_MEMORY_AND_IO; link->conf.IntType = INT_MEMORY_AND_IO;
link->conf.Present = PRESENT_OPTION; link->conf.Present = PRESENT_OPTION;
/* fill in our module parameters as defaults */
dev->dev_addr[0] = node;
lp->timeout = timeout;
lp->backplane = backplane;
lp->clockp = clockp;
lp->clockm = clockm & 3;
lp->hw.owner = THIS_MODULE;
link->irq.Instance = info->dev = dev; link->irq.Instance = info->dev = dev;
link->priv = info; link->priv = info;
...@@ -234,8 +237,6 @@ static dev_link_t *com20020_attach(void) ...@@ -234,8 +237,6 @@ static dev_link_t *com20020_attach(void)
return link; return link;
fail_alloc_dev: fail_alloc_dev:
kfree(lp);
fail_alloc_lp:
kfree(info); kfree(info);
fail_alloc_info: fail_alloc_info:
kfree(link); kfree(link);
...@@ -303,11 +304,9 @@ static void com20020_detach(dev_link_t *link) ...@@ -303,11 +304,9 @@ static void com20020_detach(dev_link_t *link)
/* ...but I/O ports are done automatically by card services */ /* ...but I/O ports are done automatically by card services */
unregister_netdev(dev); unregister_netdev(dev);
MOD_DEC_USE_COUNT;
} }
DEBUG(1,"kfree...\n"); DEBUG(1,"kfree...\n");
kfree(dev->priv);
free_netdev(dev); free_netdev(dev);
} }
DEBUG(1,"kfree2...\n"); DEBUG(1,"kfree2...\n");
...@@ -361,7 +360,6 @@ static void com20020_config(dev_link_t *link) ...@@ -361,7 +360,6 @@ static void com20020_config(dev_link_t *link)
/* Configure card */ /* Configure card */
link->state |= DEV_CONFIG; link->state |= DEV_CONFIG;
strcpy(info->node.dev_name, dev->name);
DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1);
i = !CS_SUCCESS; i = !CS_SUCCESS;
...@@ -407,13 +405,11 @@ static void com20020_config(dev_link_t *link) ...@@ -407,13 +405,11 @@ static void com20020_config(dev_link_t *link)
goto failed; goto failed;
} }
MOD_INC_USE_COUNT;
lp = dev->priv; lp = dev->priv;
lp->card_name = "PCMCIA COM20020"; lp->card_name = "PCMCIA COM20020";
lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */ lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */
i = com20020_found(dev, 0); i = com20020_found(dev, 0); /* calls register_netdev */
if (i != 0) { if (i != 0) {
DEBUG(1,KERN_NOTICE "com20020_cs: com20020_found() failed\n"); DEBUG(1,KERN_NOTICE "com20020_cs: com20020_found() failed\n");
...@@ -421,6 +417,7 @@ static void com20020_config(dev_link_t *link) ...@@ -421,6 +417,7 @@ static void com20020_config(dev_link_t *link)
} }
info->dev_configured = 1; info->dev_configured = 1;
strcpy(info->node.dev_name, dev->name);
link->dev = &info->node; link->dev = &info->node;
link->state &= ~DEV_CONFIG_PENDING; link->state &= ~DEV_CONFIG_PENDING;
......
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