78 int ec_eoedev_open(struct net_device *); |
78 int ec_eoedev_open(struct net_device *); |
79 int ec_eoedev_stop(struct net_device *); |
79 int ec_eoedev_stop(struct net_device *); |
80 int ec_eoedev_tx(struct sk_buff *, struct net_device *); |
80 int ec_eoedev_tx(struct sk_buff *, struct net_device *); |
81 struct net_device_stats *ec_eoedev_stats(struct net_device *); |
81 struct net_device_stats *ec_eoedev_stats(struct net_device *); |
82 |
82 |
83 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31) |
83 /*****************************************************************************/ |
84 static const struct net_device_ops ec_eoe_netdev_ops = |
84 |
85 { |
85 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) |
|
86 static const struct net_device_ops ec_eoedev_ops = { |
86 .ndo_open = ec_eoedev_open, |
87 .ndo_open = ec_eoedev_open, |
87 .ndo_stop = ec_eoedev_stop, |
88 .ndo_stop = ec_eoedev_stop, |
88 .ndo_start_xmit = ec_eoedev_tx, |
89 .ndo_start_xmit = ec_eoedev_tx, |
89 .ndo_get_stats = ec_eoedev_stats, |
90 .ndo_get_stats = ec_eoedev_stats, |
90 }; |
91 }; |
148 ret = -ENODEV; |
149 ret = -ENODEV; |
149 goto out_return; |
150 goto out_return; |
150 } |
151 } |
151 |
152 |
152 // initialize net_device |
153 // initialize net_device |
153 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31) |
154 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) |
154 eoe->dev->netdev_ops = &ec_eoe_netdev_ops; |
155 eoe->dev->netdev_ops = &ec_eoedev_ops; |
155 #else |
156 #else |
156 eoe->dev->open = ec_eoedev_open; |
157 eoe->dev->open = ec_eoedev_open; |
157 eoe->dev->stop = ec_eoedev_stop; |
158 eoe->dev->stop = ec_eoedev_stop; |
158 eoe->dev->hard_start_xmit = ec_eoedev_tx; |
159 eoe->dev->hard_start_xmit = ec_eoedev_tx; |
159 eoe->dev->get_stats = ec_eoedev_stats; |
160 eoe->dev->get_stats = ec_eoedev_stats; |
199 * Unregisteres the net_device and frees allocated memory. |
200 * Unregisteres the net_device and frees allocated memory. |
200 */ |
201 */ |
201 void ec_eoe_clear(ec_eoe_t *eoe /**< EoE handler */) |
202 void ec_eoe_clear(ec_eoe_t *eoe /**< EoE handler */) |
202 { |
203 { |
203 unregister_netdev(eoe->dev); // possibly calls close callback |
204 unregister_netdev(eoe->dev); // possibly calls close callback |
204 free_netdev(eoe->dev); |
|
205 |
205 |
206 // empty transmit queue |
206 // empty transmit queue |
207 ec_eoe_flush(eoe); |
207 ec_eoe_flush(eoe); |
208 |
208 |
209 if (eoe->tx_frame) { |
209 if (eoe->tx_frame) { |
210 dev_kfree_skb(eoe->tx_frame->skb); |
210 dev_kfree_skb(eoe->tx_frame->skb); |
211 kfree(eoe->tx_frame); |
211 kfree(eoe->tx_frame); |
212 } |
212 } |
213 |
213 |
214 if (eoe->rx_skb) dev_kfree_skb(eoe->rx_skb); |
214 if (eoe->rx_skb) |
|
215 dev_kfree_skb(eoe->rx_skb); |
|
216 |
|
217 free_netdev(eoe->dev); |
215 |
218 |
216 ec_datagram_clear(&eoe->datagram); |
219 ec_datagram_clear(&eoe->datagram); |
217 } |
220 } |
218 |
221 |
219 /*****************************************************************************/ |
222 /*****************************************************************************/ |