Simplify libusb_fill_control_transfer()

Transfer length can be inferred from the setup packet.
This commit is contained in:
Daniel Drake 2008-03-10 11:32:15 +00:00
parent 7c5ea95297
commit aae05f688d
3 changed files with 10 additions and 10 deletions

View file

@ -168,8 +168,7 @@ static void cb_mode_changed(struct libusb_transfer *transfer)
static int set_mode_async(unsigned char data)
{
int bufsize = LIBUSB_CONTROL_SETUP_SIZE + 1;
unsigned char *buf = malloc(bufsize);
unsigned char *buf = malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
struct libusb_transfer *transfer;
if (!buf)
@ -184,8 +183,8 @@ static int set_mode_async(unsigned char data)
printf("async set mode %02x\n", data);
libusb_fill_control_setup(buf, CTRL_OUT, USB_RQ, 0x4e, 0, 1);
buf[LIBUSB_CONTROL_SETUP_SIZE] = data;
libusb_fill_control_transfer(transfer, devh, buf, bufsize,
cb_mode_changed, NULL, 1000);
libusb_fill_control_transfer(transfer, devh, buf, cb_mode_changed, NULL,
1000);
return libusb_submit_transfer(transfer);
}