eeprom: update pt5161l getVersion()

Add a step to read fw_load_status before fetching the firmware
version. This ensures the service only proceeds when the device
reports a normal status.

Test on Harma:
```
<7> Host state xyz.openbmc_project.State.Host.HostState.Running matches to retrieve the version
<3> Status from file: /sys/kernel/debug/pt5161l/21-0024/fw_load_status is invalid: abnormal
<7> Host state xyz.openbmc_project.State.Host.HostState.Running matches to retrieve the version
<7> Device version is ready
<7> Harma_MB_Retimer_0_2251: set version 2.8.19
<7> Device version is ready
<7> Harma_MB_Retimer_1_8040: set version 2.8.19
```

Change-Id: I7b665652d8bee20956da3e3d15ff1d222560a656
Signed-off-by: Daniel Hsu <Daniel-Hsu@quantatw.com>
diff --git a/eeprom-device/eeprom_device.cpp b/eeprom-device/eeprom_device.cpp
index 41cfea2..f89292b 100644
--- a/eeprom-device/eeprom_device.cpp
+++ b/eeprom-device/eeprom_device.cpp
@@ -370,6 +370,7 @@
 
 sdbusplus::async::task<> EEPROMDevice::processHostStateChange()
 {
+    constexpr int maxRetries = 15;
     auto requiredHostState = deviceVersion->getHostStateToQueryVersion();
 
     if (!requiredHostState)
@@ -383,7 +384,7 @@
         auto nextResult = co_await hostPower.stateChangedMatch.next<
             std::string, std::map<std::string, std::variant<std::string>>>();
 
-        auto [interfaceName, changedProperties] = nextResult;
+        const auto& [interfaceName, changedProperties] = nextResult;
 
         auto it = changedProperties.find("CurrentHostState");
         if (it != changedProperties.end())
@@ -393,10 +394,22 @@
             if (currentHostState ==
                 State::convertForMessage(*requiredHostState))
             {
+                auto isDeviceReady = false;
                 debug("Host state {STATE} matches to retrieve the version",
                       "STATE", currentHostState);
+                for (int i = 0; i < maxRetries; ++i)
+                {
+                    isDeviceReady = deviceVersion->isDeviceReady();
+                    if (isDeviceReady)
+                    {
+                        debug("Device version is ready");
+                        break;
+                    }
+                    co_await sdbusplus::async::sleep_for(
+                        ctx, std::chrono::seconds(2));
+                }
                 std::string version = deviceVersion->getVersion();
-                if (!version.empty())
+                if (isDeviceReady && !version.empty())
                 {
                     softwareCurrent->setVersion(
                         version,