Add reaped URB error checking
This commit is contained in:
parent
c8736296c3
commit
a739b4b856
@ -282,6 +282,9 @@ void bootloader_command(uint8_t req[8])
|
|||||||
ret = ioctl(bootloader_fd, USBDEVFS_REAPURB, &reaped_urb);
|
ret = ioctl(bootloader_fd, USBDEVFS_REAPURB, &reaped_urb);
|
||||||
syscall_error(ret < 0, "USBDEVFS_REAPURB failed");
|
syscall_error(ret < 0, "USBDEVFS_REAPURB failed");
|
||||||
|
|
||||||
|
if (urb.status != 0)
|
||||||
|
error("URB failed with status=%s (%d)", strerror(urb.status), urb.status);
|
||||||
|
|
||||||
debug("CMD:");
|
debug("CMD:");
|
||||||
for (int i = 0; i < urb.actual_length; i++)
|
for (int i = 0; i < urb.actual_length; i++)
|
||||||
debug(" %02hhx", req[i]);
|
debug(" %02hhx", req[i]);
|
||||||
@ -307,6 +310,11 @@ void bootloader_status(uint8_t res[4])
|
|||||||
ret = ioctl(bootloader_fd, USBDEVFS_REAPURB, &reaped_urb);
|
ret = ioctl(bootloader_fd, USBDEVFS_REAPURB, &reaped_urb);
|
||||||
syscall_error(ret < 0, "USBDEVFS_REAPURB failed");
|
syscall_error(ret < 0, "USBDEVFS_REAPURB failed");
|
||||||
|
|
||||||
|
if (urb.status != 0)
|
||||||
|
error("URB failed with status=%s (%d)", strerror(urb.status), urb.status);
|
||||||
|
if (urb.actual_length != 4)
|
||||||
|
error("Status response too short, must be 4 bytes, got %d", urb.actual_length);
|
||||||
|
|
||||||
debug("RES:");
|
debug("RES:");
|
||||||
for (int i = 0; i < urb.actual_length; i++)
|
for (int i = 0; i < urb.actual_length; i++)
|
||||||
debug(" %02hhx", res[i]);
|
debug(" %02hhx", res[i]);
|
||||||
@ -387,6 +395,11 @@ int bootloader_read_data(uint8_t res[64])
|
|||||||
debug(" %02hhx", res[i]);
|
debug(" %02hhx", res[i]);
|
||||||
debug("\n");
|
debug("\n");
|
||||||
|
|
||||||
|
if (urb.status != 0)
|
||||||
|
error("URB failed with status=%s (%d)", strerror(urb.status), urb.status);
|
||||||
|
if (urb.actual_length != 64)
|
||||||
|
error("Data response too short, must be 64 bytes, got %d", urb.actual_length);
|
||||||
|
|
||||||
return urb.actual_length;
|
return urb.actual_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,6 +423,9 @@ void bootloader_write_data(uint8_t res[64])
|
|||||||
ret = ioctl(bootloader_fd, USBDEVFS_REAPURB, &reaped_urb);
|
ret = ioctl(bootloader_fd, USBDEVFS_REAPURB, &reaped_urb);
|
||||||
syscall_error(ret < 0, "USBDEVFS_REAPURB failed");
|
syscall_error(ret < 0, "USBDEVFS_REAPURB failed");
|
||||||
|
|
||||||
|
if (urb.status != 0)
|
||||||
|
error("URB failed with status=%s (%d)", strerror(urb.status), urb.status);
|
||||||
|
|
||||||
debug("DATA:");
|
debug("DATA:");
|
||||||
for (int i = 0; i < urb.actual_length; i++)
|
for (int i = 0; i < urb.actual_length; i++)
|
||||||
debug(" %02hhx", res[i]);
|
debug(" %02hhx", res[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user