Private
Public Access
2
0

i2c.c: Fix return value of mraa_i2c_write in error cases

ioctl() returns -1 on error, or otherwise a value certainly not within the
mraa_result_t enum. Fixes #480.

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2016-03-28 04:16:39 +01:00
parent 52f9c48bbc
commit a218056905

View File

@@ -298,7 +298,10 @@ mraa_i2c_write(mraa_i2c_context dev, const uint8_t* data, int length)
}
d.block[0] = length;
return mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command, I2C_SMBUS_I2C_BLOCK_DATA, &d);
if (mraa_i2c_smbus_access(dev->fh, I2C_SMBUS_WRITE, command, I2C_SMBUS_I2C_BLOCK_DATA, &d) < 0) {
return MRAA_ERROR_INVALID_HANDLE;
}
return MRAA_SUCCESS;
}
mraa_result_t