Commit 0bd56a0a authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://gkernel.bkbits.net/net-drivers-2.5

into home.osdl.org:/home/torvalds/v2.5/linux
parents 774bf415 ec041cd9
This diff is collapsed.
This diff is collapsed.
...@@ -244,7 +244,6 @@ typedef struct _mgslpc_info { ...@@ -244,7 +244,6 @@ typedef struct _mgslpc_info {
char netname[10]; char netname[10];
struct net_device *netdev; struct net_device *netdev;
struct net_device_stats netstats; struct net_device_stats netstats;
struct net_device netdevice;
#endif #endif
} MGSLPC_INFO; } MGSLPC_INFO;
...@@ -4206,35 +4205,46 @@ void tx_timeout(unsigned long context) ...@@ -4206,35 +4205,46 @@ void tx_timeout(unsigned long context)
#ifdef CONFIG_SYNCLINK_SYNCPPP #ifdef CONFIG_SYNCLINK_SYNCPPP
/* syncppp net device routines /* syncppp net device routines
*/ */
static void mgslpc_setup(struct net_device *dev)
{
dev->open = mgslpc_sppp_open;
dev->stop = mgslpc_sppp_close;
dev->hard_start_xmit = mgslpc_sppp_tx;
dev->do_ioctl = mgslpc_sppp_ioctl;
dev->get_stats = mgslpc_net_stats;
dev->tx_timeout = mgslpc_sppp_tx_timeout;
dev->watchdog_timeo = 10*HZ;
}
void mgslpc_sppp_init(MGSLPC_INFO *info) void mgslpc_sppp_init(MGSLPC_INFO *info)
{ {
struct net_device *d; struct net_device *d;
sprintf(info->netname,"mgslp%d",info->line); sprintf(info->netname,"mgslp%d",info->line);
d = alloc_netdev(0, info->netname, mgslpc_setup);
if (!d) {
printk(KERN_WARNING "%s: alloc_netdev failed.\n",
info->netname);
return;
}
info->if_ptr = &info->pppdev; info->if_ptr = &info->pppdev;
info->netdev = info->pppdev.dev = &info->netdevice; info->netdev = info->pppdev.dev = d;
sppp_attach(&info->pppdev); sppp_attach(&info->pppdev);
d = info->netdev;
strcpy(d->name,info->netname);
d->base_addr = info->io_base; d->base_addr = info->io_base;
d->irq = info->irq_level; d->irq = info->irq_level;
d->priv = info; d->priv = info;
d->init = NULL;
d->open = mgslpc_sppp_open;
d->stop = mgslpc_sppp_close;
d->hard_start_xmit = mgslpc_sppp_tx;
d->do_ioctl = mgslpc_sppp_ioctl;
d->get_stats = mgslpc_net_stats;
d->tx_timeout = mgslpc_sppp_tx_timeout;
d->watchdog_timeo = 10*HZ;
if (register_netdev(d)) { if (register_netdev(d)) {
printk(KERN_WARNING "%s: register_netdev failed.\n", d->name); printk(KERN_WARNING "%s: register_netdev failed.\n", d->name);
sppp_detach(info->netdev); sppp_detach(info->netdev);
info->netdev = NULL;
info->pppdev.dev = NULL;
free_netdev(d);
return; return;
} }
...@@ -4246,8 +4256,11 @@ void mgslpc_sppp_delete(MGSLPC_INFO *info) ...@@ -4246,8 +4256,11 @@ void mgslpc_sppp_delete(MGSLPC_INFO *info)
{ {
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("mgslpc_sppp_delete(%s)\n",info->netname); printk("mgslpc_sppp_delete(%s)\n",info->netname);
sppp_detach(info->netdev);
unregister_netdev(info->netdev); unregister_netdev(info->netdev);
sppp_detach(info->netdev);
free_netdev(info->netdev);
info->netdev = NULL;
info->pppdev.dev = NULL;
} }
int mgslpc_sppp_open(struct net_device *d) int mgslpc_sppp_open(struct net_device *d)
......
...@@ -327,7 +327,6 @@ struct mgsl_struct { ...@@ -327,7 +327,6 @@ struct mgsl_struct {
char netname[10]; char netname[10];
struct net_device *netdev; struct net_device *netdev;
struct net_device_stats netstats; struct net_device_stats netstats;
struct net_device netdevice;
#endif #endif
}; };
...@@ -737,8 +736,8 @@ int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long ...@@ -737,8 +736,8 @@ int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long
#ifdef CONFIG_SYNCLINK_SYNCPPP #ifdef CONFIG_SYNCLINK_SYNCPPP
/* SPPP/HDLC stuff */ /* SPPP/HDLC stuff */
void mgsl_sppp_init(struct mgsl_struct *info); static void mgsl_sppp_init(struct mgsl_struct *info);
void mgsl_sppp_delete(struct mgsl_struct *info); static void mgsl_sppp_delete(struct mgsl_struct *info);
int mgsl_sppp_open(struct net_device *d); int mgsl_sppp_open(struct net_device *d);
int mgsl_sppp_close(struct net_device *d); int mgsl_sppp_close(struct net_device *d);
void mgsl_sppp_tx_timeout(struct net_device *d); void mgsl_sppp_tx_timeout(struct net_device *d);
...@@ -7820,36 +7819,45 @@ int usc_loopmode_send_active( struct mgsl_struct * info ) ...@@ -7820,36 +7819,45 @@ int usc_loopmode_send_active( struct mgsl_struct * info )
#ifdef CONFIG_SYNCLINK_SYNCPPP #ifdef CONFIG_SYNCLINK_SYNCPPP
/* syncppp net device routines /* syncppp net device routines
*/ */
static void mgsl_setup(struct net_device *dev)
{
dev->open = mgsl_sppp_open;
dev->stop = mgsl_sppp_close;
dev->hard_start_xmit = mgsl_sppp_tx;
dev->do_ioctl = mgsl_sppp_ioctl;
dev->get_stats = mgsl_net_stats;
dev->tx_timeout = mgsl_sppp_tx_timeout;
dev->watchdog_timeo = 10*HZ;
}
void mgsl_sppp_init(struct mgsl_struct *info) static void mgsl_sppp_init(struct mgsl_struct *info)
{ {
struct net_device *d; struct net_device *d;
sprintf(info->netname,"mgsl%d",info->line); sprintf(info->netname,"mgsl%d",info->line);
d = alloc_netdev(0, info->netname, mgsl_setup);
if (!d) {
printk(KERN_WARNING "%s: alloc_netdev failed.\n",
info->netname);
return;
}
info->if_ptr = &info->pppdev; info->if_ptr = &info->pppdev;
info->netdev = info->pppdev.dev = &info->netdevice; info->netdev = info->pppdev.dev = d;
sppp_attach(&info->pppdev); sppp_attach(&info->pppdev);
d = info->netdev;
strcpy(d->name,info->netname);
d->base_addr = info->io_base; d->base_addr = info->io_base;
d->irq = info->irq_level; d->irq = info->irq_level;
d->dma = info->dma_level; d->dma = info->dma_level;
d->priv = info; d->priv = info;
d->init = NULL;
d->open = mgsl_sppp_open;
d->stop = mgsl_sppp_close;
d->hard_start_xmit = mgsl_sppp_tx;
d->do_ioctl = mgsl_sppp_ioctl;
d->get_stats = mgsl_net_stats;
d->tx_timeout = mgsl_sppp_tx_timeout;
d->watchdog_timeo = 10*HZ;
if (register_netdev(d)) { if (register_netdev(d)) {
printk(KERN_WARNING "%s: register_netdev failed.\n", d->name); printk(KERN_WARNING "%s: register_netdev failed.\n", d->name);
sppp_detach(info->netdev); sppp_detach(info->netdev);
info->netdev = NULL;
free_netdev(d);
return; return;
} }
...@@ -7861,8 +7869,11 @@ void mgsl_sppp_delete(struct mgsl_struct *info) ...@@ -7861,8 +7869,11 @@ void mgsl_sppp_delete(struct mgsl_struct *info)
{ {
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("mgsl_sppp_delete(%s)\n",info->netname); printk("mgsl_sppp_delete(%s)\n",info->netname);
sppp_detach(info->netdev);
unregister_netdev(info->netdev); unregister_netdev(info->netdev);
sppp_detach(info->netdev);
free_netdev(info->netdev);
info->netdev = NULL;
info->pppdev.dev = NULL;
} }
int mgsl_sppp_open(struct net_device *d) int mgsl_sppp_open(struct net_device *d)
......
...@@ -289,7 +289,6 @@ typedef struct _synclinkmp_info { ...@@ -289,7 +289,6 @@ typedef struct _synclinkmp_info {
char netname[10]; char netname[10];
struct net_device *netdev; struct net_device *netdev;
struct net_device_stats netstats; struct net_device_stats netstats;
struct net_device netdevice;
#endif #endif
} SLMP_INFO; } SLMP_INFO;
...@@ -1627,35 +1626,44 @@ static void set_break(struct tty_struct *tty, int break_state) ...@@ -1627,35 +1626,44 @@ static void set_break(struct tty_struct *tty, int break_state)
/* syncppp support and callbacks */ /* syncppp support and callbacks */
static void cb_setup(struct net_device *dev)
{
dev->open = sppp_cb_open;
dev->stop = sppp_cb_close;
dev->hard_start_xmit = sppp_cb_tx;
dev->do_ioctl = sppp_cb_ioctl;
dev->get_stats = sppp_cb_net_stats;
dev->tx_timeout = sppp_cb_tx_timeout;
dev->watchdog_timeo = 10*HZ;
}
static void sppp_init(SLMP_INFO *info) static void sppp_init(SLMP_INFO *info)
{ {
struct net_device *d; struct net_device *d;
sprintf(info->netname,"mgslm%dp%d",info->adapter_num,info->port_num); sprintf(info->netname,"mgslm%dp%d",info->adapter_num,info->port_num);
d = alloc_netdev(0, info->netname, cb_setup);
if (!d) {
printk(KERN_WARNING "%s: alloc_netdev failed.\n",
info->netname);
return;
}
info->if_ptr = &info->pppdev; info->if_ptr = &info->pppdev;
info->netdev = info->pppdev.dev = &info->netdevice; info->netdev = info->pppdev.dev = d;
sppp_attach(&info->pppdev); sppp_attach(&info->pppdev);
d = info->netdev;
strcpy(d->name,info->netname);
d->base_addr = 0;
d->irq = info->irq_level; d->irq = info->irq_level;
d->dma = 0;
d->priv = info; d->priv = info;
d->init = NULL;
d->open = sppp_cb_open;
d->stop = sppp_cb_close;
d->hard_start_xmit = sppp_cb_tx;
d->do_ioctl = sppp_cb_ioctl;
d->get_stats = sppp_cb_net_stats;
d->tx_timeout = sppp_cb_tx_timeout;
d->watchdog_timeo = 10*HZ;
if (register_netdev(d)) { if (register_netdev(d)) {
printk(KERN_WARNING "%s: register_netdev failed.\n", d->name); printk(KERN_WARNING "%s: register_netdev failed.\n", d->name);
sppp_detach(info->netdev); sppp_detach(info->netdev);
info->netdev = NULL;
info->pppdev.dev = NULL;
free_netdev(d);
return; return;
} }
...@@ -1667,8 +1675,11 @@ static void sppp_delete(SLMP_INFO *info) ...@@ -1667,8 +1675,11 @@ static void sppp_delete(SLMP_INFO *info)
{ {
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("sppp_delete(%s)\n",info->netname); printk("sppp_delete(%s)\n",info->netname);
sppp_detach(info->netdev);
unregister_netdev(info->netdev); unregister_netdev(info->netdev);
sppp_detach(info->netdev);
free_netdev(info->netdev);
info->netdev = NULL;
info->pppdev.dev = NULL;
} }
static int sppp_cb_open(struct net_device *d) static int sppp_cb_open(struct net_device *d)
......
...@@ -395,8 +395,8 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu) ...@@ -395,8 +395,8 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
} }
} }
/* This function is called by register_netdev */ /* This function is called right before register_netdev */
static int ether1394_init_dev (struct net_device *dev) static void ether1394_init_dev (struct net_device *dev)
{ {
/* Our functions */ /* Our functions */
dev->open = ether1394_open; dev->open = ether1394_open;
...@@ -423,8 +423,6 @@ static int ether1394_init_dev (struct net_device *dev) ...@@ -423,8 +423,6 @@ static int ether1394_init_dev (struct net_device *dev)
dev->type = ARPHRD_IEEE1394; dev->type = ARPHRD_IEEE1394;
ether1394_reset_priv (dev, 1); ether1394_reset_priv (dev, 1);
return 0;
} }
/* /*
...@@ -461,8 +459,6 @@ static void ether1394_add_host (struct hpsb_host *host) ...@@ -461,8 +459,6 @@ static void ether1394_add_host (struct hpsb_host *host)
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
dev->init = ether1394_init_dev;
priv = (struct eth1394_priv *)dev->priv; priv = (struct eth1394_priv *)dev->priv;
spin_lock_init(&priv->lock); spin_lock_init(&priv->lock);
...@@ -483,6 +479,8 @@ static void ether1394_add_host (struct hpsb_host *host) ...@@ -483,6 +479,8 @@ static void ether1394_add_host (struct hpsb_host *host)
goto out; goto out;
} }
ether1394_init_dev(dev);
if (register_netdev (dev)) { if (register_netdev (dev)) {
ETH1394_PRINT (KERN_ERR, dev->name, "Error registering network driver\n"); ETH1394_PRINT (KERN_ERR, dev->name, "Error registering network driver\n");
goto out; goto out;
...@@ -507,7 +505,7 @@ static void ether1394_add_host (struct hpsb_host *host) ...@@ -507,7 +505,7 @@ static void ether1394_add_host (struct hpsb_host *host)
out: out:
if (dev != NULL) if (dev != NULL)
kfree(dev); free_netdev(dev);
if (hi) if (hi)
hpsb_destroy_hostinfo(&eth1394_highlevel, host); hpsb_destroy_hostinfo(&eth1394_highlevel, host);
......
...@@ -145,12 +145,11 @@ static void cleanup_card(struct net_device *dev) ...@@ -145,12 +145,11 @@ static void cleanup_card(struct net_device *dev)
{ {
/* NB: el2_close() handles free_irq */ /* NB: el2_close() handles free_irq */
release_region(dev->base_addr, EL2_IO_EXTENT); release_region(dev->base_addr, EL2_IO_EXTENT);
kfree(dev->priv);
} }
struct net_device * __init el2_probe(int unit) struct net_device * __init el2_probe(int unit)
{ {
struct net_device *dev = alloc_etherdev(0); struct net_device *dev = alloc_ei_netdev();
int err; int err;
if (!dev) if (!dev)
...@@ -159,8 +158,6 @@ struct net_device * __init el2_probe(int unit) ...@@ -159,8 +158,6 @@ struct net_device * __init el2_probe(int unit)
sprintf(dev->name, "eth%d", unit); sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev); netdev_boot_setup_check(dev);
dev->priv = NULL; /* until all 8390-based use alloc_etherdev() */
err = do_el2_probe(dev); err = do_el2_probe(dev);
if (err) if (err)
goto out; goto out;
...@@ -228,12 +225,6 @@ el2_probe1(struct net_device *dev, int ioaddr) ...@@ -228,12 +225,6 @@ el2_probe1(struct net_device *dev, int ioaddr)
printk(version); printk(version);
dev->base_addr = ioaddr; dev->base_addr = ioaddr;
/* Allocate dev->priv and fill in 8390 specific dev fields. */
if (ethdev_init(dev)) {
printk ("3c503: unable to allocate memory for dev->priv.\n");
retval = -ENOMEM;
goto out1;
}
printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr); printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
...@@ -699,10 +690,9 @@ init_module(void) ...@@ -699,10 +690,9 @@ init_module(void)
if (this_dev != 0) break; /* only autoprobe 1st one */ if (this_dev != 0) break; /* only autoprobe 1st one */
printk(KERN_NOTICE "3c503.c: Presently autoprobing (not recommended) for a single card.\n"); printk(KERN_NOTICE "3c503.c: Presently autoprobing (not recommended) for a single card.\n");
} }
dev = alloc_etherdev(0); dev = alloc_ei_netdev();
if (!dev) if (!dev)
break; break;
dev->priv = NULL;
dev->irq = irq[this_dev]; dev->irq = irq[this_dev];
dev->base_addr = io[this_dev]; dev->base_addr = io[this_dev];
dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */ dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
......
...@@ -157,15 +157,8 @@ static void do_set_multicast_list(struct net_device *dev); ...@@ -157,15 +157,8 @@ static void do_set_multicast_list(struct net_device *dev);
int ei_open(struct net_device *dev) int ei_open(struct net_device *dev)
{ {
unsigned long flags; unsigned long flags;
struct ei_device *ei_local = (struct ei_device *) dev->priv; struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
/* This can't happen unless somebody forgot to call ethdev_init(). */
if (ei_local == NULL)
{
printk(KERN_EMERG "%s: ei_open passed a non-existent device!\n", dev->name);
return -ENXIO;
}
/* The card I/O part of the driver (e.g. 3c503) can hook a Tx timeout /* The card I/O part of the driver (e.g. 3c503) can hook a Tx timeout
wrapper that does e.g. media check & then calls ei_tx_timeout. */ wrapper that does e.g. media check & then calls ei_tx_timeout. */
if (dev->tx_timeout == NULL) if (dev->tx_timeout == NULL)
...@@ -196,7 +189,7 @@ int ei_open(struct net_device *dev) ...@@ -196,7 +189,7 @@ int ei_open(struct net_device *dev)
*/ */
int ei_close(struct net_device *dev) int ei_close(struct net_device *dev)
{ {
struct ei_device *ei_local = (struct ei_device *) dev->priv; struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
unsigned long flags; unsigned long flags;
/* /*
...@@ -221,7 +214,7 @@ int ei_close(struct net_device *dev) ...@@ -221,7 +214,7 @@ int ei_close(struct net_device *dev)
void ei_tx_timeout(struct net_device *dev) void ei_tx_timeout(struct net_device *dev)
{ {
long e8390_base = dev->base_addr; long e8390_base = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) dev->priv; struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
int txsr, isr, tickssofar = jiffies - dev->trans_start; int txsr, isr, tickssofar = jiffies - dev->trans_start;
unsigned long flags; unsigned long flags;
...@@ -267,7 +260,7 @@ void ei_tx_timeout(struct net_device *dev) ...@@ -267,7 +260,7 @@ void ei_tx_timeout(struct net_device *dev)
static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev) static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
long e8390_base = dev->base_addr; long e8390_base = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) dev->priv; struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
int length, send_length, output_page; int length, send_length, output_page;
unsigned long flags; unsigned long flags;
char scratch[ETH_ZLEN]; char scratch[ETH_ZLEN];
...@@ -435,7 +428,7 @@ irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs * regs) ...@@ -435,7 +428,7 @@ irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs * regs)
} }
e8390_base = dev->base_addr; e8390_base = dev->base_addr;
ei_local = (struct ei_device *) dev->priv; ei_local = (struct ei_device *) netdev_priv(dev);
/* /*
* Protect the irq test too. * Protect the irq test too.
...@@ -540,7 +533,7 @@ irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs * regs) ...@@ -540,7 +533,7 @@ irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs * regs)
static void ei_tx_err(struct net_device *dev) static void ei_tx_err(struct net_device *dev)
{ {
long e8390_base = dev->base_addr; long e8390_base = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) dev->priv; struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
unsigned char txsr = inb_p(e8390_base+EN0_TSR); unsigned char txsr = inb_p(e8390_base+EN0_TSR);
unsigned char tx_was_aborted = txsr & (ENTSR_ABT+ENTSR_FU); unsigned char tx_was_aborted = txsr & (ENTSR_ABT+ENTSR_FU);
...@@ -583,7 +576,7 @@ static void ei_tx_err(struct net_device *dev) ...@@ -583,7 +576,7 @@ static void ei_tx_err(struct net_device *dev)
static void ei_tx_intr(struct net_device *dev) static void ei_tx_intr(struct net_device *dev)
{ {
long e8390_base = dev->base_addr; long e8390_base = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) dev->priv; struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
int status = inb(e8390_base + EN0_TSR); int status = inb(e8390_base + EN0_TSR);
outb_p(ENISR_TX, e8390_base + EN0_ISR); /* Ack intr. */ outb_p(ENISR_TX, e8390_base + EN0_ISR); /* Ack intr. */
...@@ -675,7 +668,7 @@ static void ei_tx_intr(struct net_device *dev) ...@@ -675,7 +668,7 @@ static void ei_tx_intr(struct net_device *dev)
static void ei_receive(struct net_device *dev) static void ei_receive(struct net_device *dev)
{ {
long e8390_base = dev->base_addr; long e8390_base = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) dev->priv; struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
unsigned char rxing_page, this_frame, next_frame; unsigned char rxing_page, this_frame, next_frame;
unsigned short current_offset; unsigned short current_offset;
int rx_pkt_count = 0; int rx_pkt_count = 0;
...@@ -813,7 +806,7 @@ static void ei_rx_overrun(struct net_device *dev) ...@@ -813,7 +806,7 @@ static void ei_rx_overrun(struct net_device *dev)
{ {
long e8390_base = dev->base_addr; long e8390_base = dev->base_addr;
unsigned char was_txing, must_resend = 0; unsigned char was_txing, must_resend = 0;
struct ei_device *ei_local = (struct ei_device *) dev->priv; struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
/* /*
* Record whether a Tx was in progress and then issue the * Record whether a Tx was in progress and then issue the
...@@ -881,7 +874,7 @@ static void ei_rx_overrun(struct net_device *dev) ...@@ -881,7 +874,7 @@ static void ei_rx_overrun(struct net_device *dev)
static struct net_device_stats *get_stats(struct net_device *dev) static struct net_device_stats *get_stats(struct net_device *dev)
{ {
long ioaddr = dev->base_addr; long ioaddr = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) dev->priv; struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
unsigned long flags; unsigned long flags;
/* If the card is stopped, just return the present stats. */ /* If the card is stopped, just return the present stats. */
...@@ -936,7 +929,7 @@ static void do_set_multicast_list(struct net_device *dev) ...@@ -936,7 +929,7 @@ static void do_set_multicast_list(struct net_device *dev)
{ {
long e8390_base = dev->base_addr; long e8390_base = dev->base_addr;
int i; int i;
struct ei_device *ei_local = (struct ei_device*)dev->priv; struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))) if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI)))
{ {
...@@ -990,53 +983,34 @@ static void do_set_multicast_list(struct net_device *dev) ...@@ -990,53 +983,34 @@ static void do_set_multicast_list(struct net_device *dev)
static void set_multicast_list(struct net_device *dev) static void set_multicast_list(struct net_device *dev)
{ {
unsigned long flags; unsigned long flags;
struct ei_device *ei_local = (struct ei_device*)dev->priv; struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
spin_lock_irqsave(&ei_local->page_lock, flags); spin_lock_irqsave(&ei_local->page_lock, flags);
do_set_multicast_list(dev); do_set_multicast_list(dev);
spin_unlock_irqrestore(&ei_local->page_lock, flags); spin_unlock_irqrestore(&ei_local->page_lock, flags);
} }
static inline void ei_device_init(struct ei_device *ei_local)
{
spin_lock_init(&ei_local->page_lock);
}
/** /**
* ethdev_init - init rest of 8390 device struct * ethdev_setup - init rest of 8390 device struct
* @dev: network device structure to init * @dev: network device structure to init
* *
* Initialize the rest of the 8390 device structure. Do NOT __init * Initialize the rest of the 8390 device structure. Do NOT __init
* this, as it is used by 8390 based modular drivers too. * this, as it is used by 8390 based modular drivers too.
*/ */
int ethdev_init(struct net_device *dev) static void ethdev_setup(struct net_device *dev)
{ {
struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
if (ei_debug > 1) if (ei_debug > 1)
printk(version); printk(version);
if (dev->priv == NULL)
{
dev->priv = kmalloc(sizeof(struct ei_device), GFP_KERNEL);
if (dev->priv == NULL)
return -ENOMEM;
memset(dev->priv, 0, sizeof(struct ei_device));
ei_device_init(dev->priv);
}
dev->hard_start_xmit = &ei_start_xmit; dev->hard_start_xmit = &ei_start_xmit;
dev->get_stats = get_stats; dev->get_stats = get_stats;
dev->set_multicast_list = &set_multicast_list; dev->set_multicast_list = &set_multicast_list;
ether_setup(dev); ether_setup(dev);
return 0;
}
/* wrapper to make alloc_netdev happy; probably should just cast... */ spin_lock_init(&ei_local->page_lock);
static void __ethdev_init(struct net_device *dev)
{
ethdev_init(dev);
} }
/** /**
...@@ -1044,15 +1018,10 @@ static void __ethdev_init(struct net_device *dev) ...@@ -1044,15 +1018,10 @@ static void __ethdev_init(struct net_device *dev)
* *
* Allocate 8390-specific net_device. * Allocate 8390-specific net_device.
*/ */
struct net_device *alloc_ei_netdev(void) struct net_device *__alloc_ei_netdev(int size)
{ {
struct net_device *dev; return alloc_netdev(sizeof(struct ei_device) + size, "eth%d",
ethdev_setup);
dev = alloc_netdev(sizeof(struct ei_device), "eth%d", __ethdev_init);
if (dev)
ei_device_init(dev->priv);
return dev;
} }
...@@ -1072,7 +1041,7 @@ struct net_device *alloc_ei_netdev(void) ...@@ -1072,7 +1041,7 @@ struct net_device *alloc_ei_netdev(void)
void NS8390_init(struct net_device *dev, int startp) void NS8390_init(struct net_device *dev, int startp)
{ {
long e8390_base = dev->base_addr; long e8390_base = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) dev->priv; struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
int i; int i;
int endcfg = ei_local->word16 int endcfg = ei_local->word16
? (0x48 | ENDCFG_WTS | (ei_local->bigendian ? ENDCFG_BOS : 0)) ? (0x48 | ENDCFG_WTS | (ei_local->bigendian ? ENDCFG_BOS : 0))
...@@ -1136,7 +1105,7 @@ static void NS8390_trigger_send(struct net_device *dev, unsigned int length, ...@@ -1136,7 +1105,7 @@ static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
int start_page) int start_page)
{ {
long e8390_base = dev->base_addr; long e8390_base = dev->base_addr;
struct ei_device *ei_local __attribute((unused)) = (struct ei_device *) dev->priv; struct ei_device *ei_local __attribute((unused)) = (struct ei_device *) netdev_priv(dev);
outb_p(E8390_NODMA+E8390_PAGE0, e8390_base+E8390_CMD); outb_p(E8390_NODMA+E8390_PAGE0, e8390_base+E8390_CMD);
...@@ -1156,9 +1125,8 @@ EXPORT_SYMBOL(ei_open); ...@@ -1156,9 +1125,8 @@ EXPORT_SYMBOL(ei_open);
EXPORT_SYMBOL(ei_close); EXPORT_SYMBOL(ei_close);
EXPORT_SYMBOL(ei_interrupt); EXPORT_SYMBOL(ei_interrupt);
EXPORT_SYMBOL(ei_tx_timeout); EXPORT_SYMBOL(ei_tx_timeout);
EXPORT_SYMBOL(ethdev_init);
EXPORT_SYMBOL(NS8390_init); EXPORT_SYMBOL(NS8390_init);
EXPORT_SYMBOL(alloc_ei_netdev); EXPORT_SYMBOL(__alloc_ei_netdev);
#if defined(MODULE) #if defined(MODULE)
......
...@@ -39,12 +39,15 @@ extern int ei_debug; ...@@ -39,12 +39,15 @@ extern int ei_debug;
#define ei_debug 1 #define ei_debug 1
#endif #endif
extern int ethdev_init(struct net_device *dev);
extern void NS8390_init(struct net_device *dev, int startp); extern void NS8390_init(struct net_device *dev, int startp);
extern int ei_open(struct net_device *dev); extern int ei_open(struct net_device *dev);
extern int ei_close(struct net_device *dev); extern int ei_close(struct net_device *dev);
extern irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs *regs); extern irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs *regs);
extern struct net_device *alloc_ei_netdev(void); extern struct net_device *__alloc_ei_netdev(int size);
static inline struct net_device *alloc_ei_netdev(void)
{
return __alloc_ei_netdev(0);
}
/* You have one of these per-board */ /* You have one of these per-board */
struct ei_device { struct ei_device {
...@@ -84,7 +87,7 @@ struct ei_device { ...@@ -84,7 +87,7 @@ struct ei_device {
/* The maximum time waited (in jiffies) before assuming a Tx failed. (20ms) */ /* The maximum time waited (in jiffies) before assuming a Tx failed. (20ms) */
#define TX_TIMEOUT (20*HZ/100) #define TX_TIMEOUT (20*HZ/100)
#define ei_status (*(struct ei_device *)(dev->priv)) #define ei_status (*(struct ei_device *)netdev_priv(dev))
/* Some generic ethernet register configurations. */ /* Some generic ethernet register configurations. */
#define E8390_TX_IRQ_MASK 0xa /* For register EN0_ISR */ #define E8390_TX_IRQ_MASK 0xa /* For register EN0_ISR */
......
...@@ -74,7 +74,7 @@ extern struct net_device *sonic_probe(int unit); ...@@ -74,7 +74,7 @@ extern struct net_device *sonic_probe(int unit);
extern struct net_device *SK_init(int unit); extern struct net_device *SK_init(int unit);
extern struct net_device *seeq8005_probe(int unit); extern struct net_device *seeq8005_probe(int unit);
extern struct net_device *smc_init(int unit); extern struct net_device *smc_init(int unit);
extern struct net_device *atarilance_probe(struct net_device *); extern struct net_device *atarilance_probe(int unit);
extern struct net_device *sun3lance_probe(int unit); extern struct net_device *sun3lance_probe(int unit);
extern struct net_device *sun3_82586_probe(int unit); extern struct net_device *sun3_82586_probe(int unit);
extern struct net_device *apne_probe(int unit); extern struct net_device *apne_probe(int unit);
...@@ -86,7 +86,7 @@ extern struct net_device *bagetlance_probe(int unit); ...@@ -86,7 +86,7 @@ extern struct net_device *bagetlance_probe(int unit);
extern struct net_device *mvme147lance_probe(int unit); extern struct net_device *mvme147lance_probe(int unit);
extern struct net_device *tc515_probe(int unit); extern struct net_device *tc515_probe(int unit);
extern struct net_device *lance_probe(int unit); extern struct net_device *lance_probe(int unit);
extern struct net_device *mace_probe(struct net_device *dev); extern struct net_device *mace_probe(int unit);
extern struct net_device *macsonic_probe(int unit); extern struct net_device *macsonic_probe(int unit);
extern struct net_device *mac8390_probe(int unit); extern struct net_device *mac8390_probe(int unit);
extern struct net_device *mac89x0_probe(int unit); extern struct net_device *mac89x0_probe(int unit);
...@@ -326,17 +326,17 @@ static void __init ethif_probe2(int unit) ...@@ -326,17 +326,17 @@ static void __init ethif_probe2(int unit)
if (base_addr == 1) if (base_addr == 1)
return; return;
probe_list2(unit, m68k_probes, base_addr == 0) && (void)( probe_list2(unit, m68k_probes, base_addr == 0) &&
probe_list2(unit, mips_probes, base_addr == 0) && probe_list2(unit, mips_probes, base_addr == 0) &&
probe_list2(unit, eisa_probes, base_addr == 0) && probe_list2(unit, eisa_probes, base_addr == 0) &&
probe_list2(unit, mca_probes, base_addr == 0) && probe_list2(unit, mca_probes, base_addr == 0) &&
probe_list2(unit, isa_probes, base_addr == 0) && probe_list2(unit, isa_probes, base_addr == 0) &&
probe_list2(unit, parport_probes, base_addr == 0); probe_list2(unit, parport_probes, base_addr == 0));
} }
#ifdef CONFIG_TR #ifdef CONFIG_TR
/* Token-ring device probe */ /* Token-ring device probe */
extern int ibmtr_probe(struct net_device *); extern int ibmtr_probe_card(struct net_device *);
extern struct net_device *sk_isa_probe(int unit); extern struct net_device *sk_isa_probe(int unit);
extern struct net_device *proteon_probe(int unit); extern struct net_device *proteon_probe(int unit);
extern struct net_device *smctr_probe(int unit); extern struct net_device *smctr_probe(int unit);
...@@ -356,26 +356,19 @@ static struct devprobe2 tr_probes2[] __initdata = { ...@@ -356,26 +356,19 @@ static struct devprobe2 tr_probes2[] __initdata = {
static __init int trif_probe(int unit) static __init int trif_probe(int unit)
{ {
struct net_device *dev;
int err = -ENODEV; int err = -ENODEV;
#ifdef CONFIG_IBMTR
dev = alloc_trdev(0); struct net_device *dev = alloc_trdev(0);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
sprintf(dev->name, "tr%d", unit); sprintf(dev->name, "tr%d", unit);
netdev_boot_setup_check(dev); netdev_boot_setup_check(dev);
if ( err = ibmtr_probe_card(dev);
#ifdef CONFIG_IBMTR
ibmtr_probe(dev) == 0 ||
#endif
0 )
err = register_netdev(dev);
if (err) if (err)
free_netdev(dev); free_netdev(dev);
#endif
return err; return err;
} }
static void __init trif_probe2(int unit) static void __init trif_probe2(int unit)
......
...@@ -737,7 +737,7 @@ static int __init a2065_probe(void) ...@@ -737,7 +737,7 @@ static int __init a2065_probe(void)
continue; continue;
} }
dev = alloc_etherdev(0, sizeof(struct lance_private)); dev = alloc_etherdev(sizeof(struct lance_private));
if (dev == NULL) { if (dev == NULL) {
release_resource(r1); release_resource(r1);
......
...@@ -128,12 +128,11 @@ static void cleanup_card(struct net_device *dev) ...@@ -128,12 +128,11 @@ static void cleanup_card(struct net_device *dev)
release_region(dev->base_addr, AC_IO_EXTENT); release_region(dev->base_addr, AC_IO_EXTENT);
if (ei_status.reg0) if (ei_status.reg0)
iounmap((void *)dev->mem_start); iounmap((void *)dev->mem_start);
kfree(dev->priv);
} }
struct net_device * __init ac3200_probe(int unit) struct net_device * __init ac3200_probe(int unit)
{ {
struct net_device *dev = alloc_etherdev(0); struct net_device *dev = alloc_ei_netdev();
int err; int err;
if (!dev) if (!dev)
...@@ -142,8 +141,6 @@ struct net_device * __init ac3200_probe(int unit) ...@@ -142,8 +141,6 @@ struct net_device * __init ac3200_probe(int unit)
sprintf(dev->name, "eth%d", unit); sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev); netdev_boot_setup_check(dev);
dev->priv = NULL; /* until all 8390-based use alloc_etherdev() */
err = do_ac3200_probe(dev); err = do_ac3200_probe(dev);
if (err) if (err)
goto out; goto out;
...@@ -197,13 +194,6 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev) ...@@ -197,13 +194,6 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev)
} }
#endif #endif
/* Allocate dev->priv and fill in 8390 specific dev fields. */
if (ethdev_init(dev)) {
printk (", unable to allocate memory for dev->priv.\n");
retval = -ENOMEM;
goto out;
}
/* Assign and allocate the interrupt now. */ /* Assign and allocate the interrupt now. */
if (dev->irq == 0) { if (dev->irq == 0) {
dev->irq = config2irq(inb(ioaddr + AC_CONFIG)); dev->irq = config2irq(inb(ioaddr + AC_CONFIG));
...@@ -251,7 +241,7 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev) ...@@ -251,7 +241,7 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev)
printk(KERN_CRIT "ac3200.c: or to an address above 0x%lx.\n", virt_to_phys(high_memory)); printk(KERN_CRIT "ac3200.c: or to an address above 0x%lx.\n", virt_to_phys(high_memory));
printk(KERN_CRIT "ac3200.c: Driver NOT installed.\n"); printk(KERN_CRIT "ac3200.c: Driver NOT installed.\n");
retval = -EINVAL; retval = -EINVAL;
goto out2; goto out1;
} }
dev->mem_start = (unsigned long)ioremap(dev->mem_start, AC_STOP_PG*0x100); dev->mem_start = (unsigned long)ioremap(dev->mem_start, AC_STOP_PG*0x100);
if (dev->mem_start == 0) { if (dev->mem_start == 0) {
...@@ -259,7 +249,7 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev) ...@@ -259,7 +249,7 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev)
printk(KERN_ERR "ac3200.c: Try using EISA SCU to set memory below 1MB.\n"); printk(KERN_ERR "ac3200.c: Try using EISA SCU to set memory below 1MB.\n");
printk(KERN_ERR "ac3200.c: Driver NOT installed.\n"); printk(KERN_ERR "ac3200.c: Driver NOT installed.\n");
retval = -EINVAL; retval = -EINVAL;
goto out2; goto out1;
} }
ei_status.reg0 = 1; /* Use as remap flag */ ei_status.reg0 = 1; /* Use as remap flag */
printk("ac3200.c: remapped %dkB card memory to virtual address %#lx\n", printk("ac3200.c: remapped %dkB card memory to virtual address %#lx\n",
...@@ -288,11 +278,8 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev) ...@@ -288,11 +278,8 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev)
dev->stop = &ac_close_card; dev->stop = &ac_close_card;
NS8390_init(dev, 0); NS8390_init(dev, 0);
return 0; return 0;
out2:
free_irq(dev->irq, dev);
out1: out1:
kfree(dev->priv); free_irq(dev->irq, dev);
dev->priv = NULL;
out: out:
release_region(ioaddr, AC_IO_EXTENT); release_region(ioaddr, AC_IO_EXTENT);
return retval; return retval;
...@@ -401,10 +388,9 @@ init_module(void) ...@@ -401,10 +388,9 @@ init_module(void)
for (this_dev = 0; this_dev < MAX_AC32_CARDS; this_dev++) { for (this_dev = 0; this_dev < MAX_AC32_CARDS; this_dev++) {
if (io[this_dev] == 0 && this_dev != 0) if (io[this_dev] == 0 && this_dev != 0)
break; break;
dev = alloc_etherdev(0); dev = alloc_ei_netdev();
if (!dev) if (!dev)
break; break;
dev->priv = NULL;
dev->irq = irq[this_dev]; dev->irq = irq[this_dev];
dev->base_addr = io[this_dev]; dev->base_addr = io[this_dev];
dev->mem_start = mem[this_dev]; /* Currently ignored by driver */ dev->mem_start = mem[this_dev]; /* Currently ignored by driver */
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
#define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */ #define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */
int apne_probe(struct net_device *dev); struct net_device * __init apne_probe(int unit);
static int apne_probe1(struct net_device *dev, int ioaddr); static int apne_probe1(struct net_device *dev, int ioaddr);
static int apne_open(struct net_device *dev); static int apne_open(struct net_device *dev);
...@@ -138,10 +138,9 @@ struct net_device * __init apne_probe(int unit) ...@@ -138,10 +138,9 @@ struct net_device * __init apne_probe(int unit)
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
dev = alloc_etherdev(0); dev = alloc_ei_netdev();
if (!dev) if (!dev)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
dev->priv = NULL;
if (unit >= 0) { if (unit >= 0) {
sprintf(dev->name, "eth%d", unit); sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev); netdev_boot_setup_check(dev);
...@@ -314,13 +313,6 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr) ...@@ -314,13 +313,6 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr)
i = request_irq(IRQ_AMIGA_PORTS, apne_interrupt, SA_SHIRQ, dev->name, dev); i = request_irq(IRQ_AMIGA_PORTS, apne_interrupt, SA_SHIRQ, dev->name, dev);
if (i) return i; if (i) return i;
/* Allocate dev->priv and fill in 8390 specific dev fields. */
if (ethdev_init(dev)) {
printk (" unable to get memory for dev->priv.\n");
free_irq(IRQ_AMIGA_PORTS, dev);
return -ENOMEM;
}
for(i = 0; i < ETHER_ADDR_LEN; i++) { for(i = 0; i < ETHER_ADDR_LEN; i++) {
printk(" %2.2x", SA_prom[i]); printk(" %2.2x", SA_prom[i]);
dev->dev_addr[i] = SA_prom[i]; dev->dev_addr[i] = SA_prom[i];
...@@ -572,8 +564,6 @@ static struct net_device *apne_dev; ...@@ -572,8 +564,6 @@ static struct net_device *apne_dev;
int init_module(void) int init_module(void)
{ {
int err;
apne_dev = apne_probe(-1); apne_dev = apne_probe(-1);
if (IS_ERR(apne_dev)) if (IS_ERR(apne_dev))
return PTR_ERR(apne_dev); return PTR_ERR(apne_dev);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/atalk.h> #include <linux/atalk.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
...@@ -55,34 +56,24 @@ static struct ipddp_route* ipddp_find_route(struct ipddp_route *rt); ...@@ -55,34 +56,24 @@ static struct ipddp_route* ipddp_find_route(struct ipddp_route *rt);
static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
static int __init ipddp_init(struct net_device *dev) static struct net_device * __init ipddp_init(void)
{ {
static unsigned version_printed; static unsigned version_printed;
struct net_device *dev;
int err;
dev = alloc_etherdev(sizeof(struct net_device_stats));
if (!dev)
return ERR_PTR(-ENOMEM);
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
strcpy(dev->name, "ipddp%d");
if (version_printed++ == 0) if (version_printed++ == 0)
printk(version); printk(version);
/* Let the user now what mode we are in */
if(ipddp_mode == IPDDP_ENCAP)
printk("%s: Appletalk-IP Encap. mode by Bradford W. Johnson <johns393@maroon.tc.umn.edu>\n",
dev->name);
if(ipddp_mode == IPDDP_DECAP)
printk("%s: Appletalk-IP Decap. mode by Jay Schulist <jschlst@samba.org>\n",
dev->name);
/* Fill in the device structure with ethernet-generic values. */
ether_setup(dev);
/* Initalize the device structure. */ /* Initalize the device structure. */
dev->hard_start_xmit = ipddp_xmit; dev->hard_start_xmit = ipddp_xmit;
dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
if(!dev->priv)
return -ENOMEM;
memset(dev->priv,0,sizeof(struct net_device_stats));
dev->get_stats = ipddp_get_stats; dev->get_stats = ipddp_get_stats;
dev->do_ioctl = ipddp_ioctl; dev->do_ioctl = ipddp_ioctl;
...@@ -97,7 +88,21 @@ static int __init ipddp_init(struct net_device *dev) ...@@ -97,7 +88,21 @@ static int __init ipddp_init(struct net_device *dev)
*/ */
dev->hard_header_len = 14+8+sizeof(struct ddpehdr)+1; dev->hard_header_len = 14+8+sizeof(struct ddpehdr)+1;
return 0; err = register_netdev(dev);
if (err) {
free_netdev(dev);
return ERR_PTR(err);
}
/* Let the user now what mode we are in */
if(ipddp_mode == IPDDP_ENCAP)
printk("%s: Appletalk-IP Encap. mode by Bradford W. Johnson <johns393@maroon.tc.umn.edu>\n",
dev->name);
if(ipddp_mode == IPDDP_DECAP)
printk("%s: Appletalk-IP Decap. mode by Jay Schulist <jschlst@samba.org>\n",
dev->name);
return dev;
} }
/* /*
...@@ -281,23 +286,16 @@ static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -281,23 +286,16 @@ static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
} }
} }
static struct net_device dev_ipddp; static struct net_device *dev_ipddp;
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_PARM(ipddp_mode, "i"); MODULE_PARM(ipddp_mode, "i");
static int __init ipddp_init_module(void) static int __init ipddp_init_module(void)
{ {
int err; dev_ipddp = ipddp_init();
if (IS_ERR(dev_ipddp))
dev_ipddp.init = ipddp_init; return PTR_ERR(dev_ipddp);
err=dev_alloc_name(&dev_ipddp, "ipddp%d");
if(err < 0)
return err;
if(register_netdev(&dev_ipddp) != 0)
return -EIO;
return 0; return 0;
} }
...@@ -305,8 +303,8 @@ static void __exit ipddp_cleanup_module(void) ...@@ -305,8 +303,8 @@ static void __exit ipddp_cleanup_module(void)
{ {
struct ipddp_route *p; struct ipddp_route *p;
unregister_netdev(&dev_ipddp); unregister_netdev(dev_ipddp);
kfree(dev_ipddp.priv); free_netdev(dev_ipddp);
while (ipddp_route_list) { while (ipddp_route_list) {
p = ipddp_route_list->next; p = ipddp_route_list->next;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -85,8 +86,6 @@ static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offse ...@@ -85,8 +86,6 @@ static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offse
*/ */
static int __init arcrimi_probe(struct net_device *dev) static int __init arcrimi_probe(struct net_device *dev)
{ {
int retval;
BUGLVL(D_NORMAL) printk(VERSION); BUGLVL(D_NORMAL) printk(VERSION);
BUGLVL(D_NORMAL) printk("E-mail me if you actually test the RIM I driver, please!\n"); BUGLVL(D_NORMAL) printk("E-mail me if you actually test the RIM I driver, please!\n");
...@@ -114,11 +113,7 @@ static int __init arcrimi_probe(struct net_device *dev) ...@@ -114,11 +113,7 @@ static int __init arcrimi_probe(struct net_device *dev)
"ID!\n"); "ID!\n");
return -ENODEV; return -ENODEV;
} }
retval = arcrimi_found(dev); return arcrimi_found(dev);
if (retval < 0) {
release_mem_region(dev->mem_start, BUFFER_SIZE);
}
return retval;
} }
...@@ -129,11 +124,13 @@ static int __init arcrimi_probe(struct net_device *dev) ...@@ -129,11 +124,13 @@ static int __init arcrimi_probe(struct net_device *dev)
static int __init arcrimi_found(struct net_device *dev) static int __init arcrimi_found(struct net_device *dev)
{ {
struct arcnet_local *lp; struct arcnet_local *lp;
u_long first_mirror, last_mirror, shmem; unsigned long first_mirror, last_mirror, shmem;
int mirror_size; int mirror_size;
int err;
/* reserve the irq */ /* reserve the irq */
if (request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet (RIM I)", dev)) { if (request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet (RIM I)", dev)) {
release_mem_region(dev->mem_start, BUFFER_SIZE);
BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq); BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq);
return -ENODEV; return -ENODEV;
} }
...@@ -168,11 +165,7 @@ static int __init arcrimi_found(struct net_device *dev) ...@@ -168,11 +165,7 @@ static int __init arcrimi_found(struct net_device *dev)
/* initialize the rest of the device structure. */ /* initialize the rest of the device structure. */
lp = dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL); lp = dev->priv;
if (!lp) {
BUGMSG(D_NORMAL, "Can't allocate device data!\n");
goto err_free_irq;
}
lp->card_name = "RIM I"; lp->card_name = "RIM I";
lp->hw.command = arcrimi_command; lp->hw.command = arcrimi_command;
lp->hw.status = arcrimi_status; lp->hw.status = arcrimi_status;
...@@ -181,18 +174,6 @@ static int __init arcrimi_found(struct net_device *dev) ...@@ -181,18 +174,6 @@ static int __init arcrimi_found(struct net_device *dev)
lp->hw.owner = THIS_MODULE; lp->hw.owner = THIS_MODULE;
lp->hw.copy_to_card = arcrimi_copy_to_card; lp->hw.copy_to_card = arcrimi_copy_to_card;
lp->hw.copy_from_card = arcrimi_copy_from_card; lp->hw.copy_from_card = arcrimi_copy_from_card;
lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1);
if (!lp->mem_start) {
BUGMSG(D_NORMAL, "Can't remap device memory!\n");
goto err_free_dev_priv;
}
/* Fill in the fields of the device structure with generic
* values.
*/
arcdev_setup(dev);
/* get and check the station ID from offset 1 in shmem */
dev->dev_addr[0] = readb(lp->mem_start + 1);
/* /*
* re-reserve the memory region - arcrimi_probe() alloced this reqion * re-reserve the memory region - arcrimi_probe() alloced this reqion
...@@ -200,25 +181,40 @@ static int __init arcrimi_found(struct net_device *dev) ...@@ -200,25 +181,40 @@ static int __init arcrimi_found(struct net_device *dev)
* with the correct size. There is a VERY slim chance this could * with the correct size. There is a VERY slim chance this could
* fail. * fail.
*/ */
release_mem_region(dev->mem_start, BUFFER_SIZE); release_mem_region(shmem, BUFFER_SIZE);
if (!request_mem_region(dev->mem_start, if (!request_mem_region(dev->mem_start,
dev->mem_end - dev->mem_start + 1, dev->mem_end - dev->mem_start + 1,
"arcnet (90xx)")) { "arcnet (90xx)")) {
BUGMSG(D_NORMAL, "Card memory already allocated\n"); BUGMSG(D_NORMAL, "Card memory already allocated\n");
goto err_free_dev_priv; goto err_free_irq;
} }
lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1);
if (!lp->mem_start) {
BUGMSG(D_NORMAL, "Can't remap device memory!\n");
goto err_release_mem;
}
/* get and check the station ID from offset 1 in shmem */
dev->dev_addr[0] = readb(lp->mem_start + 1);
BUGMSG(D_NORMAL, "ARCnet RIM I: station %02Xh found at IRQ %d, " BUGMSG(D_NORMAL, "ARCnet RIM I: station %02Xh found at IRQ %d, "
"ShMem %lXh (%ld*%d bytes).\n", "ShMem %lXh (%ld*%d bytes).\n",
dev->dev_addr[0], dev->dev_addr[0],
dev->irq, dev->mem_start, dev->irq, dev->mem_start,
(dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size); (dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size);
err = register_netdev(dev);
if (err)
goto err_unmap;
return 0; return 0;
err_free_dev_priv: err_unmap:
kfree(dev->priv); iounmap(lp->mem_start);
err_free_irq: err_release_mem:
release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
err_free_irq:
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
return -EIO; return -EIO;
} }
...@@ -294,94 +290,79 @@ static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offse ...@@ -294,94 +290,79 @@ static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offse
TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count)); TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
} }
#ifdef MODULE static int node;
static int io; /* use the insmod io= irq= node= options */
static struct net_device *my_dev; static int irq;
static char device[9]; /* use eg. device=arc1 to change name */
/* Module parameters */ module_param(node, int, 0);
module_param(io, int, 0);
static int node = 0; module_param(irq, int, 0);
static int io = 0x0; /* <--- EDIT THESE LINES FOR YOUR CONFIGURATION */ module_param_string(device, device, sizeof(device), 0);
static int irq = 0; /* or use the insmod io= irq= shmem= options */
static char *device; /* use eg. device="arc1" to change name */
MODULE_PARM(node, "i");
MODULE_PARM(io, "i");
MODULE_PARM(irq, "i");
MODULE_PARM(device, "s");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
int init_module(void) static struct net_device *my_dev;
static int __init arc_rimi_init(void)
{ {
struct net_device *dev; struct net_device *dev;
int err;
dev = dev_alloc(device ? : "arc%d", &err); dev = alloc_arcdev(device);
if (!dev) if (!dev)
return err; return -ENOMEM;
if (node && node != 0xff) if (node && node != 0xff)
dev->dev_addr[0] = node; dev->dev_addr[0] = node;
dev->base_addr = io; dev->mem_start = io;
dev->irq = irq; dev->irq = irq;
if (dev->irq == 2) if (dev->irq == 2)
dev->irq = 9; dev->irq = 9;
if (arcrimi_probe(dev)) if (arcrimi_probe(dev)) {
free_netdev(dev);
return -EIO; return -EIO;
}
my_dev = dev; my_dev = dev;
return 0; return 0;
} }
void cleanup_module(void) static void __exit arc_rimi_exit(void)
{ {
struct net_device *dev = my_dev; struct net_device *dev = my_dev;
struct arcnet_local *lp = (struct arcnet_local *) dev->priv; struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
unregister_netdev(dev); unregister_netdev(dev);
free_irq(dev->irq, dev);
iounmap(lp->mem_start); iounmap(lp->mem_start);
release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1); release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
kfree(dev->priv); free_irq(dev->irq, dev);
free_netdev(dev); free_netdev(dev);
} }
#else #ifndef MODULE
static int __init arcrimi_setup(char *s) static int __init arcrimi_setup(char *s)
{ {
struct net_device *dev;
int ints[8]; int ints[8];
s = get_options(s, 8, ints); s = get_options(s, 8, ints);
if (!ints[0]) if (!ints[0])
return 1; return 1;
dev = alloc_bootmem(sizeof(struct net_device));
memset(dev, 0, sizeof(struct net_device));
dev->init = arcrimi_probe;
switch (ints[0]) { switch (ints[0]) {
default: /* ERROR */ default: /* ERROR */
printk("arcrimi: Too many arguments.\n"); printk("arcrimi: Too many arguments.\n");
case 3: /* Node ID */ case 3: /* Node ID */
dev->dev_addr[0] = ints[3]; node = ints[3];
case 2: /* IRQ */ case 2: /* IRQ */
dev->irq = ints[2]; irq = ints[2];
case 1: /* IO address */ case 1: /* IO address */
dev->mem_start = ints[1]; io = ints[1];
} }
if (*s) if (*s)
strncpy(dev->name, s, 9); snprintf(device, sizeof(device), "%s", s);
else
strcpy(dev->name, "arc%d");
if (register_netdev(dev))
printk(KERN_ERR "arc-rimi: Cannot register arcnet device\n");
return 1; return 1;
} }
__setup("arcrimi=", arcrimi_setup); __setup("arcrimi=", arcrimi_setup);
#endif /* MODULE */ #endif /* MODULE */
module_init(arc_rimi_init)
module_exit(arc_rimi_exit)
...@@ -92,6 +92,7 @@ EXPORT_SYMBOL(arc_proto_null); ...@@ -92,6 +92,7 @@ EXPORT_SYMBOL(arc_proto_null);
EXPORT_SYMBOL(arcnet_unregister_proto); EXPORT_SYMBOL(arcnet_unregister_proto);
EXPORT_SYMBOL(arcnet_debug); EXPORT_SYMBOL(arcnet_debug);
EXPORT_SYMBOL(arcdev_setup); EXPORT_SYMBOL(arcdev_setup);
EXPORT_SYMBOL(alloc_arcdev);
EXPORT_SYMBOL(arcnet_interrupt); EXPORT_SYMBOL(arcnet_interrupt);
/* Internal function prototypes */ /* Internal function prototypes */
...@@ -331,6 +332,11 @@ void arcdev_setup(struct net_device *dev) ...@@ -331,6 +332,11 @@ void arcdev_setup(struct net_device *dev)
dev->rebuild_header = arcnet_rebuild_header; dev->rebuild_header = arcnet_rebuild_header;
} }
struct net_device *alloc_arcdev(char *name)
{
return alloc_netdev(sizeof(struct arcnet_local),
name && *name ? name : "arc%d", arcdev_setup);
}
/* /*
* Open/initialize the board. This is called sometime after booting when * Open/initialize the board. This is called sometime after booting when
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* ********************** * **********************
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/ioport.h> #include <linux/ioport.h>
...@@ -117,49 +118,41 @@ static int __init com20020isa_probe(struct net_device *dev) ...@@ -117,49 +118,41 @@ static int __init com20020isa_probe(struct net_device *dev)
return err; return err;
} }
#ifdef MODULE
static struct net_device *my_dev;
/* Module parameters */
static int node = 0; static int node = 0;
static int io = 0x0; /* <--- EDIT THESE LINES FOR YOUR CONFIGURATION */ static int io = 0x0; /* <--- EDIT THESE LINES FOR YOUR CONFIGURATION */
static int irq = 0; /* or use the insmod io= irq= shmem= options */ static int irq = 0; /* or use the insmod io= irq= shmem= options */
static char *device; /* use eg. device="arc1" to change name */ static char device[9]; /* use eg. device="arc1" to change name */
static int timeout = 3; static int timeout = 3;
static int backplane = 0; static int backplane = 0;
static int clockp = 0; static int clockp = 0;
static int clockm = 0; static int clockm = 0;
MODULE_PARM(node, "i"); module_param(node, int, 0);
MODULE_PARM(io, "i"); module_param(io, int, 0);
MODULE_PARM(irq, "i"); module_param(irq, int, 0);
MODULE_PARM(device, "s"); module_param_string(device, device, sizeof(device), 0);
MODULE_PARM(timeout, "i"); module_param(timeout, int, 0);
MODULE_PARM(backplane, "i"); module_param(backplane, int, 0);
MODULE_PARM(clockp, "i"); module_param(clockp, int, 0);
MODULE_PARM(clockm, "i"); module_param(clockm, int, 0);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
int init_module(void) static struct net_device *my_dev;
static int __init com20020_init(void)
{ {
struct net_device *dev; struct net_device *dev;
struct arcnet_local *lp; struct arcnet_local *lp;
int err;
dev = dev_alloc(device ? : "arc%d", &err); dev = alloc_arcdev(device);
if (!dev) if (!dev)
return err;
lp = dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
if (!lp)
return -ENOMEM; return -ENOMEM;
memset(lp, 0, sizeof(struct arcnet_local));
if (node && node != 0xff) if (node && node != 0xff)
dev->dev_addr[0] = node; dev->dev_addr[0] = node;
lp = dev->priv;
lp->backplane = backplane; lp->backplane = backplane;
lp->clockp = clockp & 7; lp->clockp = clockp & 7;
lp->clockm = clockm & 3; lp->clockm = clockm & 3;
...@@ -172,21 +165,24 @@ int init_module(void) ...@@ -172,21 +165,24 @@ int init_module(void)
if (dev->irq == 2) if (dev->irq == 2)
dev->irq = 9; dev->irq = 9;
if (com20020isa_probe(dev)) if (com20020isa_probe(dev)) {
free_netdev(dev);
return -EIO; return -EIO;
}
my_dev = dev; my_dev = dev;
return 0; return 0;
} }
void cleanup_module(void) static void __exit com20020_exit(void)
{ {
com20020_remove(my_dev); unregister_netdev(my_dev);
free_irq(my_dev->irq, my_dev);
release_region(my_dev->base_addr, ARCNET_TOTAL_SIZE); release_region(my_dev->base_addr, ARCNET_TOTAL_SIZE);
free_netdev(my_dev);
} }
#else #ifndef MODULE
static int __init com20020isa_setup(char *s) static int __init com20020isa_setup(char *s)
{ {
struct net_device *dev; struct net_device *dev;
...@@ -196,37 +192,31 @@ static int __init com20020isa_setup(char *s) ...@@ -196,37 +192,31 @@ static int __init com20020isa_setup(char *s)
s = get_options(s, 8, ints); s = get_options(s, 8, ints);
if (!ints[0]) if (!ints[0])
return 1; return 1;
dev = alloc_bootmem(sizeof(struct net_device) + sizeof(struct arcnet_local));
memset(dev, 0, sizeof(struct net_device) + sizeof(struct arcnet_local));
lp = dev->priv = (struct arcnet_local *) (dev + 1);
dev->init = com20020isa_probe;
switch (ints[0]) { switch (ints[0]) {
default: /* ERROR */ default: /* ERROR */
printk("com90xx: Too many arguments.\n"); printk("com90xx: Too many arguments.\n");
case 6: /* Timeout */ case 6: /* Timeout */
lp->timeout = ints[6]; timeout = ints[6];
case 5: /* CKP value */ case 5: /* CKP value */
lp->clockp = ints[5]; clockp = ints[5];
case 4: /* Backplane flag */ case 4: /* Backplane flag */
lp->backplane = ints[4]; backplane = ints[4];
case 3: /* Node ID */ case 3: /* Node ID */
dev->dev_addr[0] = ints[3]; node = ints[3];
case 2: /* IRQ */ case 2: /* IRQ */
dev->irq = ints[2]; irq = ints[2];
case 1: /* IO address */ case 1: /* IO address */
dev->base_addr = ints[1]; io = ints[1];
} }
if (*s) if (*s)
strncpy(dev->name, s, 9); snprintf(device, sizeof(device), "%s", s);
else
strcpy(dev->name, "arc%d");
if (register_netdev(dev))
printk(KERN_ERR "com20020: Cannot register arcnet device\n");
return 1; return 1;
} }
__setup("com20020=", com20020isa_setup); __setup("com20020=", com20020isa_setup);
#endif /* MODULE */ #endif /* MODULE */
module_init(com20020_init)
module_exit(com20020_exit)
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* ********************** * **********************
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/ioport.h> #include <linux/ioport.h>
...@@ -46,18 +47,18 @@ ...@@ -46,18 +47,18 @@
/* Module parameters */ /* Module parameters */
static int node; static int node;
static char *device; /* use eg. device="arc1" to change name */ static char device[9]; /* use eg. device="arc1" to change name */
static int timeout = 3; static int timeout = 3;
static int backplane; static int backplane;
static int clockp; static int clockp;
static int clockm; static int clockm;
MODULE_PARM(node, "i"); module_param(node, int, 0);
MODULE_PARM(device, "s"); module_param_string(device, device, sizeof(device), 0);
MODULE_PARM(timeout, "i"); module_param(timeout, int, 0);
MODULE_PARM(backplane, "i"); module_param(backplane, int, 0);
MODULE_PARM(clockp, "i"); module_param(clockp, int, 0);
MODULE_PARM(clockm, "i"); module_param(clockm, int, 0);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
...@@ -68,15 +69,11 @@ static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_de ...@@ -68,15 +69,11 @@ static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_de
if (pci_enable_device(pdev)) if (pci_enable_device(pdev))
return -EIO; return -EIO;
dev = dev_alloc(device ? : "arc%d", &err); dev = alloc_arcdev(device);
if (!dev) if (!dev)
return err; return -ENOMEM;
lp = dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL); lp = dev->priv;
if (!lp) {
err = -ENOMEM;
goto out_dev;
}
memset(lp, 0, sizeof(struct arcnet_local));
pci_set_drvdata(pdev, dev); pci_set_drvdata(pdev, dev);
// SOHARD needs PCI base addr 4 // SOHARD needs PCI base addr 4
...@@ -89,6 +86,13 @@ static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_de ...@@ -89,6 +86,13 @@ static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_de
ioaddr = pci_resource_start(pdev, 2); ioaddr = pci_resource_start(pdev, 2);
} }
if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com20020-pci")) {
BUGMSG(D_INIT, "IO region %xh-%xh already allocated.\n",
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
err = -EBUSY;
goto out_dev;
}
// Dummy access after Reset // Dummy access after Reset
// ARCNET controller needs this access to detect bustype // ARCNET controller needs this access to detect bustype
outb(0x00,ioaddr+1); outb(0x00,ioaddr+1);
...@@ -105,12 +109,6 @@ static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_de ...@@ -105,12 +109,6 @@ static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_de
lp->timeout = timeout; lp->timeout = timeout;
lp->hw.owner = THIS_MODULE; lp->hw.owner = THIS_MODULE;
if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com20020-pci")) {
BUGMSG(D_INIT, "IO region %xh-%xh already allocated.\n",
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
err = -EBUSY;
goto out_priv;
}
if (ASTATUS() == 0xFF) { if (ASTATUS() == 0xFF) {
BUGMSG(D_NORMAL, "IO address %Xh was reported by PCI BIOS, " BUGMSG(D_NORMAL, "IO address %Xh was reported by PCI BIOS, "
"but seems empty!\n", ioaddr); "but seems empty!\n", ioaddr);
...@@ -129,18 +127,18 @@ static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_de ...@@ -129,18 +127,18 @@ static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_de
out_port: out_port:
release_region(ioaddr, ARCNET_TOTAL_SIZE); release_region(ioaddr, ARCNET_TOTAL_SIZE);
out_priv:
kfree(dev->priv);
out_dev: out_dev:
kfree(dev); free_netdev(dev);
return err; return err;
} }
static void __devexit com20020pci_remove(struct pci_dev *pdev) static void __devexit com20020pci_remove(struct pci_dev *pdev)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
com20020_remove(dev); unregister_netdev(dev);
free_irq(dev->irq, dev);
release_region(dev->base_addr, ARCNET_TOTAL_SIZE); release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
free_netdev(dev);
} }
static struct pci_device_id com20020pci_id_table[] = { static struct pci_device_id com20020pci_id_table[] = {
......
...@@ -172,11 +172,6 @@ int com20020_found(struct net_device *dev, int shared) ...@@ -172,11 +172,6 @@ int com20020_found(struct net_device *dev, int shared)
dev->set_multicast_list = com20020_set_mc_list; dev->set_multicast_list = com20020_set_mc_list;
/* Fill in the fields of the device structure with generic
* values.
*/
arcdev_setup(dev);
if (!dev->dev_addr[0]) if (!dev->dev_addr[0])
dev->dev_addr[0] = inb(ioaddr + 8); /* FIXME: do this some other way! */ dev->dev_addr[0] = inb(ioaddr + 8); /* FIXME: do this some other way! */
...@@ -221,7 +216,7 @@ int com20020_found(struct net_device *dev, int shared) ...@@ -221,7 +216,7 @@ int com20020_found(struct net_device *dev, int shared)
lp->setup >> 1, lp->setup >> 1,
clockrates[3 - ((lp->setup2 & 0xF0) >> 4) + ((lp->setup & 0x0F) >> 1)]); clockrates[3 - ((lp->setup2 & 0xF0) >> 4) + ((lp->setup & 0x0F) >> 1)]);
if (!dev->init && register_netdev(dev)) { if (register_netdev(dev)) {
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
return -EIO; return -EIO;
} }
...@@ -332,19 +327,10 @@ static void com20020_set_mc_list(struct net_device *dev) ...@@ -332,19 +327,10 @@ static void com20020_set_mc_list(struct net_device *dev)
} }
} }
void com20020_remove(struct net_device *dev)
{
unregister_netdev(dev);
free_irq(dev->irq, dev);
kfree(dev->priv);
free_netdev(dev);
}
#ifdef MODULE #ifdef MODULE
EXPORT_SYMBOL(com20020_check); EXPORT_SYMBOL(com20020_check);
EXPORT_SYMBOL(com20020_found); EXPORT_SYMBOL(com20020_found);
EXPORT_SYMBOL(com20020_remove);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -234,6 +235,7 @@ static int __init com90io_found(struct net_device *dev) ...@@ -234,6 +235,7 @@ static int __init com90io_found(struct net_device *dev)
{ {
struct arcnet_local *lp; struct arcnet_local *lp;
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
int err;
/* Reserve the irq */ /* Reserve the irq */
if (request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet (COM90xx-IO)", dev)) { if (request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet (COM90xx-IO)", dev)) {
...@@ -246,15 +248,6 @@ static int __init com90io_found(struct net_device *dev) ...@@ -246,15 +248,6 @@ static int __init com90io_found(struct net_device *dev)
return -EBUSY; return -EBUSY;
} }
/* Initialize the rest of the device structure. */
dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
if (!dev->priv) {
free_irq(dev->irq, dev);
release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
return -ENOMEM;
}
memset(dev->priv, 0, sizeof(struct arcnet_local));
lp = (struct arcnet_local *) (dev->priv); lp = (struct arcnet_local *) (dev->priv);
lp->card_name = "COM90xx I/O"; lp->card_name = "COM90xx I/O";
lp->hw.command = com90io_command; lp->hw.command = com90io_command;
...@@ -265,12 +258,6 @@ static int __init com90io_found(struct net_device *dev) ...@@ -265,12 +258,6 @@ static int __init com90io_found(struct net_device *dev)
lp->hw.copy_to_card = com90io_copy_to_card; lp->hw.copy_to_card = com90io_copy_to_card;
lp->hw.copy_from_card = com90io_copy_from_card; lp->hw.copy_from_card = com90io_copy_from_card;
/*
* Fill in the fields of the device structure with generic
* values.
*/
arcdev_setup(dev);
lp->config = (0x16 | IOMAPflag) & ~ENABLE16flag; lp->config = (0x16 | IOMAPflag) & ~ENABLE16flag;
SETCONF(); SETCONF();
...@@ -278,6 +265,14 @@ static int __init com90io_found(struct net_device *dev) ...@@ -278,6 +265,14 @@ static int __init com90io_found(struct net_device *dev)
dev->dev_addr[0] = get_buffer_byte(dev, 1); dev->dev_addr[0] = get_buffer_byte(dev, 1);
err = register_netdev(dev);
if (err) {
outb((inb(_CONFIG) & ~IOMAPflag), _CONFIG);
free_irq(dev->irq, dev);
release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
return err;
}
BUGMSG(D_NORMAL, "COM90IO: station %02Xh found at %03lXh, IRQ %d.\n", BUGMSG(D_NORMAL, "COM90IO: station %02Xh found at %03lXh, IRQ %d.\n",
dev->dev_addr[0], dev->base_addr, dev->irq); dev->dev_addr[0], dev->base_addr, dev->irq);
...@@ -361,44 +356,67 @@ static void com90io_copy_from_card(struct net_device *dev, int bufnum, int offse ...@@ -361,44 +356,67 @@ static void com90io_copy_from_card(struct net_device *dev, int bufnum, int offse
TIME("get_whole_buffer", count, get_whole_buffer(dev, bufnum * 512 + offset, count, buf)); TIME("get_whole_buffer", count, get_whole_buffer(dev, bufnum * 512 + offset, count, buf));
} }
#ifdef MODULE
static struct net_device *my_dev;
/* Module parameters */
static int io; /* use the insmod io= irq= shmem= options */ static int io; /* use the insmod io= irq= shmem= options */
static int irq; static int irq;
static char *device; /* use eg. device=arc1 to change name */ static char device[9]; /* use eg. device=arc1 to change name */
MODULE_PARM(io, "i"); module_param(io, int, 0);
MODULE_PARM(irq, "i"); module_param(irq, int, 0);
MODULE_PARM(device, "s"); module_param_string(device, device, sizeof(device), 0);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
int init_module(void) #ifndef MODULE
static int __init com90io_setup(char *s)
{
int ints[4];
s = get_options(s, 4, ints);
if (!ints[0])
return 0;
switch (ints[0]) {
default: /* ERROR */
printk("com90io: Too many arguments.\n");
case 2: /* IRQ */
irq = ints[2];
case 1: /* IO address */
io = ints[1];
}
if (*s)
snprintf(device, sizeof(device), "%s", s);
return 1;
}
__setup("com90io=", com90io_setup);
#endif
static struct net_device *my_dev;
static int __init com90io_init(void)
{ {
struct net_device *dev; struct net_device *dev;
int err; int err;
dev = dev_alloc(device ? : "arc%d", &err); dev = alloc_arcdev(device);
if (!dev) if (!dev)
return err; return -ENOMEM;
SET_MODULE_OWNER(dev);
dev->base_addr = io; dev->base_addr = io;
dev->irq = irq; dev->irq = irq;
if (dev->irq == 2) if (dev->irq == 2)
dev->irq = 9; dev->irq = 9;
if (com90io_probe(dev)) err = com90io_probe(dev);
return -EIO;
if (err) {
free_netdev(dev);
return err;
}
my_dev = dev; my_dev = dev;
return 0; return 0;
} }
void cleanup_module(void) static void __exit com90io_exit(void)
{ {
struct net_device *dev = my_dev; struct net_device *dev = my_dev;
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
...@@ -410,42 +428,8 @@ void cleanup_module(void) ...@@ -410,42 +428,8 @@ void cleanup_module(void)
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
release_region(dev->base_addr, ARCNET_TOTAL_SIZE); release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
kfree(dev->priv);
free_netdev(dev); free_netdev(dev);
} }
#else module_init(com90io_init)
module_exit(com90io_exit)
static int __init com90io_setup(char *s)
{
struct net_device *dev;
int ints[4];
s = get_options(s, 4, ints);
if (!ints[0])
return 0;
dev = alloc_bootmem(sizeof(struct net_device));
memset(dev, 0, sizeof(struct net_device));
dev->init = com90io_probe;
switch (ints[0]) {
default: /* ERROR */
printk("com90io: Too many arguments.\n");
case 2: /* IRQ */
dev->irq = ints[2];
case 1: /* IO address */
dev->base_addr = ints[1];
}
if (*s)
strncpy(dev->name, s, 9);
else
strcpy(dev->name, "arc%d");
if (register_netdev(dev))
printk(KERN_ERR "com90io: Cannot register arcnet device\n");
return 1;
}
__setup("com90io=", com90io_setup);
#endif /* MODULE */
This diff is collapsed.
...@@ -551,15 +551,12 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -551,15 +551,12 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
etherh_banner(); etherh_banner();
dev = alloc_etherdev(sizeof(struct etherh_priv)); dev = alloc_ei_netdev();
if (!dev) { if (!dev) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
/*
* alloc_etherdev allocs and zeros dev->priv
*/
eh = dev->priv; eh = dev->priv;
spin_lock_init(&eh->eidev.page_lock); spin_lock_init(&eh->eidev.page_lock);
...@@ -622,21 +619,12 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -622,21 +619,12 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
goto free; goto free;
} }
if (ethdev_init(dev)) {
ret = -ENODEV;
goto release;
}
/* /*
* If we're in the NIC slot, make sure the IRQ is enabled * If we're in the NIC slot, make sure the IRQ is enabled
*/ */
if (dev->irq == 11) if (dev->irq == 11)
etherh_set_ctrl(eh, ETHERH_CP_IE); etherh_set_ctrl(eh, ETHERH_CP_IE);
/*
* Unfortunately, ethdev_init eventually calls
* ether_setup, which re-writes dev->flags.
*/
switch (ec->cid.product) { switch (ec->cid.product) {
case PROD_ANT_ETHERM: case PROD_ANT_ETHERM:
dev_type = "ANT EtherM"; dev_type = "ANT EtherM";
......
This diff is collapsed.
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
* 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com> * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
* - Renamed bond_3ad_link_status_changed() to * - Renamed bond_3ad_link_status_changed() to
* bond_3ad_handle_link_change() for compatibility with TLB. * bond_3ad_handle_link_change() for compatibility with TLB.
*
* 2003/09/24 - Shmulik Hen <shmulik.hen at intel dot com>
* - Code cleanup and style changes
*/ */
#ifndef __BOND_3AD_H__ #ifndef __BOND_3AD_H__
......
This diff is collapsed.
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
* 2003/08/06 - Amir Noam <amir.noam at intel dot com> * 2003/08/06 - Amir Noam <amir.noam at intel dot com>
* - Add support for setting bond's MAC address with special * - Add support for setting bond's MAC address with special
* handling required for ALB/TLB. * handling required for ALB/TLB.
*
* 2003/09/24 - Shmulik Hen <shmulik.hen at intel dot com>
* - Code cleanup and style changes
*/ */
#ifndef __BOND_ALB_H__ #ifndef __BOND_ALB_H__
...@@ -126,10 +129,10 @@ void bond_alb_deinitialize(struct bonding *bond); ...@@ -126,10 +129,10 @@ void bond_alb_deinitialize(struct bonding *bond);
int bond_alb_init_slave(struct bonding *bond, struct slave *slave); int bond_alb_init_slave(struct bonding *bond, struct slave *slave);
void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave); void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave);
void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link); void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link);
void bond_alb_assign_current_slave(struct bonding *bond, struct slave *new_slave); void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave);
int bond_alb_xmit(struct sk_buff *skb, struct net_device *dev); int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
void bond_alb_monitor(struct bonding *bond); void bond_alb_monitor(struct bonding *bond);
int bond_alb_set_mac_address(struct net_device *dev, void *addr); int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
#endif /* __BOND_ALB_H__ */ #endif /* __BOND_ALB_H__ */
This diff is collapsed.
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* This software may be used and distributed according to the terms * This software may be used and distributed according to the terms
* of the GNU Public License, incorporated herein by reference. * of the GNU Public License, incorporated herein by reference.
* *
* *
* 2003/03/18 - Amir Noam <amir.noam at intel dot com>, * 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
* Tsippy Mendelson <tsippy.mendelson at intel dot com> and * Tsippy Mendelson <tsippy.mendelson at intel dot com> and
...@@ -22,159 +22,205 @@ ...@@ -22,159 +22,205 @@
* *
* 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com> * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
* - Added support for Transmit load balancing mode. * - Added support for Transmit load balancing mode.
*
* 2003/09/24 - Shmulik Hen <shmulik.hen at intel dot com>
* - Code cleanup and style changes
*/ */
#ifndef _LINUX_BONDING_H #ifndef _LINUX_BONDING_H
#define _LINUX_BONDING_H #define _LINUX_BONDING_H
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/if_bonding.h>
#include "bond_3ad.h" #include "bond_3ad.h"
#include "bond_alb.h" #include "bond_alb.h"
#ifdef BONDING_DEBUG #define DRV_VERSION "2.5.0"
#define DRV_RELDATE "December 1, 2003"
// use this like so: BOND_PRINT_DBG(("foo = %d, bar = %d", foo, bar)); #define DRV_NAME "bonding"
#define BOND_PRINT_DBG(X) \ #define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
do { \
printk(KERN_DEBUG "%s (%d)", __FUNCTION__, __LINE__); \
printk X; \
printk("\n"); \
} while(0)
#ifdef BONDING_DEBUG
#define dprintk(fmt, args...) \
printk(KERN_DEBUG \
DRV_NAME ": %s() %d: " fmt, __FUNCTION__, __LINE__ , ## args )
#else #else
#define BOND_PRINT_DBG(X) #define dprintk(fmt, args...)
#endif /* BONDING_DEBUG */ #endif /* BONDING_DEBUG */
#define IS_UP(dev) ((((dev)->flags & (IFF_UP)) == (IFF_UP)) && \ #define IS_UP(dev) \
(netif_running(dev) && netif_carrier_ok(dev))) ((((dev)->flags & IFF_UP) == IFF_UP) && \
netif_running(dev) && \
netif_carrier_ok(dev))
/*
* Checks whether bond is ready for transmit.
*
* Caller must hold bond->lock
*/
#define BOND_IS_OK(bond) \
(((bond)->dev->flags & IFF_UP) && \
netif_running((bond)->dev) && \
((bond)->slave_cnt > 0))
/* Checks whether the dev is ready for transmit. We do not check netif_running /*
* since a device can be stopped by the driver for short periods of time for * Checks whether slave is ready for transmit.
* maintainance. dev_queue_xmit() handles this by queing the packet until the
* the dev is running again. Keeping packets ordering requires sticking the
* same dev as much as possible
*/ */
#define SLAVE_IS_OK(slave) \ #define SLAVE_IS_OK(slave) \
((((slave)->dev->flags & (IFF_UP)) == (IFF_UP)) && \ (((slave)->dev->flags & IFF_UP) && \
netif_carrier_ok((slave)->dev) && \ netif_running((slave)->dev) && \
((slave)->link == BOND_LINK_UP) && \ ((slave)->link == BOND_LINK_UP) && \
((slave)->state == BOND_STATE_ACTIVE)) ((slave)->state == BOND_STATE_ACTIVE))
typedef struct slave { #define USES_PRIMARY(mode) \
(((mode) == BOND_MODE_ACTIVEBACKUP) || \
((mode) == BOND_MODE_TLB) || \
((mode) == BOND_MODE_ALB))
/*
* Less bad way to call ioctl from within the kernel; this needs to be
* done some other way to get the call out of interrupt context.
* Needs "ioctl" variable to be supplied by calling context.
*/
#define IOCTL(dev, arg, cmd) ({ \
int res = 0; \
mm_segment_t fs = get_fs(); \
set_fs(get_ds()); \
res = ioctl(dev, arg, cmd); \
set_fs(fs); \
res; })
/**
* bond_for_each_slave_from - iterate the slaves list from a starting point
* @bond: the bond holding this list.
* @pos: current slave.
* @cnt: counter for max number of moves
* @start: starting point.
*
* Caller must hold bond->lock
*/
#define bond_for_each_slave_from(bond, pos, cnt, start) \
for (cnt = 0, pos = start; \
cnt < (bond)->slave_cnt; \
cnt++, pos = (pos)->next)
/**
* bond_for_each_slave_from_to - iterate the slaves list from start point to stop point
* @bond: the bond holding this list.
* @pos: current slave.
* @cnt: counter for number max of moves
* @start: start point.
* @stop: stop point.
*
* Caller must hold bond->lock
*/
#define bond_for_each_slave_from_to(bond, pos, cnt, start, stop) \
for (cnt = 0, pos = start; \
((cnt < (bond)->slave_cnt) && (pos != (stop)->next)); \
cnt++, pos = (pos)->next)
/**
* bond_for_each_slave - iterate the slaves list from head
* @bond: the bond holding this list.
* @pos: current slave.
* @cnt: counter for max number of moves
*
* Caller must hold bond->lock
*/
#define bond_for_each_slave(bond, pos, cnt) \
bond_for_each_slave_from(bond, pos, cnt, (bond)->first_slave)
struct slave {
struct net_device *dev; /* first - usefull for panic debug */
struct slave *next; struct slave *next;
struct slave *prev; struct slave *prev;
struct net_device *dev; s16 delay;
short delay; u32 jiffies;
unsigned long jiffies; s8 link; /* one of BOND_LINK_XXXX */
char link; /* one of BOND_LINK_XXXX */ s8 state; /* one of BOND_STATE_XXXX */
char state; /* one of BOND_STATE_XXXX */ u32 original_flags;
unsigned short original_flags; u32 link_failure_count;
u32 link_failure_count;
u16 speed; u16 speed;
u8 duplex; u8 duplex;
u8 perm_hwaddr[ETH_ALEN]; u8 perm_hwaddr[ETH_ALEN];
struct ad_slave_info ad_info; /* HUGE - better to dynamically alloc */ struct ad_slave_info ad_info; /* HUGE - better to dynamically alloc */
struct tlb_slave_info tlb_info; struct tlb_slave_info tlb_info;
} slave_t; };
/* /*
* Here are the locking policies for the two bonding locks: * Here are the locking policies for the two bonding locks:
* *
* 1) Get bond->lock when reading/writing slave list. * 1) Get bond->lock when reading/writing slave list.
* 2) Get bond->ptrlock when reading/writing bond->current_slave. * 2) Get bond->curr_slave_lock when reading/writing bond->curr_active_slave.
* (It is unnecessary when the write-lock is put with bond->lock.) * (It is unnecessary when the write-lock is put with bond->lock.)
* 3) When we lock with bond->ptrlock, we must lock with bond->lock * 3) When we lock with bond->curr_slave_lock, we must lock with bond->lock
* beforehand. * beforehand.
*/ */
typedef struct bonding { struct bonding {
slave_t *next; struct net_device *dev; /* first - usefull for panic debug */
slave_t *prev; struct slave *first_slave;
slave_t *current_slave; struct slave *curr_active_slave;
slave_t *primary_slave; struct slave *current_arp_slave;
slave_t *current_arp_slave; struct slave *primary_slave;
__s32 slave_cnt; s32 slave_cnt; /* never change this value outside the attach/detach wrappers */
rwlock_t lock; rwlock_t lock;
rwlock_t ptrlock; rwlock_t curr_slave_lock;
struct timer_list mii_timer; struct timer_list mii_timer;
struct timer_list arp_timer; struct timer_list arp_timer;
struct net_device_stats stats; s8 kill_timers;
struct net_device_stats stats;
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct proc_dir_entry *bond_proc_file; struct proc_dir_entry *proc_entry;
char procdir_name[IFNAMSIZ]; char proc_file_name[IFNAMSIZ];
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
struct list_head bond_list; struct list_head bond_list;
struct net_device *device; struct dev_mc_list *mc_list;
struct dev_mc_list *mc_list; u16 flags;
unsigned short flags; struct ad_bond_info ad_info;
struct ad_bond_info ad_info; struct alb_bond_info alb_info;
struct alb_bond_info alb_info; };
} bonding_t;
/* Forward declarations */
void bond_set_slave_active_flags(slave_t *slave);
void bond_set_slave_inactive_flags(slave_t *slave);
/**
* These functions can be used for iterating the slave list
* (which is circular)
* Caller must hold bond lock for read
*/
extern inline struct slave*
bond_get_first_slave(struct bonding *bond)
{
/* if there are no slaves return NULL */
if (bond->next == (slave_t *)bond) {
return NULL;
}
return bond->next;
}
/**
* Caller must hold bond lock for read
*/
extern inline struct slave*
bond_get_next_slave(struct bonding *bond, struct slave *slave)
{
/* If we have reached the last slave return NULL */
if (slave->next == bond->next) {
return NULL;
}
return slave->next;
}
/** /**
* Returns NULL if the net_device does not belong to any of the bond's slaves * Returns NULL if the net_device does not belong to any of the bond's slaves
* *
* Caller must hold bond lock for read * Caller must hold bond lock for read
*/ */
extern inline struct slave* extern inline struct slave *bond_get_slave_by_dev(struct bonding *bond, struct net_device *slave_dev)
bond_get_slave_by_dev(struct bonding *bond, struct net_device *slave_dev)
{ {
struct slave *our_slave = bond->next; struct slave *slave = NULL;
int i;
/* check if the list of slaves is empty */ bond_for_each_slave(bond, slave, i) {
if (our_slave == (slave_t *)bond) { if (slave->dev == slave_dev) {
return NULL;
}
for (; our_slave; our_slave = bond_get_next_slave(bond, our_slave)) {
if (our_slave->dev == slave_dev) {
break; break;
} }
} }
return our_slave;
return slave;
} }
extern inline struct bonding* extern inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
bond_get_bond_by_slave(struct slave *slave)
{ {
if (!slave || !slave->dev->master) { if (!slave || !slave->dev->master) {
return NULL; return NULL;
} }
return (struct bonding *)(slave->dev->master->priv); return (struct bonding *)slave->dev->master->priv;
}
extern inline void bond_set_slave_inactive_flags(struct slave *slave)
{
slave->state = BOND_STATE_BACKUP;
slave->dev->flags |= IFF_NOARP;
}
extern inline void bond_set_slave_active_flags(struct slave *slave)
{
slave->state = BOND_STATE_ACTIVE;
slave->dev->flags &= ~IFF_NOARP;
} }
#endif /* _LINUX_BONDING_H */ #endif /* _LINUX_BONDING_H */
......
...@@ -140,15 +140,13 @@ static int __init do_e2100_probe(struct net_device *dev) ...@@ -140,15 +140,13 @@ static int __init do_e2100_probe(struct net_device *dev)
static void cleanup_card(struct net_device *dev) static void cleanup_card(struct net_device *dev)
{ {
void *priv = dev->priv;
/* NB: e21_close() handles free_irq */ /* NB: e21_close() handles free_irq */
release_region(dev->base_addr, E21_IO_EXTENT); release_region(dev->base_addr, E21_IO_EXTENT);
kfree(priv);
} }
struct net_device * __init e2100_probe(int unit) struct net_device * __init e2100_probe(int unit)
{ {
struct net_device *dev = alloc_etherdev(0); struct net_device *dev = alloc_ei_netdev();
int err; int err;
if (!dev) if (!dev)
...@@ -157,8 +155,6 @@ struct net_device * __init e2100_probe(int unit) ...@@ -157,8 +155,6 @@ struct net_device * __init e2100_probe(int unit)
sprintf(dev->name, "eth%d", unit); sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev); netdev_boot_setup_check(dev);
dev->priv = NULL; /* until all 8390-based use alloc_etherdev() */
err = do_e2100_probe(dev); err = do_e2100_probe(dev);
if (err) if (err)
goto out; goto out;
...@@ -212,13 +208,6 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr) ...@@ -212,13 +208,6 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr)
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
printk(" %02X", station_addr[i]); printk(" %02X", station_addr[i]);
/* Allocate dev->priv and fill in 8390 specific dev fields. */
if (ethdev_init(dev)) {
printk (" unable to get memory for dev->priv.\n");
retval = -ENOMEM;
goto out;
}
if (dev->irq < 2) { if (dev->irq < 2) {
int irqlist[] = {15,11,10,12,5,9,3,4}, i; int irqlist[] = {15,11,10,12,5,9,3,4}, i;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
...@@ -228,8 +217,6 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr) ...@@ -228,8 +217,6 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr)
} }
if (i >= 8) { if (i >= 8) {
printk(" unable to get IRQ %d.\n", dev->irq); printk(" unable to get IRQ %d.\n", dev->irq);
kfree(dev->priv);
dev->priv = NULL;
retval = -EAGAIN; retval = -EAGAIN;
goto out; goto out;
} }
...@@ -443,10 +430,9 @@ init_module(void) ...@@ -443,10 +430,9 @@ init_module(void)
if (this_dev != 0) break; /* only autoprobe 1st one */ if (this_dev != 0) break; /* only autoprobe 1st one */
printk(KERN_NOTICE "e2100.c: Presently autoprobing (not recommended) for a single card.\n"); printk(KERN_NOTICE "e2100.c: Presently autoprobing (not recommended) for a single card.\n");
} }
dev = alloc_etherdev(0); dev = alloc_ei_netdev();
if (!dev) if (!dev)
break; break;
dev->priv = NULL;
dev->irq = irq[this_dev]; dev->irq = irq[this_dev];
dev->base_addr = io[this_dev]; dev->base_addr = io[this_dev];
dev->mem_start = mem[this_dev]; dev->mem_start = mem[this_dev];
......
...@@ -159,12 +159,11 @@ static void cleanup_card(struct net_device *dev) ...@@ -159,12 +159,11 @@ static void cleanup_card(struct net_device *dev)
{ {
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
release_region(dev->base_addr, ES_IO_EXTENT); release_region(dev->base_addr, ES_IO_EXTENT);
kfree(dev->priv);
} }
struct net_device * __init es_probe(int unit) struct net_device * __init es_probe(int unit)
{ {
struct net_device *dev = alloc_etherdev(0); struct net_device *dev = alloc_ei_netdev();
int err; int err;
if (!dev) if (!dev)
...@@ -173,8 +172,6 @@ struct net_device * __init es_probe(int unit) ...@@ -173,8 +172,6 @@ struct net_device * __init es_probe(int unit)
sprintf(dev->name, "eth%d", unit); sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev); netdev_boot_setup_check(dev);
dev->priv = NULL; /* until all 8390-based use alloc_etherdev() */
err = do_es_probe(dev); err = do_es_probe(dev);
if (err) if (err)
goto out; goto out;
...@@ -278,13 +275,6 @@ static int __init es_probe1(struct net_device *dev, int ioaddr) ...@@ -278,13 +275,6 @@ static int __init es_probe1(struct net_device *dev, int ioaddr)
printk("mem %#lx-%#lx\n", dev->mem_start, dev->mem_end-1); printk("mem %#lx-%#lx\n", dev->mem_start, dev->mem_end-1);
/* Allocate dev->priv and fill in 8390 specific dev fields. */
if (ethdev_init(dev)) {
printk (" unable to allocate memory for dev->priv.\n");
retval = -ENOMEM;
goto out1;
}
#if ES_DEBUG & ES_D_PROBE #if ES_DEBUG & ES_D_PROBE
if (inb(ioaddr + ES_CFG5)) if (inb(ioaddr + ES_CFG5))
printk("es3210: Warning - DMA channel enabled, but not used here.\n"); printk("es3210: Warning - DMA channel enabled, but not used here.\n");
...@@ -437,10 +427,9 @@ init_module(void) ...@@ -437,10 +427,9 @@ init_module(void)
for (this_dev = 0; this_dev < MAX_ES_CARDS; this_dev++) { for (this_dev = 0; this_dev < MAX_ES_CARDS; this_dev++) {
if (io[this_dev] == 0 && this_dev != 0) if (io[this_dev] == 0 && this_dev != 0)
break; break;
dev = alloc_etherdev(0); dev = alloc_ei_netdev();
if (!dev) if (!dev)
break; break;
dev->priv = NULL;
dev->irq = irq[this_dev]; dev->irq = irq[this_dev];
dev->base_addr = io[this_dev]; dev->base_addr = io[this_dev];
dev->mem_start = mem[this_dev]; dev->mem_start = mem[this_dev];
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -275,7 +275,4 @@ typedef struct { ...@@ -275,7 +275,4 @@ typedef struct {
#endif /* _IBM_LANA_DRIVER_ */ #endif /* _IBM_LANA_DRIVER_ */
extern int ibmlana_probe(struct net_device *);
#endif /* _IBM_LANA_INCLUDE_ */ #endif /* _IBM_LANA_INCLUDE_ */
This diff is collapsed.
...@@ -446,7 +446,7 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -446,7 +446,7 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
iounmap(adapter->hw.hw_addr); iounmap(adapter->hw.hw_addr);
err_ioremap: err_ioremap:
pci_release_regions(pdev); pci_release_regions(pdev);
kfree(netdev); free_netdev(netdev);
err_alloc_etherdev: err_alloc_etherdev:
return -ENOMEM; return -ENOMEM;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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