aboutsummaryrefslogtreecommitdiff
path: root/examples/ezusb.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ezusb.c')
-rw-r--r--examples/ezusb.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/examples/ezusb.c b/examples/ezusb.c
index 6abd47d..4bed12a 100644
--- a/examples/ezusb.c
+++ b/examples/ezusb.c
@@ -139,7 +139,11 @@ static int ezusb_write(libusb_device_handle *device, const char *label,
else
logerror("%s ==> %d\n", label, status);
}
- return (status < 0) ? -EIO : 0;
+ if (status < 0) {
+ errno = EIO;
+ return -1;
+ }
+ return 0;
}
/*
@@ -162,7 +166,11 @@ static int ezusb_read(libusb_device_handle *device, const char *label,
else
logerror("%s ==> %d\n", label, status);
}
- return (status < 0) ? -EIO : 0;
+ if (status < 0) {
+ errno = EIO;
+ return -1;
+ }
+ return 0;
}
/*
@@ -195,7 +203,7 @@ static bool ezusb_cpucs(libusb_device_handle *device, uint32_t addr, bool doRun)
}
/*
- * Send an FX3 jumpt to address command
+ * Send an FX3 jump to address command
* Returns false on error.
*/
static bool ezusb_fx3_jump(libusb_device_handle *device, uint32_t addr)
@@ -514,7 +522,8 @@ static int ram_poke(void *context, uint32_t addr, bool external,
if (external) {
logerror("can't write %u bytes external memory at 0x%08x\n",
(unsigned)len, addr);
- return -EINVAL;
+ errno = EINVAL;
+ return -1;
}
break;
case skip_internal: /* CPU must be running */
@@ -538,7 +547,8 @@ static int ram_poke(void *context, uint32_t addr, bool external,
case _undef:
default:
logerror("bug\n");
- return -EDOM;
+ errno = EDOM;
+ return -1;
}
ctx->total += len;