Chip Type dependend code must be evaluated type dependant
authorUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Wed, 8 Sep 2010 16:16:59 +0000 (18:16 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 20 Sep 2010 13:34:37 +0000 (15:34 +0200)
src/ftdi.c

index aa713d5..de696f3 100644 (file)
@@ -2610,19 +2610,6 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, unsigned char *buf, int size)
     }
     else eeprom->serial = NULL;
 
-    // Addr 14: CBUS function: CBUS0, CBUS1
-    // Addr 15: CBUS function: CBUS2, CBUS3
-    // Addr 16: CBUS function: CBUS5
-    if (ftdi->type == TYPE_R) {
-        eeprom->cbus_function[0] = buf[0x14] & 0x0f;
-        eeprom->cbus_function[1] = (buf[0x14] >> 4) & 0x0f;
-        eeprom->cbus_function[2] = buf[0x15] & 0x0f;
-        eeprom->cbus_function[3] = (buf[0x15] >> 4) & 0x0f;
-        eeprom->cbus_function[4] = buf[0x16] & 0x0f;
-    } else {
-        for (j=0; j<5; j++) eeprom->cbus_function[j] = 0;
-    }
-
     // verify checksum
     checksum = 0xAAAA;
 
@@ -2643,6 +2630,22 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, unsigned char *buf, int size)
         ftdi_error_return(-1,"EEPROM checksum error");
     }
 
+    if(ftdi->type == TYPE_R)
+    {
+        // Addr 14: CBUS function: CBUS0, CBUS1
+        // Addr 15: CBUS function: CBUS2, CBUS3
+        // Addr 16: CBUS function: CBUS5
+        if (ftdi->type == TYPE_R) {
+            eeprom->cbus_function[0] = buf[0x14] & 0x0f;
+            eeprom->cbus_function[1] = (buf[0x14] >> 4) & 0x0f;
+            eeprom->cbus_function[2] = buf[0x15] & 0x0f;
+            eeprom->cbus_function[3] = (buf[0x15] >> 4) & 0x0f;
+            eeprom->cbus_function[4] = buf[0x16] & 0x0f;
+        } else {
+        for (j=0; j<5; j++) eeprom->cbus_function[j] = 0;
+        }
+    }
+
     return 0;
 }