From: Christoph Hellwig <hch@lst.de>
To: jgarzik@pobox.com
Cc: netdev@oss.sgi.com
Subject: [PATCH] allow modular mv64340_eth
Date: Tue, 6 Jul 2004 12:36:45 +0200 [thread overview]
Message-ID: <20040706103645.GA14521@lst.de> (raw)
Only tested together with some additional patches to make the driver
work on PPC that need more work, but the changes are obvious.
--- a/drivers/net/Kconfig~ 2004-07-06 14:32:32.380761120 +0200
+++ b/drivers/net/Kconfig 2004-07-06 14:32:40.494527640 +0200
@@ -2132,7 +2132,7 @@
will be called tg3. This is recommended.
config MV64340_ETH
- bool "MV-64340 Ethernet support"
+ tristate "MV-64340 Ethernet support"
depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX
help
This driver supports the gigabit Ethernet on the Marvell MV64340
--- a/drivers/net/mv64340_eth.c~ 2004-07-06 14:26:47.163242160 +0200
+++ b/drivers/net/mv64340_eth.c 2004-07-06 14:32:15.198373240 +0200
@@ -1316,7 +1316,7 @@
* Input : number of port to initialize
* Output : -ENONMEM if failed , 0 if success
*/
-static int mv64340_eth_init(int port_num)
+static struct net_device *mv64340_eth_init(int port_num)
{
struct mv64340_private *mp;
struct net_device *dev;
@@ -1324,7 +1324,7 @@
dev = alloc_etherdev(sizeof(struct mv64340_private));
if (!dev)
- return -ENOMEM;
+ return NULL;
mp = netdev_priv(dev);
@@ -1395,14 +1395,27 @@
printk("RX NAPI Enabled \n");
#endif
- return 0;
+ return dev;
out_free_dev:
free_netdev(dev);
- return err;
+ return NULL;
+}
+
+static void mv64340_eth_remove(struct net_device *dev)
+{
+ struct mv64340_private *mp = netdev_priv(dev);
+
+ unregister_netdev(dev);
+ flush_scheduled_work();
+ free_netdev(dev);
}
+static struct net_device *mv64340_dev0;
+static struct net_device *mv64340_dev1;
+static struct net_device *mv64340_dev2;
+
/*
* mv64340_init_module
*
@@ -1415,20 +1428,24 @@
static int __init mv64340_init_module(void)
{
printk(KERN_NOTICE "MV-64340 10/100/1000 Ethernet Driver\n");
+
#ifdef CONFIG_MV64340_ETH_0
- if (mv64340_eth_init(0)) {
+ mv64340_dev0 = mv64340_eth_init(0);
+ if (!mv64340_dev0) {
printk(KERN_ERR
"Error registering MV-64360 ethernet port 0\n");
}
#endif
#ifdef CONFIG_MV64340_ETH_1
- if (mv64340_eth_init(1)) {
+ mv64340_dev1 = mv64340_eth_init(1);
+ if (!mv64340_dev1) {
printk(KERN_ERR
"Error registering MV-64360 ethernet port 1\n");
}
#endif
#ifdef CONFIG_MV64340_ETH_2
- if (mv64340_eth_init(2)) {
+ mv64340_dev2 = mv64340_eth_init(2);
+ if (!mv64340_dev2) {
printk(KERN_ERR
"Error registering MV-64360 ethernet port 2\n");
}
@@ -1445,9 +1462,14 @@
*
* Output : N/A
*/
-static void __init mv64340_cleanup_module(void)
+static void __exit mv64340_cleanup_module(void)
{
- /* Nothing to do here ! it's not a removable module */
+ if (mv64340_dev2)
+ mv64340_eth_remove(mv64340_dev2);
+ if (mv64340_dev1)
+ mv64340_eth_remove(mv64340_dev1);
+ if (mv64340_dev0)
+ mv64340_eth_remove(mv64340_dev0);
}
module_init(mv64340_init_module);
next reply other threads:[~2004-07-06 10:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-06 10:36 Christoph Hellwig [this message]
2004-07-07 5:08 ` [PATCH] allow modular mv64340_eth Jeff Garzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040706103645.GA14521@lst.de \
--to=hch@lst.de \
--cc=jgarzik@pobox.com \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.