* [PATCH 2.5.74] Change appletalk/cops to dynamic allocation of net_device
@ 2003-07-09 20:29 Stephen Hemminger
2003-07-10 22:40 ` Jeff Garzik
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2003-07-09 20:29 UTC (permalink / raw)
To: Jeff Garzik, Jay Schulist; +Cc: netdev
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:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 2.5.74] Change appletalk/cops to dynamic allocation of net_device
2003-07-09 20:29 [PATCH 2.5.74] Change appletalk/cops to dynamic allocation of net_device Stephen Hemminger
@ 2003-07-10 22:40 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2003-07-10 22:40 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jay Schulist, netdev
viro did this one...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-07-10 22:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-09 20:29 [PATCH 2.5.74] Change appletalk/cops to dynamic allocation of net_device Stephen Hemminger
2003-07-10 22:40 ` Jeff Garzik
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).