aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2008-11-25 21:12:49 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-25 21:12:49 -0500
commit8884c092e5e4f9a1b6e44f2e02a3eb5481af87ab (patch)
tree3afd7d5b3453aa34ce1f6bb010c3e843ca337b90 /drivers/net
parentb27aeadb5948d400df83db4d29590fb9862ba49d (diff)
8390: add common net_device ops
Fix the defactoring of ei_XXX functions in 8390 and 8390p. Remove the tx_timeout hack since no driver including the 3c503 overrides tx_timeout at this time, looks like a legacy thing. Also, since several drivers all have same hooks, provide common netdev_ops. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/8390.c39
-rw-r--r--drivers/net/8390.h18
-rw-r--r--drivers/net/8390p.c39
-rw-r--r--drivers/net/lib8390.c19
4 files changed, 97 insertions, 18 deletions
diff --git a/drivers/net/8390.c b/drivers/net/8390.c
index f72a2e87d569..029ad08f0330 100644
--- a/drivers/net/8390.c
+++ b/drivers/net/8390.c
@@ -17,6 +17,30 @@ int ei_close(struct net_device *dev)
17} 17}
18EXPORT_SYMBOL(ei_close); 18EXPORT_SYMBOL(ei_close);
19 19
20int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
21{
22 return __ei_start_xmit(skb, dev);
23}
24EXPORT_SYMBOL(ei_start_xmit);
25
26struct net_device_stats *ei_get_stats(struct net_device *dev)
27{
28 return __ei_get_stats(dev);
29}
30EXPORT_SYMBOL(ei_get_stats);
31
32void ei_set_multicast_list(struct net_device *dev)
33{
34 __ei_set_multicast_list(dev);
35}
36EXPORT_SYMBOL(ei_set_multicast_list);
37
38void ei_tx_timeout(struct net_device *dev)
39{
40 __ei_tx_timeout(dev);
41}
42EXPORT_SYMBOL(ei_tx_timeout);
43
20irqreturn_t ei_interrupt(int irq, void *dev_id) 44irqreturn_t ei_interrupt(int irq, void *dev_id)
21{ 45{
22 return __ei_interrupt(irq, dev_id); 46 return __ei_interrupt(irq, dev_id);
@@ -31,6 +55,21 @@ void ei_poll(struct net_device *dev)
31EXPORT_SYMBOL(ei_poll); 55EXPORT_SYMBOL(ei_poll);
32#endif 56#endif
33 57
58const struct net_device_ops ei_netdev_ops = {
59 .ndo_open = ei_open,
60 .ndo_stop = ei_close,
61 .ndo_start_xmit = ei_start_xmit,
62 .ndo_tx_timeout = ei_tx_timeout,
63 .ndo_get_stats = ei_get_stats,
64 .ndo_set_multicast_list = ei_set_multicast_list,
65 .ndo_validate_addr = eth_validate_addr,
66 .ndo_change_mtu = eth_change_mtu,
67#ifdef CONFIG_NET_POLL_CONTROLLER
68 .ndo_poll_controller = ei_poll,
69#endif
70};
71EXPORT_SYMBOL(ei_netdev_ops);
72
34struct net_device *__alloc_ei_netdev(int size) 73struct net_device *__alloc_ei_netdev(int size)
35{ 74{
36 return ____alloc_ei_netdev(size); 75 return ____alloc_ei_netdev(size);
diff --git a/drivers/net/8390.h b/drivers/net/8390.h
index 9470998bf634..3c61d6d2748a 100644
--- a/drivers/net/8390.h
+++ b/drivers/net/8390.h
@@ -33,16 +33,19 @@ extern void ei_poll(struct net_device *dev);
33extern void eip_poll(struct net_device *dev); 33extern void eip_poll(struct net_device *dev);
34#endif 34#endif
35 35
36extern void ei_tx_timeout(struct net_device *dev);
37extern int ei_start_xmit(struct sk_buff *skb, struct net_device *dev);
38extern void ei_set_multicast_list(struct net_device *dev);
39extern struct net_device_stats *ei_get_stats(struct net_device *dev);
40 36
41/* Without I/O delay - non ISA or later chips */ 37/* Without I/O delay - non ISA or later chips */
42extern void NS8390_init(struct net_device *dev, int startp); 38extern void NS8390_init(struct net_device *dev, int startp);
43extern int ei_open(struct net_device *dev); 39extern int ei_open(struct net_device *dev);
44extern int ei_close(struct net_device *dev); 40extern int ei_close(struct net_device *dev);
45extern irqreturn_t ei_interrupt(int irq, void *dev_id); 41extern irqreturn_t ei_interrupt(int irq, void *dev_id);
42extern void ei_tx_timeout(struct net_device *dev);
43extern int ei_start_xmit(struct sk_buff *skb, struct net_device *dev);
44extern void ei_set_multicast_list(struct net_device *dev);
45extern struct net_device_stats *ei_get_stats(struct net_device *dev);
46
47extern const struct net_device_ops ei_netdev_ops;
48
46extern struct net_device *__alloc_ei_netdev(int size); 49extern struct net_device *__alloc_ei_netdev(int size);
47static inline struct net_device *alloc_ei_netdev(void) 50static inline struct net_device *alloc_ei_netdev(void)
48{ 51{
@@ -54,6 +57,13 @@ extern void NS8390p_init(struct net_device *dev, int startp);
54extern int eip_open(struct net_device *dev); 57extern int eip_open(struct net_device *dev);
55extern int eip_close(struct net_device *dev); 58extern int eip_close(struct net_device *dev);
56extern irqreturn_t eip_interrupt(int irq, void *dev_id); 59extern irqreturn_t eip_interrupt(int irq, void *dev_id);
60extern void eip_tx_timeout(struct net_device *dev);
61extern int eip_start_xmit(struct sk_buff *skb, struct net_device *dev);
62extern void eip_set_multicast_list(struct net_device *dev);
63extern struct net_device_stats *eip_get_stats(struct net_device *dev);
64
65extern const struct net_device_ops eip_netdev_ops;
66
57extern struct net_device *__alloc_eip_netdev(int size); 67extern struct net_device *__alloc_eip_netdev(int size);
58static inline struct net_device *alloc_eip_netdev(void) 68static inline struct net_device *alloc_eip_netdev(void)
59{ 69{
diff --git a/drivers/net/8390p.c b/drivers/net/8390p.c
index 4c6eea4611a2..9c916d4d206e 100644
--- a/drivers/net/8390p.c
+++ b/drivers/net/8390p.c
@@ -22,6 +22,30 @@ int eip_close(struct net_device *dev)
22} 22}
23EXPORT_SYMBOL(eip_close); 23EXPORT_SYMBOL(eip_close);
24 24
25int eip_start_xmit(struct sk_buff *skb, struct net_device *dev)
26{
27 return __ei_start_xmit(skb, dev);
28}
29EXPORT_SYMBOL(eip_start_xmit);
30
31struct net_device_stats *eip_get_stats(struct net_device *dev)
32{
33 return __ei_get_stats(dev);
34}
35EXPORT_SYMBOL(eip_get_stats);
36
37void eip_set_multicast_list(struct net_device *dev)
38{
39 __ei_set_multicast_list(dev);
40}
41EXPORT_SYMBOL(eip_set_multicast_list);
42
43void eip_tx_timeout(struct net_device *dev)
44{
45 __ei_tx_timeout(dev);
46}
47EXPORT_SYMBOL(eip_tx_timeout);
48
25irqreturn_t eip_interrupt(int irq, void *dev_id) 49irqreturn_t eip_interrupt(int irq, void *dev_id)
26{ 50{
27 return __ei_interrupt(irq, dev_id); 51 return __ei_interrupt(irq, dev_id);
@@ -36,6 +60,21 @@ void eip_poll(struct net_device *dev)
36EXPORT_SYMBOL(eip_poll); 60EXPORT_SYMBOL(eip_poll);
37#endif 61#endif
38 62
63const struct net_device_ops eip_netdev_ops = {
64 .ndo_open = eip_open,
65 .ndo_stop = eip_close,
66 .ndo_start_xmit = eip_start_xmit,
67 .ndo_tx_timeout = eip_tx_timeout,
68 .ndo_get_stats = eip_get_stats,
69 .ndo_set_multicast_list = eip_set_multicast_list,
70 .ndo_validate_addr = eth_validate_addr,
71 .ndo_change_mtu = eth_change_mtu,
72#ifdef CONFIG_NET_POLL_CONTROLLER
73 .ndo_poll_controller = eip_poll,
74#endif
75};
76EXPORT_SYMBOL(eip_netdev_ops);
77
39struct net_device *__alloc_eip_netdev(int size) 78struct net_device *__alloc_eip_netdev(int size)
40{ 79{
41 return ____alloc_ei_netdev(size); 80 return ____alloc_ei_netdev(size);
diff --git a/drivers/net/lib8390.c b/drivers/net/lib8390.c
index 46335af12393..1d36ca4dc6b9 100644
--- a/drivers/net/lib8390.c
+++ b/drivers/net/lib8390.c
@@ -205,12 +205,6 @@ static int __ei_open(struct net_device *dev)
205 unsigned long flags; 205 unsigned long flags;
206 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 206 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
207 207
208 /* The card I/O part of the driver (e.g. 3c503) can hook a Tx timeout
209 wrapper that does e.g. media check & then calls ei_tx_timeout. */
210#ifdef CONFIG_COMPAT_NET_DEV_OPS
211 if (dev->tx_timeout == NULL)
212 dev->tx_timeout = ei_tx_timeout;
213#endif
214 if (dev->watchdog_timeo <= 0) 208 if (dev->watchdog_timeo <= 0)
215 dev->watchdog_timeo = TX_TIMEOUT; 209 dev->watchdog_timeo = TX_TIMEOUT;
216 210
@@ -259,7 +253,7 @@ static int __ei_close(struct net_device *dev)
259 * completed (or failed) - i.e. never posted a Tx related interrupt. 253 * completed (or failed) - i.e. never posted a Tx related interrupt.
260 */ 254 */
261 255
262void ei_tx_timeout(struct net_device *dev) 256static void __ei_tx_timeout(struct net_device *dev)
263{ 257{
264 unsigned long e8390_base = dev->base_addr; 258 unsigned long e8390_base = dev->base_addr;
265 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 259 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
@@ -296,7 +290,6 @@ void ei_tx_timeout(struct net_device *dev)
296 enable_irq_lockdep(dev->irq); 290 enable_irq_lockdep(dev->irq);
297 netif_wake_queue(dev); 291 netif_wake_queue(dev);
298} 292}
299EXPORT_SYMBOL_GPL(ei_tx_timeout);
300 293
301/** 294/**
302 * ei_start_xmit - begin packet transmission 295 * ei_start_xmit - begin packet transmission
@@ -306,7 +299,7 @@ EXPORT_SYMBOL_GPL(ei_tx_timeout);
306 * Sends a packet to an 8390 network device. 299 * Sends a packet to an 8390 network device.
307 */ 300 */
308 301
309int ei_start_xmit(struct sk_buff *skb, struct net_device *dev) 302static int __ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
310{ 303{
311 unsigned long e8390_base = dev->base_addr; 304 unsigned long e8390_base = dev->base_addr;
312 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 305 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
@@ -423,7 +416,6 @@ int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
423 416
424 return 0; 417 return 0;
425} 418}
426EXPORT_SYMBOL_GPL(ei_start_xmit);
427 419
428/** 420/**
429 * ei_interrupt - handle the interrupts from an 8390 421 * ei_interrupt - handle the interrupts from an 8390
@@ -885,7 +877,7 @@ static void ei_rx_overrun(struct net_device *dev)
885 * Collect the stats. This is called unlocked and from several contexts. 877 * Collect the stats. This is called unlocked and from several contexts.
886 */ 878 */
887 879
888struct net_device_stats *ei_get_stats(struct net_device *dev) 880static struct net_device_stats *__ei_get_stats(struct net_device *dev)
889{ 881{
890 unsigned long ioaddr = dev->base_addr; 882 unsigned long ioaddr = dev->base_addr;
891 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 883 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
@@ -904,7 +896,6 @@ struct net_device_stats *ei_get_stats(struct net_device *dev)
904 896
905 return &dev->stats; 897 return &dev->stats;
906} 898}
907EXPORT_SYMBOL_GPL(ei_get_stats);
908 899
909/* 900/*
910 * Form the 64 bit 8390 multicast table from the linked list of addresses 901 * Form the 64 bit 8390 multicast table from the linked list of addresses
@@ -995,7 +986,7 @@ static void do_set_multicast_list(struct net_device *dev)
995 * not called too often. Must protect against both bh and irq users 986 * not called too often. Must protect against both bh and irq users
996 */ 987 */
997 988
998void ei_set_multicast_list(struct net_device *dev) 989static void __ei_set_multicast_list(struct net_device *dev)
999{ 990{
1000 unsigned long flags; 991 unsigned long flags;
1001 struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev); 992 struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
@@ -1004,7 +995,6 @@ void ei_set_multicast_list(struct net_device *dev)
1004 do_set_multicast_list(dev); 995 do_set_multicast_list(dev);
1005 spin_unlock_irqrestore(&ei_local->page_lock, flags); 996 spin_unlock_irqrestore(&ei_local->page_lock, flags);
1006} 997}
1007EXPORT_SYMBOL_GPL(ei_set_multicast_list);
1008 998
1009/** 999/**
1010 * ethdev_setup - init rest of 8390 device struct 1000 * ethdev_setup - init rest of 8390 device struct
@@ -1024,6 +1014,7 @@ static void ethdev_setup(struct net_device *dev)
1024 dev->hard_start_xmit = ei_start_xmit; 1014 dev->hard_start_xmit = ei_start_xmit;
1025 dev->get_stats = ei_get_stats; 1015 dev->get_stats = ei_get_stats;
1026 dev->set_multicast_list = ei_set_multicast_list; 1016 dev->set_multicast_list = ei_set_multicast_list;
1017 dev->tx_timeout = __ei_tx_timeout;
1027#endif 1018#endif
1028 ether_setup(dev); 1019 ether_setup(dev);
1029 1020