regulators: Retry failed I2C operations
A previous commit enhanced the I2CInterface class hierarchy to support
retrying failed I2C operations.
Modify the phosphor-regulators application to utilize this new support.
Specify that failed I2C operations should be retried a maximum of 3
times.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: Ia6b7ce3852f1563a5e9d854ad75e42ec7ca3797b
diff --git a/phosphor-regulators/src/config_file_parser.cpp b/phosphor-regulators/src/config_file_parser.cpp
index 3eecbb6..4bb8bd8 100644
--- a/phosphor-regulators/src/config_file_parser.cpp
+++ b/phosphor-regulators/src/config_file_parser.cpp
@@ -586,8 +586,13 @@
uint8_t address = parseHexByte(addressElement);
++propertyCount;
+ // Verify no invalid properties exist
verifyPropertyCount(element, propertyCount);
- return i2c::create(bus, address, i2c::I2CInterface::InitialState::CLOSED);
+
+ // Create I2CInterface object; retry failed I2C operations a max of 3 times.
+ int maxRetries{3};
+ return i2c::create(bus, address, i2c::I2CInterface::InitialState::CLOSED,
+ maxRetries);
}
std::unique_ptr<I2CWriteBitAction> parseI2CWriteBit(const json& element)