i2c: add busnum to context
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -56,6 +56,7 @@ struct _gpio {
|
|||||||
*/
|
*/
|
||||||
struct _i2c {
|
struct _i2c {
|
||||||
/*@{*/
|
/*@{*/
|
||||||
|
int busnum; /**< the bus number of the /dev/i2c-* device */
|
||||||
int fh; /**< the file handle to the /dev/i2c-* device */
|
int fh; /**< the file handle to the /dev/i2c-* device */
|
||||||
int addr; /**< the address of the i2c slave */
|
int addr; /**< the address of the i2c slave */
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ mraa_i2c_init_raw(unsigned int bus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char filepath[32];
|
char filepath[32];
|
||||||
|
dev->busnum = bus;
|
||||||
snprintf(filepath, 32, "/dev/i2c-%u", bus);
|
snprintf(filepath, 32, "/dev/i2c-%u", bus);
|
||||||
if ((dev->fh = open(filepath, O_RDWR)) < 1) {
|
if ((dev->fh = open(filepath, O_RDWR)) < 1) {
|
||||||
syslog(LOG_ERR, "i2c: Failed to open requested i2c port %s", filepath);
|
syslog(LOG_ERR, "i2c: Failed to open requested i2c port %s", filepath);
|
||||||
|
|||||||
Reference in New Issue
Block a user