diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2009-03-20 15:36:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-22 01:37:56 -0400 |
commit | 3dd205165e076eacf09575f0c90031e7c52bc5e1 (patch) | |
tree | 5057f55e9389d3484c490f15317b8fad17f99678 /drivers/net/pcmcia/axnet_cs.c | |
parent | 9b31b6971f448796768860e3c9ee2d22f4511731 (diff) |
axnet: convert to net_device_ops
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/pcmcia/axnet_cs.c')
-rw-r--r-- | drivers/net/pcmcia/axnet_cs.c | 68 |
1 files changed, 26 insertions, 42 deletions
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 871ad2958ff6..501a8d7ac2be 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
36 | #include <linux/ethtool.h> | 36 | #include <linux/ethtool.h> |
37 | #include <linux/netdevice.h> | 37 | #include <linux/netdevice.h> |
38 | #include <linux/etherdevice.h> | ||
38 | #include <linux/crc32.h> | 39 | #include <linux/crc32.h> |
39 | #include "../8390.h" | 40 | #include "../8390.h" |
40 | 41 | ||
@@ -91,6 +92,10 @@ static void axnet_release(struct pcmcia_device *link); | |||
91 | static int axnet_open(struct net_device *dev); | 92 | static int axnet_open(struct net_device *dev); |
92 | static int axnet_close(struct net_device *dev); | 93 | static int axnet_close(struct net_device *dev); |
93 | static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); | 94 | static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
95 | static int axnet_start_xmit(struct sk_buff *skb, struct net_device *dev); | ||
96 | static struct net_device_stats *get_stats(struct net_device *dev); | ||
97 | static void set_multicast_list(struct net_device *dev); | ||
98 | static void axnet_tx_timeout(struct net_device *dev); | ||
94 | static const struct ethtool_ops netdev_ethtool_ops; | 99 | static const struct ethtool_ops netdev_ethtool_ops; |
95 | static irqreturn_t ei_irq_wrapper(int irq, void *dev_id); | 100 | static irqreturn_t ei_irq_wrapper(int irq, void *dev_id); |
96 | static void ei_watchdog(u_long arg); | 101 | static void ei_watchdog(u_long arg); |
@@ -108,7 +113,6 @@ static void block_output(struct net_device *dev, int count, | |||
108 | 113 | ||
109 | static void axnet_detach(struct pcmcia_device *p_dev); | 114 | static void axnet_detach(struct pcmcia_device *p_dev); |
110 | 115 | ||
111 | static void axdev_setup(struct net_device *dev); | ||
112 | static void AX88190_init(struct net_device *dev, int startp); | 116 | static void AX88190_init(struct net_device *dev, int startp); |
113 | static int ax_open(struct net_device *dev); | 117 | static int ax_open(struct net_device *dev); |
114 | static int ax_close(struct net_device *dev); | 118 | static int ax_close(struct net_device *dev); |
@@ -134,6 +138,19 @@ static inline axnet_dev_t *PRIV(struct net_device *dev) | |||
134 | return p; | 138 | return p; |
135 | } | 139 | } |
136 | 140 | ||
141 | static const struct net_device_ops axnet_netdev_ops = { | ||
142 | .ndo_open = axnet_open, | ||
143 | .ndo_stop = axnet_close, | ||
144 | .ndo_do_ioctl = axnet_ioctl, | ||
145 | .ndo_start_xmit = axnet_start_xmit, | ||
146 | .ndo_tx_timeout = axnet_tx_timeout, | ||
147 | .ndo_get_stats = get_stats, | ||
148 | .ndo_set_multicast_list = set_multicast_list, | ||
149 | .ndo_change_mtu = eth_change_mtu, | ||
150 | .ndo_set_mac_address = eth_mac_addr, | ||
151 | .ndo_validate_addr = eth_validate_addr, | ||
152 | }; | ||
153 | |||
137 | /*====================================================================== | 154 | /*====================================================================== |
138 | 155 | ||
139 | axnet_attach() creates an "instance" of the driver, allocating | 156 | axnet_attach() creates an "instance" of the driver, allocating |
@@ -146,15 +163,17 @@ static int axnet_probe(struct pcmcia_device *link) | |||
146 | { | 163 | { |
147 | axnet_dev_t *info; | 164 | axnet_dev_t *info; |
148 | struct net_device *dev; | 165 | struct net_device *dev; |
166 | struct ei_device *ei_local; | ||
149 | 167 | ||
150 | DEBUG(0, "axnet_attach()\n"); | 168 | DEBUG(0, "axnet_attach()\n"); |
151 | 169 | ||
152 | dev = alloc_netdev(sizeof(struct ei_device) + sizeof(axnet_dev_t), | 170 | dev = alloc_etherdev(sizeof(struct ei_device) + sizeof(axnet_dev_t)); |
153 | "eth%d", axdev_setup); | ||
154 | |||
155 | if (!dev) | 171 | if (!dev) |
156 | return -ENOMEM; | 172 | return -ENOMEM; |
157 | 173 | ||
174 | ei_local = netdev_priv(dev); | ||
175 | spin_lock_init(&ei_local->page_lock); | ||
176 | |||
158 | info = PRIV(dev); | 177 | info = PRIV(dev); |
159 | info->p_dev = link; | 178 | info->p_dev = link; |
160 | link->priv = dev; | 179 | link->priv = dev; |
@@ -163,10 +182,10 @@ static int axnet_probe(struct pcmcia_device *link) | |||
163 | link->conf.Attributes = CONF_ENABLE_IRQ; | 182 | link->conf.Attributes = CONF_ENABLE_IRQ; |
164 | link->conf.IntType = INT_MEMORY_AND_IO; | 183 | link->conf.IntType = INT_MEMORY_AND_IO; |
165 | 184 | ||
166 | dev->open = &axnet_open; | 185 | dev->netdev_ops = &axnet_netdev_ops; |
167 | dev->stop = &axnet_close; | 186 | |
168 | dev->do_ioctl = &axnet_ioctl; | ||
169 | SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); | 187 | SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); |
188 | dev->watchdog_timeo = TX_TIMEOUT; | ||
170 | 189 | ||
171 | return axnet_config(link); | 190 | return axnet_config(link); |
172 | } /* axnet_attach */ | 191 | } /* axnet_attach */ |
@@ -905,14 +924,12 @@ int ei_debug = 1; | |||
905 | /* Index to functions. */ | 924 | /* Index to functions. */ |
906 | static void ei_tx_intr(struct net_device *dev); | 925 | static void ei_tx_intr(struct net_device *dev); |
907 | static void ei_tx_err(struct net_device *dev); | 926 | static void ei_tx_err(struct net_device *dev); |
908 | static void axnet_tx_timeout(struct net_device *dev); | ||
909 | static void ei_receive(struct net_device *dev); | 927 | static void ei_receive(struct net_device *dev); |
910 | static void ei_rx_overrun(struct net_device *dev); | 928 | static void ei_rx_overrun(struct net_device *dev); |
911 | 929 | ||
912 | /* Routines generic to NS8390-based boards. */ | 930 | /* Routines generic to NS8390-based boards. */ |
913 | static void NS8390_trigger_send(struct net_device *dev, unsigned int length, | 931 | static void NS8390_trigger_send(struct net_device *dev, unsigned int length, |
914 | int start_page); | 932 | int start_page); |
915 | static void set_multicast_list(struct net_device *dev); | ||
916 | static void do_set_multicast_list(struct net_device *dev); | 933 | static void do_set_multicast_list(struct net_device *dev); |
917 | 934 | ||
918 | /* | 935 | /* |
@@ -954,15 +971,6 @@ static int ax_open(struct net_device *dev) | |||
954 | unsigned long flags; | 971 | unsigned long flags; |
955 | struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); | 972 | struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); |
956 | 973 | ||
957 | #ifdef HAVE_TX_TIMEOUT | ||
958 | /* The card I/O part of the driver (e.g. 3c503) can hook a Tx timeout | ||
959 | wrapper that does e.g. media check & then calls axnet_tx_timeout. */ | ||
960 | if (dev->tx_timeout == NULL) | ||
961 | dev->tx_timeout = axnet_tx_timeout; | ||
962 | if (dev->watchdog_timeo <= 0) | ||
963 | dev->watchdog_timeo = TX_TIMEOUT; | ||
964 | #endif | ||
965 | |||
966 | /* | 974 | /* |
967 | * Grab the page lock so we own the register set, then call | 975 | * Grab the page lock so we own the register set, then call |
968 | * the init function. | 976 | * the init function. |
@@ -1701,30 +1709,6 @@ static void set_multicast_list(struct net_device *dev) | |||
1701 | spin_unlock_irqrestore(&dev_lock(dev), flags); | 1709 | spin_unlock_irqrestore(&dev_lock(dev), flags); |
1702 | } | 1710 | } |
1703 | 1711 | ||
1704 | /** | ||
1705 | * axdev_setup - init rest of 8390 device struct | ||
1706 | * @dev: network device structure to init | ||
1707 | * | ||
1708 | * Initialize the rest of the 8390 device structure. Do NOT __init | ||
1709 | * this, as it is used by 8390 based modular drivers too. | ||
1710 | */ | ||
1711 | |||
1712 | static void axdev_setup(struct net_device *dev) | ||
1713 | { | ||
1714 | struct ei_device *ei_local; | ||
1715 | if (ei_debug > 1) | ||
1716 | printk(version_8390); | ||
1717 | |||
1718 | ei_local = (struct ei_device *)netdev_priv(dev); | ||
1719 | spin_lock_init(&ei_local->page_lock); | ||
1720 | |||
1721 | dev->hard_start_xmit = &axnet_start_xmit; | ||
1722 | dev->get_stats = get_stats; | ||
1723 | dev->set_multicast_list = &set_multicast_list; | ||
1724 | |||
1725 | ether_setup(dev); | ||
1726 | } | ||
1727 | |||
1728 | /* This page of functions should be 8390 generic */ | 1712 | /* This page of functions should be 8390 generic */ |
1729 | /* Follow National Semi's recommendations for initializing the "NIC". */ | 1713 | /* Follow National Semi's recommendations for initializing the "NIC". */ |
1730 | 1714 | ||