Fix an error scenario where reading the file fails

When ledcontroller starts, it looks at sysfs entries to
populate its initial D-Bus values. In the case where the
read error's out for any reason, the code sets the initial
state as On

This patch fixes that scenario by putting the default to Off.
Also, this patch will enable a usecase where one wants
to have virtual physical LEDs that are not backed by file system

Tested:

/tmp/phosphor-ledcontroller -p /sys/class/leds/virtual/foo/led &

busctl get-property xyz.openbmc_project.LED.Controller.virtual_foo_led
/xyz/openbmc_project/led/physical/virtual_foo_led
xyz.openbmc_project.Led.Physical State
s "xyz.openbmc_project.Led.Physical.Action.Off"

busctl set-property xyz.openbmc_project.LED.Controller.virtual_foo_led
/xyz/openbmc_project/led/physical/virtual_foo_led
xyz.openbmc_project.Led.Physical State
s "xyz.openbmc_project.Led.Physical.Action.Blink"

busctl get-property xyz.openbmc_project.LED.Controller.virtual_foo_led
/xyz/openbmc_project/led/physical/virtual_foo_led
xyz.openbmc_project.Led.Physical State
s "xyz.openbmc_project.Led.Physical.Action.Blink"

Change-Id: If4c880902a62939197129fc3b7ce8a73f2a7d137
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
1 file changed