Commit b91a902e authored by Alexander Viro's avatar Alexander Viro Committed by Stephen Hemminger

[netdrvr stnic] use alloc_etherdev

parent 074821d5
...@@ -98,26 +98,27 @@ STNIC_WRITE (int reg, byte val) ...@@ -98,26 +98,27 @@ STNIC_WRITE (int reg, byte val)
STNIC_DELAY (); STNIC_DELAY ();
} }
int __init stnic_probe(void) static int __init stnic_probe(void)
{ {
struct net_device *dev; struct net_device *dev;
int i; int i, err;
/* If we are not running on a SolutionEngine, give up now */ /* If we are not running on a SolutionEngine, give up now */
if (! MACH_SE) if (! MACH_SE)
return -ENODEV; return -ENODEV;
/* New style probing API */ /* New style probing API */
dev = init_etherdev (NULL, 0); dev = alloc_etherdev(0);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
stnic_dev = dev; dev->probe = NULL;
/* Allocate dev->priv and fill in 8390 specific dev fields. */ /* Allocate dev->priv and fill in 8390 specific dev fields. */
if (ethdev_init (dev)) if (ethdev_init (dev))
{ {
printk (KERN_EMERG "Unable to get memory for dev->priv.\n"); printk (KERN_EMERG "Unable to get memory for dev->priv.\n");
free_netdev(dev);
return -ENOMEM; return -ENOMEM;
} }
...@@ -135,13 +136,12 @@ int __init stnic_probe(void) ...@@ -135,13 +136,12 @@ int __init stnic_probe(void)
/* Snarf the interrupt now. There's no point in waiting since we cannot /* Snarf the interrupt now. There's no point in waiting since we cannot
share and the board will usually be enabled. */ share and the board will usually be enabled. */
i = request_irq (dev->irq, ei_interrupt, 0, dev->name, dev); err = request_irq (dev->irq, ei_interrupt, 0, dev->name, dev);
if (i) { if (err) {
printk (KERN_EMERG " unable to get IRQ %d.\n", dev->irq); printk (KERN_EMERG " unable to get IRQ %d.\n", dev->irq);
unregister_netdev(dev);
kfree(dev->priv); kfree(dev->priv);
kfree(dev); free_netdev(dev);
return i; return err;
} }
ei_status.name = dev->name; ei_status.name = dev->name;
...@@ -162,6 +162,15 @@ int __init stnic_probe(void) ...@@ -162,6 +162,15 @@ int __init stnic_probe(void)
stnic_init (dev); stnic_init (dev);
err = register_netdev(dev);
if (err) {
free_irq(dev->irq, dev);
kfree(dev->priv);
free_netdev(dev);
return err;
}
stnic_dev = dev;
printk (KERN_INFO "NS ST-NIC 83902A\n"); printk (KERN_INFO "NS ST-NIC 83902A\n");
return 0; return 0;
...@@ -305,15 +314,14 @@ stnic_init (struct net_device *dev) ...@@ -305,15 +314,14 @@ stnic_init (struct net_device *dev)
return; return;
} }
/* Hardware interrupt handler. */ static void __exit stnic_cleanup(void)
extern void ei_interrupt (int irq, void *dev_id, struct pt_regs *regs);
void
do_stnic_intr (int irq, void *dev_id, struct pt_regs *regs)
{ {
ei_interrupt (0, stnic_dev, regs); unregister_netdev(stnic_dev);
free_irq(stnic_dev->irq, stnic_dev);
kfree(stnic_dev->priv);
free_netdev(stnic_dev);
} }
module_init(stnic_probe); module_init(stnic_probe);
/* No cleanup routine. */ module_exit(stnic_cleanup);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
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