summaryrefslogtreecommitdiff
path: root/api_examples/demo.c
diff options
context:
space:
mode:
authorRafal Jaworowski <raj@semihalf.com>2009-01-23 13:27:18 +0100
committerWolfgang Denk <wd@denx.de>2009-02-18 00:39:44 +0100
commit923aa48126259c13de95131203f1d28bfa5cb889 (patch)
treeaa1c893363a1fcfa6a3611d3fcb7bd72dbbcbc05 /api_examples/demo.c
parent44a94e596ba0f6d0951b165403c520bf55b1c56f (diff)
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>
Diffstat (limited to 'api_examples/demo.c')
-rw-r--r--api_examples/demo.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/api_examples/demo.c b/api_examples/demo.c
index 2510ed8866..df9c4bd8bc 100644
--- a/api_examples/demo.c
+++ b/api_examples/demo.c
@@ -43,12 +43,11 @@ static char buf[BUF_SZ];
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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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");