Fixed crash on loading e100 driver for 2.6.33 (allocating cbs_pool). redundancy
authorFlorian Pose <fp@igh-essen.com>
Wed, 04 Jan 2012 12:30:30 +0100
branchredundancy
changeset 2326 a0762c46360e
parent 2325 d1d275d4dfee
child 2327 995205be6393
Fixed crash on loading e100 driver for 2.6.33 (allocating cbs_pool).
devices/e100-2.6.33-ethercat.c
--- a/devices/e100-2.6.33-ethercat.c	Fri Nov 04 11:26:12 2011 +0100
+++ b/devices/e100-2.6.33-ethercat.c	Wed Jan 04 12:30:30 2012 +0100
@@ -206,15 +206,13 @@
 #include <linux/ethtool.h>
 #include <linux/string.h>
 #include <linux/firmware.h>
+#include <asm/unaligned.h>
 
 // EtherCAT includes
 #include "../globals.h"
 #include "ecdev.h"
 
 #define DRV_NAME		"ec_e100"
-#include <asm/unaligned.h>
-
-
 #define DRV_EXT			"-NAPI"
 #define DRV_VERSION		"3.5.24-k2"DRV_EXT
 #define DRV_DESCRIPTION		"Intel(R) PRO/100 Network Driver"
@@ -2994,26 +2992,30 @@
 
 	// offer device to EtherCAT master module
 	nic->ecdev = ecdev_offer(netdev, e100_ec_poll, THIS_MODULE);
+
+	if (!nic->ecdev) {
+		strcpy(netdev->name, "eth%d");
+		if((err = register_netdev(netdev))) {
+			DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n");
+			goto err_out_free;
+		}
+	}
+
+	nic->cbs_pool = pci_pool_create(netdev->name,
+			   nic->pdev,
+			   nic->params.cbs.max * sizeof(struct cb),
+			   sizeof(u32),
+			   0);
+	DPRINTK(PROBE, INFO, "addr 0x%llx, irq %d, MAC addr %pM\n",
+		(unsigned long long)pci_resource_start(pdev, use_io ? 1 : 0),
+		pdev->irq, netdev->dev_addr);
+
 	if (nic->ecdev) {
 		if (ecdev_open(nic->ecdev)) {
 			ecdev_withdraw(nic->ecdev);
 			goto err_out_free;
 		}
-	} else {
-		strcpy(netdev->name, "eth%d");
-		if((err = register_netdev(netdev))) {
-			DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n");
-			goto err_out_free;
-		}
-		nic->cbs_pool = pci_pool_create(netdev->name,
-			   nic->pdev,
-			   nic->params.cbs.max * sizeof(struct cb),
-			   sizeof(u32),
-			   0);
-	}
-	DPRINTK(PROBE, INFO, "addr 0x%llx, irq %d, MAC addr %pM\n",
-		(unsigned long long)pci_resource_start(pdev, use_io ? 1 : 0),
-		pdev->irq, netdev->dev_addr);
+	}
 
 	return 0;