diff options
author | Mihai Tudor Panu <mihai.tudor.panu@intel.com> | 2015-12-01 11:48:36 +0000 |
---|---|---|
committer | Brendan Le Foll <brendan.le.foll@intel.com> | 2015-12-01 12:01:25 +0000 |
commit | efc79d13c0e150e965c0cfd0fb6b736b6572016c (patch) | |
tree | f190fb90d080fd1b34439665317648f4cb280f4f | |
parent | e8cb060f4ea15b49f458beee57dc47e88bf0b8f6 (diff) |
i2c.c: Fix identation/style and simplify logic in mraa_i2c_read
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
-rw-r--r-- | src/i2c/i2c.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/i2c/i2c.c b/src/i2c/i2c.c index 972ef2e..c9dcda4 100644 --- a/src/i2c/i2c.c +++ b/src/i2c/i2c.c @@ -120,7 +120,7 @@ mraa_i2c_init_internal(mraa_adv_func_t* advance_func, unsigned int bus) init_internal_cleanup: if (status == MRAA_SUCCESS) { return dev; - } else { + } else { if (dev != NULL) free(dev); return NULL; @@ -202,14 +202,17 @@ int mraa_i2c_read(mraa_i2c_context dev, uint8_t* data, int length) { int bytes_read = 0; - if (IS_FUNC_DEFINED(dev, i2c_read_replace)) + if (IS_FUNC_DEFINED(dev, i2c_read_replace)) { bytes_read = dev->advance_func->i2c_read_replace(dev, data, length); - else + } + else { bytes_read = read(dev->fh, data, length); - if (bytes_read == length) - return length; - else - return 0; + } + if (bytes_read == length) { + return length; + } + + return 0; } uint8_t |