EEPROM: Null out buffer after allocation
[libftdi] / src / ftdi.c
index b9e3a00..c9492f5 100644 (file)
@@ -105,6 +105,7 @@ int ftdi_init(struct ftdi_context *ftdi)
 
     if (eeprom == 0)
         ftdi_error_return(-2, "Can't malloc struct ftdi_eeprom");
+    memset(eeprom, 0, sizeof(struct ftdi_eeprom);
     ftdi->eeprom = eeprom;
 
     /* All fine. Now allocate the readbuffer */
@@ -2214,7 +2215,7 @@ int ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, char * manufacturer,
         eeprom->usb_version = 0x0101;
     else
         eeprom->usb_version = 0x0200;
-    eeprom->max_power = 50;
+    eeprom->max_power = 100;
 
     if (eeprom->manufacturer)
         free (eeprom->manufacturer);
@@ -2248,7 +2249,7 @@ int ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, char * manufacturer,
 
     if(ftdi->type == TYPE_R)
     {
-        eeprom->max_power = 45;
+        eeprom->max_power = 90;
         eeprom->size = 0x80;
         eeprom->cbus_function[0] = CBUS_TXLED;
         eeprom->cbus_function[1] = CBUS_RXLED;
@@ -2586,6 +2587,11 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
         else
             output[0x01] &= ~SUSPEND_DBUS7;
         
+        if (eeprom->suspend_pull_downs == 1)
+            output[0x0A] |= 0x4;
+        else
+            output[0x0A] &= ~0x4;
+
         if(eeprom->group0_drive > DRIVE_16MA)
             output[0x0c] |= DRIVE_16MA;
         else
@@ -2844,7 +2850,7 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose)
     }
     else if ((ftdi->type == TYPE_2232H) ||(ftdi->type == TYPE_4232H)) 
     {
-        eeprom->high_current     = buf[0x00] & HIGH_CURRENT_DRIVE_R;
+        eeprom->channel_a_type   = buf[0x00] & 0x7;
         eeprom->channel_a_driver = buf[0x00] & DRIVER_VCP;
         eeprom->channel_b_type   = buf[0x01] & 0x7;
         eeprom->channel_b_driver = buf[0x01] & DRIVER_VCP;