Update copyright information and add ftdi_eeprom TODO list
[libftdi] / src / ftdi.c
index ff09a35..782bd0f 100644 (file)
@@ -2,7 +2,7 @@
                           ftdi.c  -  description
                              -------------------
     begin                : Fri Apr 4 2003
-    copyright            : (C) 2003-2010 by Intra2net AG
+    copyright            : (C) 2003-2011 by Intra2net AG and the libftdi developers
     email                : opensource@intra2net.com
  ***************************************************************************/
 
@@ -1376,19 +1376,22 @@ static void ftdi_write_data_cb(struct libusb_transfer *transfer)
 struct ftdi_transfer_control *ftdi_write_data_submit(struct ftdi_context *ftdi, unsigned char *buf, int size)
 {
     struct ftdi_transfer_control *tc;
-    struct libusb_transfer *transfer = libusb_alloc_transfer(0);
+    struct libusb_transfer *transfer;
     int write_size, ret;
 
     if (ftdi == NULL || ftdi->usb_dev == NULL)
-    {
-        libusb_free_transfer(transfer);
         return NULL;
-    }
 
     tc = (struct ftdi_transfer_control *) malloc (sizeof (*tc));
+    if (!tc)
+        return NULL;
 
-    if (!tc || !transfer)
+    transfer = libusb_alloc_transfer(0);
+    if (!transfer)
+    {
+        free(tc);
         return NULL;
+    }
 
     tc->ftdi = ftdi;
     tc->completed = 0;
@@ -1410,8 +1413,7 @@ struct ftdi_transfer_control *ftdi_write_data_submit(struct ftdi_context *ftdi,
     if (ret < 0)
     {
         libusb_free_transfer(transfer);
-        tc->completed = 1;
-        tc->transfer = NULL;
+        free(tc);
         return NULL;
     }
     tc->transfer = transfer;
@@ -2310,6 +2312,7 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
         case TYPE_2232H:            // six extra config bytes + 4 bytes PnP stuff
         case TYPE_4232H:
             user_area_size = 86;
+            break;
         default:
             user_area_size = 0;
             break;
@@ -2941,7 +2944,6 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose)
                                 "IOMODE","BB_WR","BB_RD"
                                };
             char *cbus_BB[] = {"RXF","TXE","RD", "WR"};
-            int i;
 
             if (eeprom->invert)
             {