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