1*7e446a40SChristopher Meis #include "i2cvr_device.hpp" 2*7e446a40SChristopher Meis 3*7e446a40SChristopher Meis #include <phosphor-logging/lg2.hpp> 4*7e446a40SChristopher Meis #include <sdbusplus/async.hpp> 5*7e446a40SChristopher Meis #include <sdbusplus/async/context.hpp> 6*7e446a40SChristopher Meis 7*7e446a40SChristopher Meis namespace phosphor::software::i2c_vr::device 8*7e446a40SChristopher Meis { 9*7e446a40SChristopher Meis 10*7e446a40SChristopher Meis // NOLINTBEGIN(readability-static-accessed-through-instance) 11*7e446a40SChristopher Meis sdbusplus::async::task<bool> I2CVRDevice::updateDevice(const uint8_t* image, 12*7e446a40SChristopher Meis size_t imageSize) 13*7e446a40SChristopher Meis // NOLINTEND(readability-static-accessed-through-instance) 14*7e446a40SChristopher Meis { 15*7e446a40SChristopher Meis bool ret = false; 16*7e446a40SChristopher Meis setUpdateProgress(20); 17*7e446a40SChristopher Meis 18*7e446a40SChristopher Meis // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) 19*7e446a40SChristopher Meis ret = co_await vrInterface->verifyImage(image, imageSize); 20*7e446a40SChristopher Meis // NOLINTEND(clang-analyzer-core.uninitialized.Branch) 21*7e446a40SChristopher Meis if (!ret) 22*7e446a40SChristopher Meis { 23*7e446a40SChristopher Meis co_return false; 24*7e446a40SChristopher Meis } 25*7e446a40SChristopher Meis 26*7e446a40SChristopher Meis setUpdateProgress(50); 27*7e446a40SChristopher Meis 28*7e446a40SChristopher Meis // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) 29*7e446a40SChristopher Meis ret = co_await vrInterface->updateFirmware(false); 30*7e446a40SChristopher Meis // NOLINTEND(clang-analyzer-core.uninitialized.Branch) 31*7e446a40SChristopher Meis if (!ret) 32*7e446a40SChristopher Meis { 33*7e446a40SChristopher Meis co_return false; 34*7e446a40SChristopher Meis } 35*7e446a40SChristopher Meis 36*7e446a40SChristopher Meis setUpdateProgress(80); 37*7e446a40SChristopher Meis 38*7e446a40SChristopher Meis // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) 39*7e446a40SChristopher Meis ret = co_await vrInterface->reset(); 40*7e446a40SChristopher Meis // NOLINTEND(clang-analyzer-core.uninitialized.Branch) 41*7e446a40SChristopher Meis if (!ret) 42*7e446a40SChristopher Meis { 43*7e446a40SChristopher Meis co_return false; 44*7e446a40SChristopher Meis } 45*7e446a40SChristopher Meis 46*7e446a40SChristopher Meis setUpdateProgress(100); 47*7e446a40SChristopher Meis 48*7e446a40SChristopher Meis lg2::info("Successfully updated VR {NAME}", "NAME", config.configName); 49*7e446a40SChristopher Meis 50*7e446a40SChristopher Meis co_return true; 51*7e446a40SChristopher Meis } 52*7e446a40SChristopher Meis 53*7e446a40SChristopher Meis // NOLINTBEGIN(readability-static-accessed-through-instance) 54*7e446a40SChristopher Meis sdbusplus::async::task<bool> I2CVRDevice::getVersion(uint32_t* sum) const 55*7e446a40SChristopher Meis // NOLINTEND(readability-static-accessed-through-instance) 56*7e446a40SChristopher Meis { 57*7e446a40SChristopher Meis // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) 58*7e446a40SChristopher Meis if (!(co_await this->vrInterface->getCRC(sum))) 59*7e446a40SChristopher Meis // NOLINTEND(clang-analyzer-core.uninitialized.Branch) 60*7e446a40SChristopher Meis { 61*7e446a40SChristopher Meis co_return false; 62*7e446a40SChristopher Meis } 63*7e446a40SChristopher Meis co_return true; 64*7e446a40SChristopher Meis } 65*7e446a40SChristopher Meis 66*7e446a40SChristopher Meis } // namespace phosphor::software::i2c_vr::device 67