Prevent updating power cap sysfs file when OCC not active
The power cap can be updated at any time, but occ-control should only
update the sysfs files when the OCCs are active.
Also prevent sending pass through commands when OCC is not
active.
Change-Id: I7e5d5ad0b897b55a00e4d07c62b917aa62b7f9ef
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/powercap.cpp b/powercap.cpp
index cac7465..65d8998 100644
--- a/powercap.cpp
+++ b/powercap.cpp
@@ -172,6 +172,12 @@
// This will trigger the driver to send the cap to the OCC
void PowerCap::writeOcc(uint32_t pcapValue)
{
+ if (!occStatus.occActive())
+ {
+ // OCC not running, skip update
+ return;
+ }
+
// Build the hwmon string to write the user power cap
fs::path fileName = getPcapFilename(std::regex{"power\\d+_cap_user$"});
if (fileName.empty())