blob: b9242cc4ceadc8b479486493ea6ebda46d46b00d [file] [log] [blame]
Christopher Meis7e446a42024-10-22 09:36:41 +02001#include "i2cvr_device.hpp"
2
3#include <phosphor-logging/lg2.hpp>
4#include <sdbusplus/async.hpp>
5#include <sdbusplus/async/context.hpp>
6
7namespace phosphor::software::i2c_vr::device
8{
9
Christopher Meis7e446a42024-10-22 09:36:41 +020010sdbusplus::async::task<bool> I2CVRDevice::updateDevice(const uint8_t* image,
11 size_t imageSize)
Christopher Meis7e446a42024-10-22 09:36:41 +020012{
Christopher Meis7e446a42024-10-22 09:36:41 +020013 setUpdateProgress(20);
14
15 // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch)
Christopher Meisfd341442025-06-16 14:34:51 +020016 if (!(co_await vrInterface->verifyImage(image, imageSize)))
Christopher Meis7e446a42024-10-22 09:36:41 +020017 // NOLINTEND(clang-analyzer-core.uninitialized.Branch)
Christopher Meis7e446a42024-10-22 09:36:41 +020018 {
19 co_return false;
20 }
21
22 setUpdateProgress(50);
23
24 // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch)
Christopher Meisfd341442025-06-16 14:34:51 +020025 if (!(co_await vrInterface->updateFirmware(false)))
Christopher Meis7e446a42024-10-22 09:36:41 +020026 // NOLINTEND(clang-analyzer-core.uninitialized.Branch)
Christopher Meis7e446a42024-10-22 09:36:41 +020027 {
28 co_return false;
29 }
30
Christopher Meis7e446a42024-10-22 09:36:41 +020031 setUpdateProgress(100);
32
33 lg2::info("Successfully updated VR {NAME}", "NAME", config.configName);
34
35 co_return true;
36}
37
Christopher Meis7e446a42024-10-22 09:36:41 +020038sdbusplus::async::task<bool> I2CVRDevice::getVersion(uint32_t* sum) const
Christopher Meis7e446a42024-10-22 09:36:41 +020039{
40 // NOLINTBEGIN(clang-analyzer-core.uninitialized.Branch)
41 if (!(co_await this->vrInterface->getCRC(sum)))
42 // NOLINTEND(clang-analyzer-core.uninitialized.Branch)
43 {
44 co_return false;
45 }
46 co_return true;
47}
48
49} // namespace phosphor::software::i2c_vr::device