misc: Update read() and write() methods to return bytes xfered

At present these functions return 0 on success. For some devices we want
to know how many bytes were transferred. It seems useful to adjust the API
to be more like the POSIX read() and write() functions.

Update these two methods, a test and all users.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
This commit is contained in:
Simon Glass
2018-11-06 15:21:39 -07:00
parent 96794a3eae
commit 8729b1ae2c
8 changed files with 27 additions and 15 deletions

View File

@@ -21,9 +21,9 @@ static int dm_test_misc(struct unit_test_state *uts)
ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "misc-test", &dev));
/* Read / write tests */
ut_assertok(misc_write(dev, 0, "TEST", 4));
ut_assertok(misc_write(dev, 4, "WRITE", 5));
ut_assertok(misc_read(dev, 0, buf, 9));
ut_asserteq(4, misc_write(dev, 0, "TEST", 4));
ut_asserteq(5, misc_write(dev, 4, "WRITE", 5));
ut_asserteq(9, misc_read(dev, 0, buf, 9));
ut_assertok(memcmp(buf, "TESTWRITE", 9));