From: Stephen Hemminger <shemminger@osdl.org>
To: Jeff Garzik <jgarzik@pobox.com>, Jay Schulist <jschlst@samba.org>
Cc: netdev@oss.sgi.com
Subject: [PATCH 2.5.74] Change appletalk/cops to dynamic allocation of net_device
Date: Wed, 9 Jul 2003 13:29:10 -0700 [thread overview]
Message-ID: <20030709132910.589cf65d.shemminger@osdl.org> (raw)
Part of the continuing campaign to fix all network devices to allocate dynamically.
Built and loaded/unloaded, but do not have the hardware. Surprisingly probe suceeds
even without hardware.
diff -Nru a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
--- a/drivers/net/appletalk/cops.c Wed Jul 9 12:55:30 2003
+++ b/drivers/net/appletalk/cops.c Wed Jul 9 12:55:30 2003
@@ -235,9 +235,11 @@
* Dayna cards don't autoprobe well at all, but if your card is
* at IRQ 5 & IO 0x240 we find it every time. ;) JS
*/
- for(i=0; cops_portlist[i]; i++)
+ for(i=0; cops_portlist[i]; i++) {
+ ltalk_setup(dev);
if(cops_probe1(dev, cops_portlist[i]) == 0)
return 0;
+ }
return -ENODEV;
}
@@ -311,24 +313,12 @@
dev->base_addr = ioaddr;
/* Initialize the private device structure. */
- dev->priv = kmalloc(sizeof(struct cops_local), GFP_KERNEL);
- if(dev->priv == NULL) {
- if (dev->irq)
- free_irq(dev->irq, dev);
- retval = -ENOMEM;
- goto err_out;
- }
-
lp = (struct cops_local *)dev->priv;
- memset(lp, 0, sizeof(struct cops_local));
spin_lock_init(&lp->lock);
/* Copy local board variable to lp struct. */
lp->board = board;
- /* Fill in the fields of the device structure with LocalTalk values. */
- ltalk_setup(dev);
-
dev->hard_start_xmit = cops_send_packet;
dev->tx_timeout = cops_timeout;
dev->watchdog_timeo = HZ * 2;
@@ -1012,44 +1002,50 @@
}
#ifdef MODULE
-static struct net_device cops0_dev = { .init = cops_probe };
+static struct net_device *cops0_dev;
MODULE_LICENSE("GPL");
MODULE_PARM(io, "i");
MODULE_PARM(irq, "i");
MODULE_PARM(board_type, "i");
-int init_module(void)
+static int __init cops_init_module(void)
{
- int result, err;
+ int err;
if(io == 0)
printk(KERN_WARNING "%s: You shouldn't autoprobe with insmod\n",
cardname);
- /* Copy the parameters from insmod into the device structure. */
- cops0_dev.base_addr = io;
- cops0_dev.irq = irq;
+ cops0_dev = alloc_netdev(sizeof(struct cops_local), "lt%d",
+ ltalk_setup);
+
+ cops0_dev->init = cops_probe;
- err=dev_alloc_name(&cops0_dev, "lt%d");
- if(err < 0)
- return err;
+ /* Copy the parameters from insmod into the device structure. */
+ cops0_dev->base_addr = io;
+ cops0_dev->irq = irq;
- if((result = register_netdev(&cops0_dev)) != 0)
- return result;
+ if ((err = register_netdev(cops0_dev)))
+ kfree(cops0_dev);
- return 0;
+ return err;
}
-void cleanup_module(void)
+static void __exit cops_cleanup_module(void)
{
- unregister_netdev(&cops0_dev);
- kfree(cops0_dev.priv);
- if(cops0_dev.irq)
- free_irq(cops0_dev.irq, &cops0_dev);
- release_region(cops0_dev.base_addr, COPS_IO_EXTENT);
+ unregister_netdev(cops0_dev);
+
+ if(cops0_dev->irq)
+ free_irq(cops0_dev->irq, &cops0_dev);
+ release_region(cops0_dev->base_addr, COPS_IO_EXTENT);
+ kfree(cops0_dev);
}
-#endif /* MODULE */
+
+module_init(cops_init_module);
+module_exit(cops_cleanup_module);
+
+#endif
/*
* Local variables:
next reply other threads:[~2003-07-09 20:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-09 20:29 Stephen Hemminger [this message]
2003-07-10 22:40 ` [PATCH 2.5.74] Change appletalk/cops to dynamic allocation of net_device 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=20030709132910.589cf65d.shemminger@osdl.org \
--to=shemminger@osdl.org \
--cc=jgarzik@pobox.com \
--cc=jschlst@samba.org \
--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 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).