API: Improve glue mid-layer of the API demo application.
- Extend ub_dev_read() and ub_dev_recv() so they return the length actually
read, which allows for better control and error handling (this introduces
additional error code API_ESYSC returned by the glue mid-layer).
- Clean up definitions naming and usage.
- Other minor cosmetics.
Note these changes do not touch the API proper, so the interface between
U-Boot and standalone applications remains unchanged.
Signed-off-by: Rafal Jaworowski <raj@semihalf.com>
diff --git a/api_examples/demo.c b/api_examples/demo.c
index 2510ed8..df9c4bd 100644
--- a/api_examples/demo.c
+++ b/api_examples/demo.c
@@ -43,12 +43,11 @@
int main(int argc, char *argv[])
{
- int rv = 0;
- int h, i, j;
- int devs_no;
+ int rv = 0, h, i, j, devs_no;
struct api_signature *sig = NULL;
ulong start, now;
struct device_info *di;
+ lbasize_t rlen;
if (!api_search_sig(&sig))
return -1;
@@ -96,7 +95,6 @@
if (devs_no == 0)
return -1;
-
printf("\n*** Show devices ***\n");
for (i = 0; i < devs_no; i++) {
test_dump_di(i);
@@ -133,7 +131,7 @@
if ((rv = ub_dev_open(i)) != 0)
errf("open device %d error %d\n", i, rv);
- else if ((rv = ub_dev_read(i, buf, 1, 0)) != 0)
+ else if ((rv = ub_dev_read(i, buf, 1, 0, &rlen)) != 0)
errf("could not read from device %d, error %d\n", i, rv);
else {
printf("Sector 0 dump (512B):\n");