Commit 59706b13 authored by Alexander Viro's avatar Alexander Viro Committed by Stephen Hemminger

[netdrvr znet] alloc_etherdev, SET_MODULE_OWNER, remove #ifdef MODULE

parent d41a435d
...@@ -372,10 +372,8 @@ static int __init znet_probe (void) ...@@ -372,10 +372,8 @@ static int __init znet_probe (void)
struct znet_private *znet; struct znet_private *znet;
struct net_device *dev; struct net_device *dev;
char *p; char *p;
int err = -ENOMEM;
if (znet_dev) /* Only look for a single adaptor */
return -ENODEV;
/* This code scans the region 0xf0000 to 0xfffff for a "NETIDBLK". */ /* This code scans the region 0xf0000 to 0xfffff for a "NETIDBLK". */
for(p = (char *)phys_to_virt(0xf0000); p < (char *)phys_to_virt(0x100000); p++) for(p = (char *)phys_to_virt(0xf0000); p < (char *)phys_to_virt(0x100000); p++)
if (*p == 'N' && strncmp(p, "NETIDBLK", 8) == 0) if (*p == 'N' && strncmp(p, "NETIDBLK", 8) == 0)
...@@ -387,12 +385,14 @@ static int __init znet_probe (void) ...@@ -387,12 +385,14 @@ static int __init znet_probe (void)
return -ENODEV; return -ENODEV;
} }
if (!(znet_dev = dev = init_etherdev(0, sizeof(struct znet_private)))) dev = alloc_etherdev(sizeof(struct znet_private));
return -ENOMEM; if (!dev)
return -ENOMEM;
SET_MODULE_OWNER (dev);
znet = dev->priv; znet = dev->priv;
SET_MODULE_OWNER (dev);
netinfo = (struct netidblk *)p; netinfo = (struct netidblk *)p;
dev->base_addr = netinfo->iobase1; dev->base_addr = netinfo->iobase1;
dev->irq = netinfo->irq1; dev->irq = netinfo->irq1;
...@@ -430,7 +430,7 @@ static int __init znet_probe (void) ...@@ -430,7 +430,7 @@ static int __init znet_probe (void)
znet->io_size = 2; znet->io_size = 2;
if (!(znet->rx_start = kmalloc (DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA))) if (!(znet->rx_start = kmalloc (DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA)))
goto free_netdev; goto free_dev;
if (!(znet->tx_start = kmalloc (DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA))) if (!(znet->tx_start = kmalloc (DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA)))
goto free_rx; goto free_rx;
...@@ -452,19 +452,19 @@ static int __init znet_probe (void) ...@@ -452,19 +452,19 @@ static int __init znet_probe (void)
dev->set_multicast_list = &znet_set_multicast_list; dev->set_multicast_list = &znet_set_multicast_list;
dev->tx_timeout = znet_tx_timeout; dev->tx_timeout = znet_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT; dev->watchdog_timeo = TX_TIMEOUT;
err = register_netdev(dev);
if (err)
goto free_tx;
znet_dev = dev;
return 0; return 0;
free_tx: free_tx:
kfree (znet->tx_start); kfree(znet->tx_start);
free_rx: free_rx:
kfree (znet->rx_start); kfree(znet->rx_start);
free_netdev: free_dev:
unregister_netdev (dev); free_netdev(dev);
kfree (dev); return err;
znet_dev = NULL;
return -ENOMEM;
} }
...@@ -934,16 +934,14 @@ static void update_stop_hit(short ioaddr, unsigned short rx_stop_offset) ...@@ -934,16 +934,14 @@ static void update_stop_hit(short ioaddr, unsigned short rx_stop_offset)
static __exit void znet_cleanup (void) static __exit void znet_cleanup (void)
{ {
#ifdef MODULE
if (znet_dev) { if (znet_dev) {
struct znet_private *znet = znet_dev->priv; struct znet_private *znet = znet_dev->priv;
unregister_netdev (znet_dev);
kfree (znet->rx_start); kfree (znet->rx_start);
kfree (znet->tx_start); kfree (znet->tx_start);
unregister_netdev (znet_dev);
free_netdev (znet_dev); free_netdev (znet_dev);
} }
#endif
} }
module_init (znet_probe); module_init (znet_probe);
......
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