utils/ingenic_tools: correct return check of libusb_control_transfer in usbboot

libusb_control_transfer returns <0 for errors,
0 is success without any bytes, read and ret >0
is the amount if bytes read.

Tested command: sudo ./usbboot --vid 0xa108 --pid 0x1000 --cpuinfo
Before:
Can't get CPU info: 8

After:
CPU info: X1000_v1

Change-Id: Ied6d430406239ea4f99e7c83274d99ae4c555899
This commit is contained in:
John Zimmermann 2026-09-16 15:38:26 +02:00 • committed by Solomon Peachy
parent dd164cadb1
commit 0a0b877dc2

View file

@ -103,7 +103,7 @@ void jz_get_cpu_info(void)
int ret = libusb_control_transfer(g_usb_dev, int ret = libusb_control_transfer(g_usb_dev,
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
VR_GET_CPU_INFO, 0, 0, buf, 8, 1000); VR_GET_CPU_INFO, 0, 0, buf, 8, 1000);
if(ret != 0) if(ret < 0)
die("Can't get CPU info: %d", ret); die("Can't get CPU info: %d", ret);
buf[8] = 0; buf[8] = 0;
@ -172,7 +172,7 @@ void jz_download(const char* filename)
int ret = libusb_control_transfer(g_usb_dev, \ int ret = libusb_control_transfer(g_usb_dev, \
LIBUSB_ENDPOINT_OUT|LIBUSB_REQUEST_TYPE_VENDOR|LIBUSB_RECIPIENT_DEVICE, \ LIBUSB_ENDPOINT_OUT|LIBUSB_REQUEST_TYPE_VENDOR|LIBUSB_RECIPIENT_DEVICE, \
VR_##type, param >> 16, param & 0xffff, NULL, 0, 1000); \ VR_##type, param >> 16, param & 0xffff, NULL, 0, 1000); \
if(ret != 0) \ if(ret < 0) \
die("Request " #type " failed: %d", ret); \ die("Request " #type " failed: %d", ret); \
} }