From ab071e64de3cb9dc7ff33fe0cb9899312aeeac68 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Wed, 11 Jun 2014 10:47:13 +0100 Subject: [PATCH] i2c: make maa_i2c_read always return the length of the read Signed-off-by: Brendan Le Foll --- api/maa/i2c.h | 4 ++-- api/maa/i2c.hpp | 4 ++-- src/i2c/i2c.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/maa/i2c.h b/api/maa/i2c.h index 214737f..374ee1b 100644 --- a/api/maa/i2c.h +++ b/api/maa/i2c.h @@ -85,9 +85,9 @@ maa_result_t maa_i2c_frequency(maa_i2c_context dev, int hz); * @param dev The i2c context * @param data pointer to the byte array to read data in to * @param length max number of bytes to read - * @return Result of operation + * @return length of the read in bytes or 0 */ -maa_result_t maa_i2c_read(maa_i2c_context dev, uint8_t *data, int length); +int maa_i2c_read(maa_i2c_context dev, uint8_t *data, int length); /** * Read a single byte from the i2c context diff --git a/api/maa/i2c.hpp b/api/maa/i2c.hpp index eb480aa..e2dd5c4 100644 --- a/api/maa/i2c.hpp +++ b/api/maa/i2c.hpp @@ -93,9 +93,9 @@ class I2c { * * @param data Buffer to write into * @param length Size of read - * @return Result of operation + * @return length of the read or 0 if failed */ - maa_result_t read(unsigned char * data, int length) { + int read(unsigned char * data, int length) { return maa_i2c_read(m_i2c, data, length); } /** diff --git a/src/i2c/i2c.c b/src/i2c/i2c.c index 0fc39ed..9d21e87 100644 --- a/src/i2c/i2c.c +++ b/src/i2c/i2c.c @@ -78,14 +78,14 @@ maa_i2c_frequency(maa_i2c_context dev, int hz) return MAA_SUCCESS; } -maa_result_t +int maa_i2c_read(maa_i2c_context dev, uint8_t* data, int length) { // this is the read(3) syscall not maa_i2c_read() if (read(dev->fh, data, length) == length) { return length; } - return MAA_ERROR_NO_DATA_AVAILABLE; + return 0; } uint8_t