From b2e8af641b5a3a83a7060f6cad95e27905680938 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Fri, 11 Dec 2015 16:26:16 +0000 Subject: [PATCH] i2c.c: 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 Signed-off-by: Brendan Le Foll --- src/i2c/i2c.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/i2c/i2c.c b/src/i2c/i2c.c index c9dcda4..18303c0 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; + } } } -- 2.7.4