jtag_libusb_bulk_read|write: return error code instead of size
[fw/openocd] / src / jtag / drivers / usb_blaster / ublast2_access_libusb.c
index ac863918cb724e3f821ef8ea52b13629b4375216..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,