beaglebone.c: check devpath only once in i2c_init_pre
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
46e5aab56e
commit
0b1ccf526f
@@ -266,9 +266,6 @@ mraa_beaglebone_i2c_init_pre(unsigned int bus)
|
|||||||
|
|
||||||
snprintf(devpath, MAX_SIZE, "/dev/i2c-%u", bus);
|
snprintf(devpath, MAX_SIZE, "/dev/i2c-%u", bus);
|
||||||
|
|
||||||
if (!mraa_file_exist(devpath)) {
|
|
||||||
ret = MRAA_ERROR_INVALID_HANDLE;
|
|
||||||
}
|
|
||||||
if (mraa_file_exist(devpath)) {
|
if (mraa_file_exist(devpath)) {
|
||||||
// Bus 1 doesn't seem to be configurable
|
// Bus 1 doesn't seem to be configurable
|
||||||
if (bus == 0) {
|
if (bus == 0) {
|
||||||
@@ -281,6 +278,7 @@ mraa_beaglebone_i2c_init_pre(unsigned int bus)
|
|||||||
return MRAA_SUCCESS;
|
return MRAA_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
syslog(LOG_ERR, "i2c: Device %s not initialized", devpath);
|
syslog(LOG_ERR, "i2c: Device %s not initialized", devpath);
|
||||||
|
ret = MRAA_ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user