Commit 938a0474 authored by Stephen Hemminger's avatar Stephen Hemminger

[PATCH] (38/42) bionet

NE63-bionet
	* switched to dynamic allocation
	* fixed resource leaks on failure exits
parent 5068053f
...@@ -78,7 +78,7 @@ extern int atarilance_probe(struct net_device *); ...@@ -78,7 +78,7 @@ extern int atarilance_probe(struct net_device *);
extern int sun3lance_probe(struct net_device *); extern int sun3lance_probe(struct net_device *);
extern int sun3_82586_probe(struct net_device *); extern int sun3_82586_probe(struct net_device *);
extern int apne_probe(struct net_device *); extern int apne_probe(struct net_device *);
extern int bionet_probe(struct net_device *); extern struct net_device *bionet_probe(int unit);
extern struct net_device *pamsnet_probe(int unit); extern struct net_device *pamsnet_probe(int unit);
extern struct net_device *cs89x0_probe(int unit); extern struct net_device *cs89x0_probe(int unit);
extern struct net_device *hplance_probe(int unit); extern struct net_device *hplance_probe(int unit);
...@@ -307,14 +307,14 @@ static struct devprobe m68k_probes[] __initdata = { ...@@ -307,14 +307,14 @@ static struct devprobe m68k_probes[] __initdata = {
#endif #endif
#ifdef CONFIG_APNE /* A1200 PCMCIA NE2000 */ #ifdef CONFIG_APNE /* A1200 PCMCIA NE2000 */
{apne_probe, 0}, {apne_probe, 0},
#endif
#ifdef CONFIG_ATARI_BIONET /* Atari Bionet Ethernet board */
{bionet_probe, 0},
#endif #endif
{NULL, 0}, {NULL, 0},
}; };
static struct devprobe2 m68k_probes2[] __initdata = { static struct devprobe2 m68k_probes2[] __initdata = {
#ifdef CONFIG_ATARI_BIONET /* Atari Bionet Ethernet board */
{bionet_probe, 0},
#endif
#ifdef CONFIG_ATARI_PAMSNET /* Atari PAMsNet Ethernet board */ #ifdef CONFIG_ATARI_PAMSNET /* Atari PAMsNet Ethernet board */
{pamsnet_probe, 0}, {pamsnet_probe, 0},
#endif #endif
......
...@@ -148,8 +148,6 @@ unsigned char *phys_nic_packet; ...@@ -148,8 +148,6 @@ unsigned char *phys_nic_packet;
/* Index to functions, as function prototypes. /* Index to functions, as function prototypes.
*/ */
extern int bionet_probe(struct net_device *dev);
static int bionet_open(struct net_device *dev); static int bionet_open(struct net_device *dev);
static int bionet_send_packet(struct sk_buff *skb, struct net_device *dev); static int bionet_send_packet(struct sk_buff *skb, struct net_device *dev);
static void bionet_poll_rx(struct net_device *); static void bionet_poll_rx(struct net_device *);
...@@ -321,15 +319,26 @@ hardware_send_packet(unsigned long paddr, int cnt) { ...@@ -321,15 +319,26 @@ hardware_send_packet(unsigned long paddr, int cnt) {
/* Check for a network adaptor of this type, and return '0' if one exists. /* Check for a network adaptor of this type, and return '0' if one exists.
*/ */
int __init struct net_device * __init bionet_probe(int unit)
bionet_probe(struct net_device *dev){ {
struct net_device *dev;
unsigned char station_addr[6]; unsigned char station_addr[6];
static unsigned version_printed; static unsigned version_printed;
static int no_more_found; /* avoid "Probing for..." printed 4 times */ static int no_more_found; /* avoid "Probing for..." printed 4 times */
int i; int i;
int err;
if (!MACH_IS_ATARI || no_more_found) if (!MACH_IS_ATARI || no_more_found)
return -ENODEV; return ERR_PTR(-ENODEV);
dev = alloc_etherdev(sizeof(struct net_local));
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
}
SET_MODULE_OWNER(dev);
printk("Probing for BioNet 100 Adapter...\n"); printk("Probing for BioNet 100 Adapter...\n");
...@@ -347,11 +356,10 @@ bionet_probe(struct net_device *dev){ ...@@ -347,11 +356,10 @@ bionet_probe(struct net_device *dev){
|| station_addr[2] != 'O' ) { || station_addr[2] != 'O' ) {
no_more_found = 1; no_more_found = 1;
printk( "No BioNet 100 found.\n" ); printk( "No BioNet 100 found.\n" );
return -ENODEV; free_netdev(dev);
return ERR_PTR(-ENODEV);
} }
SET_MODULE_OWNER(dev);
if (bionet_debug > 0 && version_printed++ == 0) if (bionet_debug > 0 && version_printed++ == 0)
printk(version); printk(version);
...@@ -369,12 +377,6 @@ bionet_probe(struct net_device *dev){ ...@@ -369,12 +377,6 @@ bionet_probe(struct net_device *dev){
nic_packet, phys_nic_packet ); nic_packet, phys_nic_packet );
} }
if (dev->priv == NULL)
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (!dev->priv)
return -ENOMEM;
memset(dev->priv, 0, sizeof(struct net_local));
dev->open = bionet_open; dev->open = bionet_open;
dev->stop = bionet_close; dev->stop = bionet_close;
dev->hard_start_xmit = bionet_send_packet; dev->hard_start_xmit = bionet_send_packet;
...@@ -390,8 +392,11 @@ bionet_probe(struct net_device *dev){ ...@@ -390,8 +392,11 @@ bionet_probe(struct net_device *dev){
#endif #endif
dev->dev_addr[i] = station_addr[i]; dev->dev_addr[i] = station_addr[i];
} }
ether_setup(dev); err = register_netdev(dev);
return 0; if (!err)
return dev;
free_netdev(dev);
return ERR_PTR(err);
} }
/* Open/initialize the board. This is called (in the current kernel) /* Open/initialize the board. This is called (in the current kernel)
...@@ -640,25 +645,20 @@ static struct net_device_stats *net_get_stats(struct net_device *dev) ...@@ -640,25 +645,20 @@ static struct net_device_stats *net_get_stats(struct net_device *dev)
#ifdef MODULE #ifdef MODULE
static struct net_device bio_dev; static struct net_device *bio_dev;
int
init_module(void) {
int err;
bio_dev.init = bionet_probe; int init_module(void)
if ((err = register_netdev(&bio_dev))) { {
if (err == -EEXIST) { bio_dev = bionet_probe(-1);
printk("BIONET: devices already present. Module not loaded.\n"); if (IS_ERR(bio_dev))
} return PTR_ERR(bio_dev);
return err;
}
return 0; return 0;
} }
void void cleanup_module(void)
cleanup_module(void) { {
unregister_netdev(&bio_dev); unregister_netdev(bio_dev);
free_netdev(bio_dev);
} }
#endif /* MODULE */ #endif /* MODULE */
......
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