From c008cbfc1a4c916d70047fc8adcaa52a0b49f007 Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Tue, 16 Mar 2021 08:55:33 +0100 Subject: [PATCH] added break if chip found and passes not found messages as debug_printf when probing --- driver_pcal6416a.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/driver_pcal6416a.c b/driver_pcal6416a.c index a6d0c28..ae73591 100755 --- a/driver_pcal6416a.c +++ b/driver_pcal6416a.c @@ -62,18 +62,20 @@ bool pcal6416a_init(void) { // ERROR HANDLING; you can check errno to see what went wrong return false; } + + /// Probing known I2C GPIO expander chips for (i = 0, i2c_expander_addr = 0; i2c_chip[i].address; i++) { - /// Probing I2C GPIO expander chip if (ioctl(fd_i2c_expander, I2C_SLAVE_FORCE, i2c_chip[i]) < 0 || pcal6416a_read_mask_interrupts() < 0) { - printf("In %s - Failed to acquire bus access and/or talk to slave %s at address 0x%02X.\n", + DEBUG_PRINTF("In %s - Failed to acquire bus access and/or talk to slave %s at address 0x%02X.\n", __func__, i2c_chip[i].name, i2c_chip[i].address); - } else { - DEBUG_PRINTF("Found I2C gpio expander chip %s at address 0x%02X\n", - i2c_chip[i].name, i2c_chip[i].address); - i2c_expander_addr = i2c_chip[i].address; - } + } else { + DEBUG_PRINTF("Found I2C gpio expander chip %s at address 0x%02X\n", + i2c_chip[i].name, i2c_chip[i].address); + i2c_expander_addr = i2c_chip[i].address; + break; + } } /// GPIO expander chip found?