i2c: add busnum to context
authorBrendan Le Foll <brendan.le.foll@intel.com>
Wed, 10 Dec 2014 00:33:34 +0000 (00:33 +0000)
committerBrendan Le Foll <brendan.le.foll@intel.com>
Mon, 5 Jan 2015 14:38:49 +0000 (14:38 +0000)
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
include/mraa_internal_types.h
src/i2c/i2c.c

index 8c5e747..6f097fd 100644 (file)
@@ -56,6 +56,7 @@ struct _gpio {
  */
 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 */
     /*@}*/
index 1dc5f67..b44e41f 100644 (file)
@@ -119,6 +119,7 @@ mraa_i2c_init_raw(unsigned int bus)
     }
 
     char filepath[32];
+    dev->busnum = bus;
     snprintf(filepath, 32, "/dev/i2c-%u", bus);
     if ((dev->fh = open(filepath, O_RDWR)) < 1) {
         syslog(LOG_ERR, "i2c: Failed to open requested i2c port %s", filepath);