17e446a40SChristopher Meis #include "i2cvr_device.hpp" 27e446a40SChristopher Meis 37e446a40SChristopher Meis #include <phosphor-logging/lg2.hpp> 47e446a40SChristopher Meis #include <sdbusplus/async.hpp> 57e446a40SChristopher Meis #include <sdbusplus/async/context.hpp> 67e446a40SChristopher Meis 77e446a40SChristopher Meis namespace phosphor::software::i2c_vr::device 87e446a40SChristopher Meis { 97e446a40SChristopher Meis 107e446a40SChristopher Meis sdbusplus::async::task<bool> I2CVRDevice::updateDevice(const uint8_t* image, 117e446a40SChristopher Meis size_t imageSize) 127e446a40SChristopher Meis { 137e446a40SChristopher Meis setUpdateProgress(20); 147e446a40SChristopher Meis 157e446a40SChristopher Meis // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) 16*fd34144bSChristopher Meis if (!(co_await vrInterface->verifyImage(image, imageSize))) 177e446a40SChristopher Meis // NOLINTEND(clang-analyzer-core.uninitialized.Branch) 187e446a40SChristopher Meis { 197e446a40SChristopher Meis co_return false; 207e446a40SChristopher Meis } 217e446a40SChristopher Meis 227e446a40SChristopher Meis setUpdateProgress(50); 237e446a40SChristopher Meis 247e446a40SChristopher Meis // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) 25*fd34144bSChristopher Meis if (!(co_await vrInterface->updateFirmware(false))) 267e446a40SChristopher Meis // NOLINTEND(clang-analyzer-core.uninitialized.Branch) 277e446a40SChristopher Meis { 287e446a40SChristopher Meis co_return false; 297e446a40SChristopher Meis } 307e446a40SChristopher Meis 317e446a40SChristopher Meis setUpdateProgress(80); 327e446a40SChristopher Meis 337e446a40SChristopher Meis // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) 34*fd34144bSChristopher Meis if (!(co_await vrInterface->reset())) 357e446a40SChristopher Meis // NOLINTEND(clang-analyzer-core.uninitialized.Branch) 367e446a40SChristopher Meis { 377e446a40SChristopher Meis co_return false; 387e446a40SChristopher Meis } 397e446a40SChristopher Meis 407e446a40SChristopher Meis setUpdateProgress(100); 417e446a40SChristopher Meis 427e446a40SChristopher Meis lg2::info("Successfully updated VR {NAME}", "NAME", config.configName); 437e446a40SChristopher Meis 447e446a40SChristopher Meis co_return true; 457e446a40SChristopher Meis } 467e446a40SChristopher Meis 477e446a40SChristopher Meis sdbusplus::async::task<bool> I2CVRDevice::getVersion(uint32_t* sum) const 487e446a40SChristopher Meis { 497e446a40SChristopher Meis // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) 507e446a40SChristopher Meis if (!(co_await this->vrInterface->getCRC(sum))) 517e446a40SChristopher Meis // NOLINTEND(clang-analyzer-core.uninitialized.Branch) 527e446a40SChristopher Meis { 537e446a40SChristopher Meis co_return false; 547e446a40SChristopher Meis } 557e446a40SChristopher Meis co_return true; 567e446a40SChristopher Meis } 577e446a40SChristopher Meis 587e446a40SChristopher Meis } // namespace phosphor::software::i2c_vr::device 59