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