controller: Heap-allocate LEDs
Do this in preparation for migrating to a single instance of the daemon
whose LED inventory is updated via DBus where the update is triggered by
udev.
Splitting out this work reduces the review complexity of the patch that
rewrites the internals of the daemon.
Signed-off-by: Jayashree Dhanapal <jayashree-d@hcl.com>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I50e58126413514f7a64153f425629142fa5af6d4
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/physical.cpp b/physical.cpp
index 67f0a90..39c1c07 100644
--- a/physical.cpp
+++ b/physical.cpp
@@ -28,13 +28,13 @@
/** @brief Populates key parameters */
void Physical::setInitialState()
{
- assert = led.getMaxBrightness();
- auto trigger = led.getTrigger();
+ assert = led->getMaxBrightness();
+ auto trigger = led->getTrigger();
if (trigger == "timer")
{
// LED is blinking. Get the on and off delays and derive percent duty
- auto delayOn = led.getDelayOn();
- uint16_t periodMs = delayOn + led.getDelayOff();
+ auto delayOn = led->getDelayOn();
+ uint16_t periodMs = delayOn + led->getDelayOff();
auto percentScale = periodMs / 100;
this->dutyOn(delayOn / percentScale);
this->period(periodMs);
@@ -44,7 +44,7 @@
else
{
// Cache current LED state
- auto brightness = led.getBrightness();
+ auto brightness = led->getBrightness();
if (brightness != 0U && assert != 0U)
{
sdbusplus::xyz::openbmc_project::Led::server::Physical::state(
@@ -96,8 +96,8 @@
{
auto value = (action == Action::On) ? assert : deasserted;
- led.setTrigger("none");
- led.setBrightness(value);
+ led->setTrigger("none");
+ led->setBrightness(value);
}
void Physical::blinkOperation()
@@ -120,9 +120,9 @@
auto p = static_cast<unsigned long>(period());
- led.setTrigger("timer");
- led.setDelayOn(p * d / 100UL);
- led.setDelayOff(p * (100UL - d) / 100UL);
+ led->setTrigger("timer");
+ led->setDelayOn(p * d / 100UL);
+ led->setDelayOff(p * (100UL - d) / 100UL);
}
/** @brief set led color property in DBus*/