From 3eb0a8dbf77a8d6243faa900244f3db4888ab31c Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Mon, 29 Dec 2014 14:41:50 +0000 Subject: [PATCH] i2c: use I2C_FUNCS to store funcs map Signed-off-by: Brendan Le Foll --- include/mraa_internal_types.h | 1 + src/i2c/i2c.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/mraa_internal_types.h b/include/mraa_internal_types.h index 6f097fd..cf37c4c 100644 --- a/include/mraa_internal_types.h +++ b/include/mraa_internal_types.h @@ -59,6 +59,7 @@ struct _i2c { int busnum; /**< the bus number of the /dev/i2c-* device */ int fh; /**< the file handle to the /dev/i2c-* device */ int addr; /**< the address of the i2c slave */ + unsigned long funcs; /*@}*/ }; diff --git a/src/i2c/i2c.c b/src/i2c/i2c.c index 2386827..ba7d051 100644 --- a/src/i2c/i2c.c +++ b/src/i2c/i2c.c @@ -127,6 +127,11 @@ mraa_i2c_init_raw(unsigned int bus) syslog(LOG_ERR, "i2c: Failed to open requested i2c port %s", filepath); } + if (ioctl(dev->fh, I2C_FUNCS, &dev->funcs) < 0) { + syslog(LOG_CRIT, "i2c: Failed to get I2C_FUNC map from device"); + return NULL; + } + if (advance_func->i2c_init_post != NULL) { mraa_result_t ret = advance_func->i2c_init_post(dev); if (ret != MRAA_SUCCESS) {