Browse Source

usbutils allow unrounded control transfers

nfactor-troky
Kano 12 years ago
parent
commit
6a0b48a650
  1. 16
      usbutils.c
  2. 2
      usbutils.h

16
usbutils.c

@ -2171,7 +2171,7 @@ int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest @@ -2171,7 +2171,7 @@ int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest
struct timeval tv_start, tv_finish;
#endif
uint32_t *buf = NULL;
int err, i;
int err, i, bufsiz;
USBDEBUG("USB debug: _usb_transfer(%s (nodev=%s),type=%"PRIu8",req=%"PRIu8",value=%"PRIu16",index=%"PRIu16",siz=%d,timeout=%u,cmd=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), request_type, bRequest, wValue, wIndex, siz, timeout, usb_cmdname(cmd));
@ -2185,22 +2185,22 @@ int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest @@ -2185,22 +2185,22 @@ int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest
USBDEBUG("USB debug: @_usb_transfer() data=%s", bin2hex((unsigned char *)data, (size_t)siz));
if (siz > 0) {
siz--;
siz >>= 2;
siz++;
buf = malloc(siz << 2);
bufsiz = siz - 1;
bufsiz >>= 2;
bufsiz++;
buf = malloc(bufsiz << 2);
if (unlikely(!buf))
quit(1, "Failed to malloc in _usb_transfer");
for (i = 0; i < siz; i++)
for (i = 0; i < bufsiz; i++)
buf[i] = htole32(data[i]);
}
USBDEBUG("USB debug: @_usb_transfer() buf=%s", bin2hex((unsigned char *)buf, (size_t)(siz << 2)));
USBDEBUG("USB debug: @_usb_transfer() buf=%s", bin2hex((unsigned char *)buf, (size_t)siz));
STATS_TIMEVAL(&tv_start);
err = libusb_control_transfer(usbdev->handle, request_type,
bRequest, htole16(wValue), htole16(wIndex),
(unsigned char *)buf, (uint16_t)(siz << 2),
(unsigned char *)buf, (uint16_t)siz,
timeout == DEVTIMEOUT ? usbdev->found->timeout : timeout);
STATS_TIMEVAL(&tv_finish);
USB_STATS(cgpu, &tv_start, &tv_finish, err, cmd, SEQ0);

2
usbutils.h

@ -71,7 +71,7 @@ @@ -71,7 +71,7 @@
#define PL2303_VALUE_CTRL (PL2303_CTRL_DTR | PL2303_CTRL_RTS)
#define PL2303_VALUE_LINE 0
#define PL2303_VALUE_LINE0 0x0001c200
#define PL2303_VALUE_LINE1 0x08000000
#define PL2303_VALUE_LINE1 0x080000
#define PL2303_VALUE_LINE_SIZE 7
#define PL2303_VALUE_VENDOR 0

Loading…
Cancel
Save