hwmontempsensor: Fix DBus update value after power on issue

HwmontempSensor failed to update value on DBus interface when the
state changes from off to on and these sensors are static sensors
(sensor filesystem created from device-tree setting). When the
condition is satisfied "findI2CDev == devices.end()", it does not
activate those sensors that already exist.

To fix this we move this condition to 'findI2CDev != devices.end()'.
Only check the status of activateOnly and isActive() to make sure these
sensors can be activated after power on.

Tested:
Before
```
root@qbmc:~# ipmitool power status
Chassis Power is on
root@qbmc:~# busctl get-property xyz.openbmc_project.HwmonTempSensor /xyz/openbmc_project/sensors/temperature/cputemp xyz.openbmc_project.Sensor.Value Value
d 36.625

root@qbmc:~# ipmitool power off
Chassis Power Control: Down/Off
root@qbmc:~# ipmitool power status
Chassis Power is off
root@qbmc:~# busctl get-property xyz.openbmc_project.HwmonTempSensor /xyz/openbmc_project/sensors/temperature/cputemp xyz.openbmc_project.Sensor.Value Value
d nan

root@qbmc:~# ipmitool power on
Chassis Power Control: Up/On
root@qbmc:~# ipmitool power status
Chassis Power is on
root@qbmc:~# busctl get-property xyz.openbmc_project.HwmonTempSensor /xyz/openbmc_project/sensors/temperature/cputemp xyz.openbmc_project.Sensor.Value Value
d nan
```

After
Power on this device which was already there, it can get value from
dbus property.
```
root@qbmc:~# ipmitool power status
Chassis Power is on
root@qbmc:~# busctl get-property xyz.openbmc_project.HwmonTempSensor /xyz/openbmc_project/sensors/temperature/cputemp xyz.openbmc_project.Sensor.Value Value
d 36.5
root@qbmc:~# busctl get-property xyz.openbmc_project.HwmonTempSensor /xyz/openbmc_project/sensors/temperature/cputemp xyz.openbmc_project.Sensor.Value Value
d 36.625
```

Signed-off-by: Joseph Fu <joseph.fu@quantatw.com>
Change-Id: Ic99c1f2dd292ab99656df06228210d3c714e27d5
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index 27b28d5..1621f5a 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -407,20 +407,16 @@
             const std::string& interfacePath = findSensorCfg->second.sensorPath;
             auto findI2CDev = devices.find(interfacePath);
 
-            // If we're only looking to activate newly-instantiated i2c
-            // devices and this sensor's underlying device either (a) wasn't
-            // found (e.g. because it's a static device and not a dynamic one
-            // whose lifetime we're managing) or (b) was already there before
-            // this call, there's nothing more to do here.
-            if (activateOnly &&
-                (findI2CDev == devices.end() || !findI2CDev->second.second))
-            {
-                continue;
-            }
-
             std::shared_ptr<I2CDevice> i2cDev;
             if (findI2CDev != devices.end())
             {
+                // If we're only looking to activate newly-instantiated i2c
+                // devices and this sensor's underlying device was already there
+                // before this call, there's nothing more to do here.
+                if (activateOnly && !findI2CDev->second.second)
+                {
+                    continue;
+                }
                 i2cDev = findI2CDev->second.first;
             }