diff options
author | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> | 2015-12-11 10:59:25 +0000 |
---|---|---|
committer | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> | 2015-12-11 12:00:12 +0000 |
commit | 5cd87078a8cb65ff1c16bed1758ded1f5a6fa214 (patch) | |
tree | a088f475da832b0c7e5f081b817d73f1e8de6455 | |
parent | 4a3eb32b66cda8ca5faf8de0688b5da9b121601d (diff) |
mraa: i2c: make use of no_bus_mux flag
This patch makes use of no_bus_mux flag in mraa_board_t to skip
unnessary mux checks.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
-rw-r--r-- | src/i2c/i2c.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/i2c/i2c.c b/src/i2c/i2c.c index c9dcda4..1e0a2fb 100644 --- a/src/i2c/i2c.c +++ b/src/i2c/i2c.c @@ -161,20 +161,21 @@ mraa_i2c_init(int bus) syslog(LOG_ERR, "Invalid i2c bus, moving to default i2c bus"); bus = board->def_i2c_bus; } - - int pos = board->i2c_bus[bus].sda; - if (board->pins[pos].i2c.mux_total > 0) { - if (mraa_setup_mux_mapped(board->pins[pos].i2c) != MRAA_SUCCESS) { - syslog(LOG_ERR, "i2c: Failed to set-up i2c sda multiplexer"); - return NULL; + if (!board->no_bus_mux) { + int pos = board->i2c_bus[bus].sda; + if (board->pins[pos].i2c.mux_total > 0) { + if (mraa_setup_mux_mapped(board->pins[pos].i2c) != MRAA_SUCCESS) { + syslog(LOG_ERR, "i2c: Failed to set-up i2c sda multiplexer"); + return NULL; + } } - } - - pos = board->i2c_bus[bus].scl; - if (board->pins[pos].i2c.mux_total > 0) { - if (mraa_setup_mux_mapped(board->pins[pos].i2c) != MRAA_SUCCESS) { - syslog(LOG_ERR, "i2c: Failed to set-up i2c scl multiplexer"); - return NULL; + + pos = board->i2c_bus[bus].scl; + if (board->pins[pos].i2c.mux_total > 0) { + if (mraa_setup_mux_mapped(board->pins[pos].i2c) != MRAA_SUCCESS) { + syslog(LOG_ERR, "i2c: Failed to set-up i2c scl multiplexer"); + return NULL; + } } } |