Commit 4e4fd4e4 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

ne2k: convert to net_device_ops

Convert driver to new net_device_ops. Compile tested only.
This required some additional work to export common code ei_XXX.
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 99921b7e
...@@ -33,6 +33,11 @@ extern void ei_poll(struct net_device *dev); ...@@ -33,6 +33,11 @@ extern void ei_poll(struct net_device *dev);
extern void eip_poll(struct net_device *dev); extern void eip_poll(struct net_device *dev);
#endif #endif
extern void ei_tx_timeout(struct net_device *dev);
extern int ei_start_xmit(struct sk_buff *skb, struct net_device *dev);
extern void ei_set_multicast_list(struct net_device *dev);
extern struct net_device_stats *ei_get_stats(struct net_device *dev);
/* Without I/O delay - non ISA or later chips */ /* Without I/O delay - non ISA or later chips */
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);
......
...@@ -108,14 +108,13 @@ int ei_debug = 1; ...@@ -108,14 +108,13 @@ int ei_debug = 1;
/* Index to functions. */ /* Index to functions. */
static void ei_tx_intr(struct net_device *dev); static void ei_tx_intr(struct net_device *dev);
static void ei_tx_err(struct net_device *dev); static void ei_tx_err(struct net_device *dev);
static void ei_tx_timeout(struct net_device *dev); void ei_tx_timeout(struct net_device *dev);
static void ei_receive(struct net_device *dev); static void ei_receive(struct net_device *dev);
static void ei_rx_overrun(struct net_device *dev); static void ei_rx_overrun(struct net_device *dev);
/* Routines generic to NS8390-based boards. */ /* Routines generic to NS8390-based boards. */
static void NS8390_trigger_send(struct net_device *dev, unsigned int length, static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
int start_page); int start_page);
static void set_multicast_list(struct net_device *dev);
static void do_set_multicast_list(struct net_device *dev); static void do_set_multicast_list(struct net_device *dev);
static void __NS8390_init(struct net_device *dev, int startp); static void __NS8390_init(struct net_device *dev, int startp);
...@@ -208,8 +207,10 @@ static int __ei_open(struct net_device *dev) ...@@ -208,8 +207,10 @@ static int __ei_open(struct net_device *dev)
/* 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. */
#ifdef CONFIG_COMPAT_NET_DEV_OPS
if (dev->tx_timeout == NULL) if (dev->tx_timeout == NULL)
dev->tx_timeout = ei_tx_timeout; dev->tx_timeout = ei_tx_timeout;
#endif
if (dev->watchdog_timeo <= 0) if (dev->watchdog_timeo <= 0)
dev->watchdog_timeo = TX_TIMEOUT; dev->watchdog_timeo = TX_TIMEOUT;
...@@ -258,7 +259,7 @@ static int __ei_close(struct net_device *dev) ...@@ -258,7 +259,7 @@ static int __ei_close(struct net_device *dev)
* completed (or failed) - i.e. never posted a Tx related interrupt. * completed (or failed) - i.e. never posted a Tx related interrupt.
*/ */
static void ei_tx_timeout(struct net_device *dev) void ei_tx_timeout(struct net_device *dev)
{ {
unsigned long e8390_base = dev->base_addr; unsigned long e8390_base = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
...@@ -295,6 +296,7 @@ static void ei_tx_timeout(struct net_device *dev) ...@@ -295,6 +296,7 @@ static void ei_tx_timeout(struct net_device *dev)
enable_irq_lockdep(dev->irq); enable_irq_lockdep(dev->irq);
netif_wake_queue(dev); netif_wake_queue(dev);
} }
EXPORT_SYMBOL_GPL(ei_tx_timeout);
/** /**
* ei_start_xmit - begin packet transmission * ei_start_xmit - begin packet transmission
...@@ -304,7 +306,7 @@ static void ei_tx_timeout(struct net_device *dev) ...@@ -304,7 +306,7 @@ static void ei_tx_timeout(struct net_device *dev)
* Sends a packet to an 8390 network device. * Sends a packet to an 8390 network device.
*/ */
static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev) int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
unsigned long e8390_base = dev->base_addr; unsigned long e8390_base = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
...@@ -421,6 +423,7 @@ static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -421,6 +423,7 @@ static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(ei_start_xmit);
/** /**
* ei_interrupt - handle the interrupts from an 8390 * ei_interrupt - handle the interrupts from an 8390
...@@ -882,7 +885,7 @@ static void ei_rx_overrun(struct net_device *dev) ...@@ -882,7 +885,7 @@ static void ei_rx_overrun(struct net_device *dev)
* Collect the stats. This is called unlocked and from several contexts. * Collect the stats. This is called unlocked and from several contexts.
*/ */
static struct net_device_stats *get_stats(struct net_device *dev) struct net_device_stats *ei_get_stats(struct net_device *dev)
{ {
unsigned long ioaddr = dev->base_addr; unsigned long ioaddr = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
...@@ -901,6 +904,7 @@ static struct net_device_stats *get_stats(struct net_device *dev) ...@@ -901,6 +904,7 @@ static struct net_device_stats *get_stats(struct net_device *dev)
return &dev->stats; return &dev->stats;
} }
EXPORT_SYMBOL_GPL(ei_get_stats);
/* /*
* Form the 64 bit 8390 multicast table from the linked list of addresses * Form the 64 bit 8390 multicast table from the linked list of addresses
...@@ -991,7 +995,7 @@ static void do_set_multicast_list(struct net_device *dev) ...@@ -991,7 +995,7 @@ static void do_set_multicast_list(struct net_device *dev)
* not called too often. Must protect against both bh and irq users * not called too often. Must protect against both bh and irq users
*/ */
static void set_multicast_list(struct net_device *dev) void ei_set_multicast_list(struct net_device *dev)
{ {
unsigned long flags; unsigned long flags;
struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev); struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
...@@ -1000,6 +1004,7 @@ static void set_multicast_list(struct net_device *dev) ...@@ -1000,6 +1004,7 @@ static void set_multicast_list(struct net_device *dev)
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);
} }
EXPORT_SYMBOL_GPL(ei_set_multicast_list);
/** /**
* ethdev_setup - init rest of 8390 device struct * ethdev_setup - init rest of 8390 device struct
...@@ -1015,10 +1020,11 @@ static void ethdev_setup(struct net_device *dev) ...@@ -1015,10 +1020,11 @@ static void ethdev_setup(struct net_device *dev)
if (ei_debug > 1) if (ei_debug > 1)
printk(version); printk(version);
dev->hard_start_xmit = &ei_start_xmit; #ifdef CONFIG_COMPAT_NET_DEV_OPS
dev->get_stats = get_stats; dev->hard_start_xmit = ei_start_xmit;
dev->set_multicast_list = &set_multicast_list; dev->get_stats = ei_get_stats;
dev->set_multicast_list = ei_set_multicast_list;
#endif
ether_setup(dev); ether_setup(dev);
spin_lock_init(&ei_local->page_lock); spin_lock_init(&ei_local->page_lock);
......
...@@ -200,6 +200,19 @@ struct ne2k_pci_card { ...@@ -200,6 +200,19 @@ struct ne2k_pci_card {
in the 'dev' and 'ei_status' structures. in the 'dev' and 'ei_status' structures.
*/ */
static const struct net_device_ops ne2k_netdev_ops = {
.ndo_open = ne2k_pci_open,
.ndo_stop = ne2k_pci_close,
.ndo_start_xmit = ei_start_xmit,
.ndo_tx_timeout = ei_tx_timeout,
.ndo_get_stats = ei_get_stats,
.ndo_set_multicast_list = ei_set_multicast_list,
.ndo_validate_addr = eth_validate_addr,
.ndo_change_mtu = eth_change_mtu,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = ei_poll,
#endif
};
static int __devinit ne2k_pci_init_one (struct pci_dev *pdev, static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
...@@ -265,6 +278,8 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev, ...@@ -265,6 +278,8 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
dev_err(&pdev->dev, "cannot allocate ethernet device\n"); dev_err(&pdev->dev, "cannot allocate ethernet device\n");
goto err_out_free_res; goto err_out_free_res;
} }
dev->netdev_ops = &ne2k_netdev_ops;
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
/* Reset card. Who knows what dain-bramaged state it was left in. */ /* Reset card. Who knows what dain-bramaged state it was left in. */
...@@ -353,12 +368,8 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev, ...@@ -353,12 +368,8 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
ei_status.block_output = &ne2k_pci_block_output; ei_status.block_output = &ne2k_pci_block_output;
ei_status.get_8390_hdr = &ne2k_pci_get_8390_hdr; ei_status.get_8390_hdr = &ne2k_pci_get_8390_hdr;
ei_status.priv = (unsigned long) pdev; ei_status.priv = (unsigned long) pdev;
dev->open = &ne2k_pci_open;
dev->stop = &ne2k_pci_close;
dev->ethtool_ops = &ne2k_pci_ethtool_ops; dev->ethtool_ops = &ne2k_pci_ethtool_ops;
#ifdef CONFIG_NET_POLL_CONTROLLER
dev->poll_controller = ei_poll;
#endif
NS8390_init(dev, 0); NS8390_init(dev, 0);
i = register_netdev(dev); i = register_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