Commit 4976b816 authored by Stephen Hemminger's avatar Stephen Hemminger

[NET]: Convert sbni initialization.

Convert sbni driver
- new probing
- single allocation using alloc_netdev for private data
parent 11897753
...@@ -114,7 +114,7 @@ extern int de620_probe(struct net_device *); ...@@ -114,7 +114,7 @@ extern int de620_probe(struct net_device *);
extern int iph5526_probe(struct net_device *dev); extern int iph5526_probe(struct net_device *dev);
/* SBNI adapters */ /* SBNI adapters */
extern int sbni_probe(struct net_device *); extern int sbni_probe(void);
struct devprobe struct devprobe
{ {
...@@ -443,6 +443,11 @@ void __init probe_old_netdevs(void) ...@@ -443,6 +443,11 @@ void __init probe_old_netdevs(void)
{ {
int num; int num;
#ifdef CONFIG_SBNI
for (num = 0; num < 8; ++num)
if (sbni_probe())
break;
#endif
#ifdef CONFIG_TR #ifdef CONFIG_TR
for (num = 0; num < 8; ++num) for (num = 0; num < 8; ++num)
if (trif_probe()) if (trif_probe())
...@@ -473,53 +478,6 @@ static struct net_device dev_ltpc = { ...@@ -473,53 +478,6 @@ static struct net_device dev_ltpc = {
#define NEXT_DEV (&dev_ltpc) #define NEXT_DEV (&dev_ltpc)
#endif /* LTPC */ #endif /* LTPC */
#ifdef CONFIG_SBNI
static struct net_device sbni7_dev = {
.name = "sbni7",
.next = NEXT_DEV,
.init = sbni_probe,
};
static struct net_device sbni6_dev = {
.name = "sbni6",
.next = &sbni7_dev,
.init = sbni_probe,
};
static struct net_device sbni5_dev = {
.name = "sbni5",
.next = &sbni6_dev,
.init = sbni_probe,
};
static struct net_device sbni4_dev = {
.name = "sbni4",
.next = &sbni5_dev,
.init = sbni_probe,
};
static struct net_device sbni3_dev = {
.name = "sbni3",
.next = &sbni4_dev,
.init = sbni_probe,
};
static struct net_device sbni2_dev = {
.name = "sbni2",
.next = &sbni3_dev,
.init = sbni_probe,
};
static struct net_device sbni1_dev = {
.name = "sbni1",
.next = &sbni2_dev,
.init = sbni_probe,
};
static struct net_device sbni0_dev = {
.name = "sbni0",
.next = &sbni1_dev,
.init = sbni_probe,
};
#undef NEXT_DEV
#define NEXT_DEV (&sbni0_dev)
#endif
/* /*
* The loopback device is global so it can be directly referenced * The loopback device is global so it can be directly referenced
* by the network code. Also, it must be first on device list. * by the network code. Also, it must be first on device list.
......
...@@ -140,6 +140,7 @@ static void change_level( struct net_device * ); ...@@ -140,6 +140,7 @@ static void change_level( struct net_device * );
static void timeout_change_level( struct net_device * ); static void timeout_change_level( struct net_device * );
static u32 calc_crc32( u32, u8 *, u32 ); static u32 calc_crc32( u32, u8 *, u32 );
static struct sk_buff * get_rx_buf( struct net_device * ); static struct sk_buff * get_rx_buf( struct net_device * );
static int sbni_init( struct net_device * );
#ifdef CONFIG_SBNI_MULTILINE #ifdef CONFIG_SBNI_MULTILINE
static int enslave( struct net_device *, struct net_device * ); static int enslave( struct net_device *, struct net_device * );
...@@ -205,23 +206,44 @@ sbni_isa_probe( struct net_device *dev ) ...@@ -205,23 +206,44 @@ sbni_isa_probe( struct net_device *dev )
} }
} }
static void __init sbni_devsetup(struct net_device *dev)
int __init
sbni_probe( struct net_device *dev )
{ {
int i; ether_setup( dev );
dev->init = &sbni_init;
dev->open = &sbni_open;
dev->stop = &sbni_close;
dev->hard_start_xmit = &sbni_start_xmit;
dev->get_stats = &sbni_get_stats;
dev->set_multicast_list = &set_multicast_list;
dev->do_ioctl = &sbni_ioctl;
SET_MODULE_OWNER( dev );
}
int __init sbni_probe(void)
{
struct net_device *dev;
static unsigned version_printed __initdata = 0; static unsigned version_printed __initdata = 0;
if( version_printed++ == 0 ) if( version_printed++ == 0 )
printk( KERN_INFO "%s", version ); printk( KERN_INFO "%s", version );
if( !dev ) { /* simple sanity check */ dev = alloc_netdev(sizeof(struct net_local), "sbni%d", sbni_devsetup);
printk( KERN_ERR "sbni: NULL device!\n" ); if (!dev)
return -ENOMEM;
netdev_boot_setup_check(dev);
if (register_netdev(dev)) {
kfree(dev);
return -ENODEV; return -ENODEV;
} }
return 0;
}
SET_MODULE_OWNER( dev ); static int __init sbni_init(struct net_device *dev)
{
int i;
if( dev->base_addr ) if( dev->base_addr )
return sbni_isa_probe( dev ); return sbni_isa_probe( dev );
/* otherwise we have to perform search our adapter */ /* otherwise we have to perform search our adapter */
...@@ -338,7 +360,7 @@ sbni_probe1( struct net_device *dev, unsigned long ioaddr, int irq ) ...@@ -338,7 +360,7 @@ sbni_probe1( struct net_device *dev, unsigned long ioaddr, int irq )
dev->base_addr = ioaddr; dev->base_addr = ioaddr;
/* Allocate dev->priv and fill in sbni-specific dev fields. */ /* Allocate dev->priv and fill in sbni-specific dev fields. */
nl = (struct net_local *) kmalloc(sizeof(struct net_local), GFP_KERNEL); nl = dev->priv;
if( !nl ) { if( !nl ) {
printk( KERN_ERR "%s: unable to get memory!\n", dev->name ); printk( KERN_ERR "%s: unable to get memory!\n", dev->name );
release_region( ioaddr, SBNI_IO_EXTENT ); release_region( ioaddr, SBNI_IO_EXTENT );
...@@ -389,14 +411,6 @@ sbni_probe1( struct net_device *dev, unsigned long ioaddr, int irq ) ...@@ -389,14 +411,6 @@ sbni_probe1( struct net_device *dev, unsigned long ioaddr, int irq )
nl->link = NULL; nl->link = NULL;
#endif #endif
dev->open = &sbni_open;
dev->stop = &sbni_close;
dev->hard_start_xmit = &sbni_start_xmit;
dev->get_stats = &sbni_get_stats;
dev->set_multicast_list = &set_multicast_list;
dev->do_ioctl = &sbni_ioctl;
ether_setup( dev );
sbni_cards[ num++ ] = dev; sbni_cards[ num++ ] = dev;
return dev; return dev;
} }
...@@ -1478,15 +1492,15 @@ init_module( void ) ...@@ -1478,15 +1492,15 @@ init_module( void )
struct net_device *dev; struct net_device *dev;
while( num < SBNI_MAX_NUM_CARDS ) { while( num < SBNI_MAX_NUM_CARDS ) {
if( !(dev = kmalloc(sizeof(struct net_device), GFP_KERNEL)) ){ dev = alloc_netdev(sizeof(struct net_local),
"sbni%d", sbni_devsetup);
if( !dev) {
printk( KERN_ERR "sbni: unable to allocate device!\n" ); printk( KERN_ERR "sbni: unable to allocate device!\n" );
return -ENOMEM; return -ENOMEM;
} }
memset( dev, 0, sizeof(struct net_device) );
sprintf( dev->name, "sbni%d", num ); sprintf( dev->name, "sbni%d", num );
dev->init = sbni_probe;
if( register_netdev( dev ) ) { if( register_netdev( dev ) ) {
kfree( dev ); kfree( dev );
break; break;
...@@ -1506,7 +1520,6 @@ cleanup_module( void ) ...@@ -1506,7 +1520,6 @@ cleanup_module( void )
if( (dev = sbni_cards[ num ]) != NULL ) { if( (dev = sbni_cards[ num ]) != NULL ) {
unregister_netdev( dev ); unregister_netdev( dev );
release_region( dev->base_addr, SBNI_IO_EXTENT ); release_region( dev->base_addr, SBNI_IO_EXTENT );
kfree( dev->priv );
free_netdev( dev ); free_netdev( dev );
} }
} }
......
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