jtag_libusb_bulk_read|write: return error code instead of size
[fw/openocd] / src / jtag / drivers / usb_blaster / ublast2_access_libusb.c
index 70dab20d58a3561108a33ece50bb597257c366eb..fb1e4440a5a4aa89ba23daa05e38d6f18b8fad23 100644 (file)
@@ -13,6 +13,9 @@
  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *   GNU General Public License for more details.
  *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
  */
 
 #ifdef HAVE_CONFIG_H
 static int ublast2_libusb_read(struct ublast_lowlevel *low, uint8_t *buf,
                              unsigned size, uint32_t *bytes_read)
 {
-       *bytes_read = jtag_libusb_bulk_read(low->libusb_dev,
+       int ret, tmp = 0;
+
+       ret = jtag_libusb_bulk_read(low->libusb_dev,
                                            USBBLASTER_EPIN | \
                                            LIBUSB_ENDPOINT_IN,
                                            (char *)buf,
                                            size,
-                                           100);
-       return ERROR_OK;
+                                           100, &tmp);
+       *bytes_read = tmp;
+
+       return ret;
 }
 
 static int ublast2_libusb_write(struct ublast_lowlevel *low, uint8_t *buf,
                               int size, uint32_t *bytes_written)
 {
-       *bytes_written = jtag_libusb_bulk_write(low->libusb_dev,
+       int ret, tmp = 0;
+
+       ret = jtag_libusb_bulk_write(low->libusb_dev,
                                                USBBLASTER_EPOUT | \
                                                LIBUSB_ENDPOINT_OUT,
                                                (char *)buf,
                                                size,
-                                               100);
-       return ERROR_OK;
+                                               100, &tmp);
+       *bytes_written = tmp;
+
+       return ret;
+
 }
 
 static int ublast2_write_firmware_section(struct jtag_libusb_device_handle *libusb_dev,
@@ -74,9 +86,6 @@ static int ublast2_write_firmware_section(struct jtag_libusb_device_handle *libu
        LOG_DEBUG("section %02i at addr 0x%04x (size 0x%04x)", section_index, addr,
                size);
 
-       if (data == NULL)
-               return ERROR_FAIL;
-
        /* Copy section contents to local buffer */
        int ret = image_read_section(firmware_image, section_index, 0, size, data,
                        &size_read);