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