This makes it clearer than we mean to initialize the variable to
0 before _each_ libusb_bulk_transfer() call.
static int read_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len)
{
int ret;
static int read_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len)
{
int ret;
ret = libusb_bulk_transfer(dev->usb_device, 0x81, buffer, len, &transferred, 0);
if (ret != 0 || (unsigned int)transferred != len) {
error(dev->ctx, "%s. Transferred: %d (expected %u)\n",
ret = libusb_bulk_transfer(dev->usb_device, 0x81, buffer, len, &transferred, 0);
if (ret != 0 || (unsigned int)transferred != len) {
error(dev->ctx, "%s. Transferred: %d (expected %u)\n",
static int send_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len)
{
int ret;
static int send_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len)
{
int ret;
trace_dump_buffer(dev->ctx, "sending -->", buffer, len);
trace_dump_buffer(dev->ctx, "sending -->", buffer, len);
ret = libusb_bulk_transfer(dev->usb_device, 0x1, buffer, len, &transferred, 0);
if (ret != 0 || (unsigned int)transferred != len) {
error(dev->ctx, "%s. Transferred: %d (expected %u)\n",
ret = libusb_bulk_transfer(dev->usb_device, 0x1, buffer, len, &transferred, 0);
if (ret != 0 || (unsigned int)transferred != len) {
error(dev->ctx, "%s. Transferred: %d (expected %u)\n",