* [PATCH] update arcnet/pcmcia driver
@ 2003-09-09 23:35 Stephen Hemminger
2003-09-11 19:25 ` Jeff Garzik
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2003-09-09 23:35 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
Convert driver to use alloc_netdev and get rid of MOD_INC/MOD_DEC
Patch against 2.6.0-test5
diff -Nru a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
--- a/drivers/net/pcmcia/com20020_cs.c Tue Sep 9 16:33:36 2003
+++ b/drivers/net/pcmcia/com20020_cs.c Tue Sep 9 16:33:36 2003
@@ -163,6 +163,21 @@
}
}
+
+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
@@ -178,7 +193,6 @@
com20020_dev_t *info;
struct net_device *dev;
int i, ret;
- struct arcnet_local *lp;
DEBUG(0, "com20020_attach()\n");
flush_stale_links();
@@ -192,18 +206,13 @@
if (!info)
goto fail_alloc_info;
- lp = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
- if (!lp)
- goto fail_alloc_lp;
-
- dev = dev_alloc("arc%d", &ret);
+ dev = alloc_netdev(sizeof(struct arcnet_local), "arc%d",
+ com20020_setup);
if (!dev)
goto fail_alloc_dev;
memset(info, 0, sizeof(struct com20020_dev_t));
- memset(lp, 0, sizeof(struct arcnet_local));
memset(link, 0, sizeof(struct dev_link_t));
- dev->priv = lp;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
link->io.NumPorts1 = 16;
@@ -215,19 +224,11 @@
else
for (i = 0; i < 4; i++)
link->irq.IRQInfo2 |= 1 << irq_list[i];
+
link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO;
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->priv = info;
@@ -253,11 +254,9 @@
return link;
fail_alloc_dev:
- kfree(lp);
-fail_alloc_lp:
kfree(info);
fail_alloc_info:
- kfree(link);
+ kfree(dev);
return NULL;
} /* com20020_attach */
@@ -324,11 +323,9 @@
/* ...but I/O ports are done automatically by card services */
unregister_netdev(dev);
- MOD_DEC_USE_COUNT;
}
DEBUG(1,"kfree...\n");
- kfree(dev->priv);
free_netdev(dev);
}
DEBUG(1,"kfree2...\n");
@@ -428,8 +425,6 @@
goto failed;
}
- MOD_INC_USE_COUNT;
-
lp = dev->priv;
lp->card_name = "PCMCIA COM20020";
lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] update arcnet/pcmcia driver
2003-09-09 23:35 [PATCH] update arcnet/pcmcia driver Stephen Hemminger
@ 2003-09-11 19:25 ` Jeff Garzik
2003-09-15 18:54 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2003-09-11 19:25 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
looks ok, but doesn't seem to apply to current BK.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] update arcnet/pcmcia driver
2003-09-11 19:25 ` Jeff Garzik
@ 2003-09-15 18:54 ` Stephen Hemminger
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2003-09-15 18:54 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
Redo of earlier patch to get rid of MOD_INC/DEC and use alloc_netdev.
This is against 2.6.0-test5 bk latest.
diff -Nru a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
--- a/drivers/net/pcmcia/com20020_cs.c Mon Sep 15 11:53:32 2003
+++ b/drivers/net/pcmcia/com20020_cs.c Mon Sep 15 11:53:32 2003
@@ -145,6 +145,20 @@
dev_node_t node;
} 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
@@ -173,18 +187,14 @@
if (!info)
goto fail_alloc_info;
- lp = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
- if (!lp)
- goto fail_alloc_lp;
-
- dev = dev_alloc("arc%d", &ret);
+ dev = alloc_netdev(sizeof(struct arcnet_local), "arc%d",
+ com20020_setup);
if (!dev)
goto fail_alloc_dev;
memset(info, 0, sizeof(struct com20020_dev_t));
- memset(lp, 0, sizeof(struct arcnet_local));
memset(link, 0, sizeof(struct dev_link_t));
- dev->priv = lp;
+ lp = dev->priv;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
link->io.NumPorts1 = 16;
@@ -201,13 +211,6 @@
link->conf.IntType = INT_MEMORY_AND_IO;
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->priv = info;
@@ -234,8 +237,6 @@
return link;
fail_alloc_dev:
- kfree(lp);
-fail_alloc_lp:
kfree(info);
fail_alloc_info:
kfree(link);
@@ -303,11 +304,9 @@
/* ...but I/O ports are done automatically by card services */
unregister_netdev(dev);
- MOD_DEC_USE_COUNT;
}
DEBUG(1,"kfree...\n");
- kfree(dev->priv);
free_netdev(dev);
}
DEBUG(1,"kfree2...\n");
@@ -361,7 +360,6 @@
/* Configure card */
link->state |= DEV_CONFIG;
- strcpy(info->node.dev_name, dev->name);
DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1);
i = !CS_SUCCESS;
@@ -407,13 +405,11 @@
goto failed;
}
- MOD_INC_USE_COUNT;
-
lp = dev->priv;
lp->card_name = "PCMCIA COM20020";
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) {
DEBUG(1,KERN_NOTICE "com20020_cs: com20020_found() failed\n");
@@ -421,6 +417,7 @@
}
info->dev_configured = 1;
+ strcpy(info->node.dev_name, dev->name);
link->dev = &info->node;
link->state &= ~DEV_CONFIG_PENDING;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-09-15 18:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-09 23:35 [PATCH] update arcnet/pcmcia driver Stephen Hemminger
2003-09-11 19:25 ` Jeff Garzik
2003-09-15 18:54 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).