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 | { |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 13 | setUpdateProgress(20); |
| 14 | |
| 15 | // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) |
Christopher Meis | fd34144 | 2025-06-16 14:34:51 +0200 | [diff] [blame] | 16 | if (!(co_await vrInterface->verifyImage(image, imageSize))) |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 17 | // NOLINTEND(clang-analyzer-core.uninitialized.Branch) |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 18 | { |
| 19 | co_return false; |
| 20 | } |
| 21 | |
| 22 | setUpdateProgress(50); |
| 23 | |
| 24 | // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) |
Christopher Meis | fd34144 | 2025-06-16 14:34:51 +0200 | [diff] [blame] | 25 | if (!(co_await vrInterface->updateFirmware(false))) |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 26 | // NOLINTEND(clang-analyzer-core.uninitialized.Branch) |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 27 | { |
| 28 | co_return false; |
| 29 | } |
| 30 | |
| 31 | setUpdateProgress(80); |
| 32 | |
| 33 | // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch) |
Christopher Meis | fd34144 | 2025-06-16 14:34:51 +0200 | [diff] [blame] | 34 | if (!(co_await vrInterface->reset())) |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 35 | // NOLINTEND(clang-analyzer-core.uninitialized.Branch) |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 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 | |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 47 | sdbusplus::async::task<bool> I2CVRDevice::getVersion(uint32_t* sum) const |
Christopher Meis | 7e446a4 | 2024-10-22 09:36:41 +0200 | [diff] [blame] | 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 |