summaryrefslogtreecommitdiffstats
path: root/cpukit/dev/i2c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-23 09:00:31 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-23 09:00:31 +0200
commit08135c85d8e868f7eaf9cebeb356fd1b2816995f (patch)
tree6255927c9bdcf7bf3f6c2f7ad0644c8b302e35c3 /cpukit/dev/i2c
parent19078dc6e60010002498e455d2b6a39fd9160ba4 (diff)
downloadrtems-08135c85d8e868f7eaf9cebeb356fd1b2816995f.tar.bz2
i2c: Fix return status of i2c dev read/write
Diffstat (limited to 'cpukit/dev/i2c')
-rw-r--r--cpukit/dev/i2c/i2c-dev.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/cpukit/dev/i2c/i2c-dev.c b/cpukit/dev/i2c/i2c-dev.c
index 6710632e87..b00a9bdf21 100644
--- a/cpukit/dev/i2c/i2c-dev.c
+++ b/cpukit/dev/i2c/i2c-dev.c
@@ -43,11 +43,13 @@ static ssize_t i2c_dev_read(
ssize_t n;
n = (*dev->read)(dev, buffer, count, iop->offset);
- if (n > 0) {
+ if (n >= 0) {
iop->offset += n;
- }
- return n;
+ return n;
+ } else {
+ rtems_set_errno_and_return_minus_one(-n);
+ }
}
static ssize_t i2c_dev_write(
@@ -60,11 +62,13 @@ static ssize_t i2c_dev_write(
ssize_t n;
n = (*dev->write)(dev, buffer, count, iop->offset);
- if (n > 0) {
+ if (n >= 0) {
iop->offset += n;
- }
- return n;
+ return n;
+ } else {
+ rtems_set_errno_and_return_minus_one(-n);
+ }
}
static int i2c_dev_ioctl(