Commit e85fecf8 authored by Dave Gateman's avatar Dave Gateman Committed by Alejandro Mery
Browse files

fel: Add useful error messages to perror()

libusb doesn't set errno, so we get ": Success" on errors
parent 915c888d
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <endian.h> #include <endian.h>
#include <errno.h>
int errno;
struct aw_usb_request { struct aw_usb_request {
char signature[8]; char signature[8];
...@@ -50,6 +53,7 @@ void usb_bulk_send(libusb_device_handle *usb, int ep, const void *data, int leng ...@@ -50,6 +53,7 @@ void usb_bulk_send(libusb_device_handle *usb, int ep, const void *data, int leng
while (length > 0) { while (length > 0) {
rc = libusb_bulk_transfer(usb, ep, (void *)data, length, &sent, 1000); rc = libusb_bulk_transfer(usb, ep, (void *)data, length, &sent, 1000);
if (rc != 0) { if (rc != 0) {
errno = EIO;
perror("usb send"); perror("usb send");
exit(2); exit(2);
} }
...@@ -64,6 +68,7 @@ void usb_bulk_recv(libusb_device_handle *usb, int ep, void *data, int length) ...@@ -64,6 +68,7 @@ void usb_bulk_recv(libusb_device_handle *usb, int ep, void *data, int length)
while (length > 0) { while (length > 0) {
rc = libusb_bulk_transfer(usb, ep, data, length, &recv, 1000); rc = libusb_bulk_transfer(usb, ep, data, length, &recv, 1000);
if (rc != 0) { if (rc != 0) {
errno = EIO;
perror("usb recv"); perror("usb recv");
exit(2); exit(2);
} }
...@@ -285,6 +290,7 @@ int main(int argc, char **argv) ...@@ -285,6 +290,7 @@ int main(int argc, char **argv)
handle = libusb_open_device_with_vid_pid(NULL, 0x1f3a, 0xefe8); handle = libusb_open_device_with_vid_pid(NULL, 0x1f3a, 0xefe8);
if (!handle) { if (!handle) {
errno = ENODEV;
perror("A10 USB FEL device not found!"); perror("A10 USB FEL device not found!");
exit(1); exit(1);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment