Fix incorrect LED initial value

If LED is in blink state, `/sys/class/leds/<led_name>/trigger`
contains following:

```
none [timer] heartbeat default-on
```

The format of the content of the trigger attribute is documented as
follows:

> What:        /sys/class/leds/<led>/trigger
> Date:        March 2006
> KernelVersion:    2.6.17
> Contact:    Richard Purdie <rpurdie@rpsys.net>
> Description:
>         Set the trigger for this LED. A trigger is a kernel based source
>         of LED events.
>
>         You can change triggers in a similar manner to the way an IO
>         scheduler is chosen. Trigger specific parameters can appear in
>         /sys/class/leds/<led> once a given trigger is selected. For
>         their documentation see `sysfs-class-led-trigger-*`.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/sysfs-class-led?h=v6.6#n71

That's unfortunately vague, but the "IO scheduler" reference is with
respect to the following:

> What:        /sys/block/<disk>/queue/scheduler
> Date:        October 2004
> Contact:    linux-block@vger.kernel.org
> Description:
>         [RW] When read, this file will display the current and available
>         IO schedulers for this block device. The currently active IO
>         scheduler will be enclosed in [] brackets. Writing an IO
>         scheduler name to this file will switch control of this block
>         device to that new IO scheduler. Note that writing an IO
>         scheduler name to this file will attempt to load that IO
>         scheduler module, if it isn't already present in the system.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/stable/sysfs-block?h=v6.6#n558

So the active trigger in the example at the top should be 'timer'.
However, getTrigger() currently returns "none", which leads to incorrect
results.

In setInitialState() the content of the "brightness" sysfs attribute
is read if the trigger is not "timer" (and it's not as it's "none").
But when LEDs is blinking, the read of `brightness` is undefined as
it may read 0 or 1.

Fixes: https://github.com/openbmc/phosphor-led-sysfs/issues/1

Change-Id: I1e06c2f9dc6511f04ec11aa30ea475f734496a50
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
4 files changed