Generic driver net_device_ops for kernels < 2.6.29.
authorFlorian Pose <fp@igh-essen.com>
Thu, 05 Nov 2009 09:37:31 +0100
changeset 1555 7679e98b0bb1
parent 1554 e07a0f8de03d
child 1556 52ec7297637c
Generic driver net_device_ops for kernels < 2.6.29.
devices/generic.c
--- a/devices/generic.c	Thu Nov 05 09:25:25 2009 +0100
+++ b/devices/generic.c	Thu Nov 05 09:37:31 2009 +0100
@@ -114,11 +114,13 @@
 
 /*****************************************************************************/
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
 static const struct net_device_ops ec_gen_netdev_ops = {
-	.ndo_open		= ec_gen_netdev_open,
-	.ndo_stop		= ec_gen_netdev_stop,
-	.ndo_start_xmit	= ec_gen_netdev_start_xmit,
+    .ndo_open       = ec_gen_netdev_open,
+    .ndo_stop       = ec_gen_netdev_stop,
+    .ndo_start_xmit = ec_gen_netdev_start_xmit,
 };
+#endif
 
 /*****************************************************************************/
 
@@ -135,12 +137,20 @@
     dev->ecdev = NULL;
     dev->socket = NULL;
 
-	dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null, ether_setup);
-	if (!dev->netdev) {
-		return -ENOMEM;
-	}
+    dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null, ether_setup);
+    if (!dev->netdev) {
+        return -ENOMEM;
+    }
     memcpy(dev->netdev->dev_addr, real_netdev->dev_addr, ETH_ALEN);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     dev->netdev->netdev_ops = &ec_gen_netdev_ops;
+#else
+    dev->netdev->open = ec_gen_netdev_open;
+    dev->netdev->stop = ec_gen_netdev_stop;
+    dev->netdev->hard_start_xmit = ec_gen_netdev_start_xmit;
+#endif
+
     priv = netdev_priv(dev->netdev);
     *priv = dev;
 
@@ -212,7 +222,7 @@
 {
     int ret = 0;
 
-	dev->ecdev = ecdev_offer(dev->netdev, ec_gen_poll, THIS_MODULE);
+    dev->ecdev = ecdev_offer(dev->netdev, ec_gen_poll, THIS_MODULE);
     if (dev->ecdev) {
         if (ec_gen_device_create_socket(dev, real_netdev)) {
             ecdev_withdraw(dev->ecdev);