History log of /openbmc/phosphor-led-sysfs/physical.cpp (Results 1 – 22 of 22)
Revision Date Author Comments
# e48bf95d 17-Aug-2022 Jayashree Dhanapal <jayashree-d@hcl.com>

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 t

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>

show more ...


# 001e2a3d 01-Dec-2023 George Liu <liuxiwei@ieisystem.com>

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 trigge

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>

show more ...


# 8e85228c 06-Feb-2023 Andrew Jeffery <andrew@aj.id.au>

sysfs: Fix several clang-tidy issues

* cppcoreguidelines-avoid-c-arrays
* cppcoreguidelines-pro-bounds-array-to-pointer-decay
* readability-identifier-naming

```
../sysfs.hpp:45:28: error: do not d

sysfs: Fix several clang-tidy issues

* cppcoreguidelines-avoid-c-arrays
* cppcoreguidelines-pro-bounds-array-to-pointer-decay
* readability-identifier-naming

```
../sysfs.hpp:45:28: error: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]
static constexpr const char BRIGHTNESS[] = "brightness";
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:45:33: error: invalid case style for variable 'BRIGHTNESS' [readability-identifier-naming,-warnings-as-errors]
static constexpr const char BRIGHTNESS[] = "brightness";
^~~~~~~~~~
brightness
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:46:28: error: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]
static constexpr const char MAX_BRIGHTNESS[] = "max_brightness";
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:46:33: error: invalid case style for variable 'MAX_BRIGHTNESS' [readability-identifier-naming,-warnings-as-errors]
static constexpr const char MAX_BRIGHTNESS[] = "max_brightness";
^~~~~~~~~~~~~~
maxBrightness
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:47:28: error: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]
static constexpr const char TRIGGER[] = "trigger";
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:47:33: error: invalid case style for variable 'TRIGGER' [readability-identifier-naming,-warnings-as-errors]
static constexpr const char TRIGGER[] = "trigger";
^~~~~~~
trigger
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:48:28: error: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]
static constexpr const char DELAY_ON[] = "delay_on";
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:48:33: error: invalid case style for variable 'DELAY_ON' [readability-identifier-naming,-warnings-as-errors]
static constexpr const char DELAY_ON[] = "delay_on";
^~~~~~~~
delayOn
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:49:28: error: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]
static constexpr const char DELAY_OFF[] = "delay_off";
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:49:33: error: invalid case style for variable 'DELAY_OFF' [readability-identifier-naming,-warnings-as-errors]
static constexpr const char DELAY_OFF[] = "delay_off";
^~~~~~~~~
delayOff
../test/sysfs.cpp:62:46: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
std::array<const char *, 4> attrs = {BRIGHTNESS, TRIGGER, DELAY_ON, DELAY_OFF};
^
../test/sysfs.cpp:62:58: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
std::array<const char *, 4> attrs = {BRIGHTNESS, TRIGGER, DELAY_ON, DELAY_OFF};
^
../test/sysfs.cpp:62:67: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
std::array<const char *, 4> attrs = {BRIGHTNESS, TRIGGER, DELAY_ON, DELAY_OFF};
^
../test/sysfs.cpp:62:77: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
std::array<const char *, 4> attrs = {BRIGHTNESS, TRIGGER, DELAY_ON, DELAY_OFF};
^
```

Change-Id: I1df5f9b9f6a8c2073a0bc04ea5f88c580e2cb1b9
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...


# dce1e205 06-Feb-2023 Andrew Jeffery <andrew@aj.id.au>

physical: Fix bugprone-narrowing-conversions

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:138:14: error: narrowing conversion from 'int' to signed type '__gnu_cxx::__alloc_t

physical: Fix bugprone-narrowing-conversions

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:138:14: error: narrowing conversion from 'int' to signed type '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' (aka 'char') is implementation-defined [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions,-warnings-as-errors]
tmp[0] = toupper(tmp[0]);
^
```

Change-Id: I58c9a47008272b856427419557dc3e592936b5eb
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...


# 826ba7b6 05-Feb-2023 Andrew Jeffery <andrew@aj.id.au>

physical: Fix readability-braces-around-statements

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:135:25: error: statement should be inside braces [readability-braces-around-s

physical: Fix readability-braces-around-statements

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:135:25: error: statement should be inside braces [readability-braces-around-statements,-warnings-as-errors]
if (!color.length())
^
{
```

Change-Id: I7ac2e39c4a1b32e08df0161adfb305c25b968873
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...


# 263c0561 05-Feb-2023 Andrew Jeffery <andrew@aj.id.au>

physical: Fix readability-implicit-bool-conversion

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:135:10: error: implicit conversion 'std::basic_string<char>::size_type' (aka

physical: Fix readability-implicit-bool-conversion

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:135:10: error: implicit conversion 'std::basic_string<char>::size_type' (aka 'unsigned long') -> bool [readability-implicit-bool-conversion,-warnings-as-errors]
if (!color.length())
~^
== 0u
```

Change-Id: I0bb5e13bec6fbe8b21a89af695ca8f9535e3cdab
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...


# 7782f0d6 05-Feb-2023 Andrew Jeffery <andrew@aj.id.au>

physical: Fix bugprone-narrowing-conversions

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:120:20: error: narrowing conversion from 'double' to 'unsigned long' [bugprone-narr

physical: Fix bugprone-narrowing-conversions

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:120:20: error: narrowing conversion from 'double' to 'unsigned long' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions,-warnings-as-errors]
led.setDelayOn(dutyOn * factor);
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:121:21: error: narrowing conversion from 'double' to 'unsigned long' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions,-warnings-as-errors]
led.setDelayOff((100 - dutyOn) * factor);
^
```

Change-Id: Ic7dbacac3b636a209a743063182d324165bbbaa1
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...


# 305e3b76 05-Feb-2023 Andrew Jeffery <andrew@aj.id.au>

physical: Fix readability-redundant-control-flow

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:57:5: error: redundant return statement at the end of a function with a void re

physical: Fix readability-redundant-control-flow

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:57:5: error: redundant return statement at the end of a function with a void return type [readability-redundant-control-flow,-warnings-as-errors]
return;
^~~~~~~
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:100:5: error: redundant return statement at the end of a function with a void return type [readability-redundant-control-flow,-warnings-as-errors]
return;
~~~~^~~~~~~
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:123:5: error: redundant return statement at the end of a function with a void return type [readability-redundant-control-flow,-warnings-as-errors]
return;
~~~~^~~~~~~
```

Change-Id: I58bf70aa3d565a0449e4c0a85b271512a0cf9742
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...


# e3719f44 05-Feb-2023 Andrew Jeffery <andrew@aj.id.au>

physical: Fix readability-implicit-bool-conversion

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:46:13: error: implicit conversion 'unsigned long' -> bool [readability-implic

physical: Fix readability-implicit-bool-conversion

```
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:46:13: error: implicit conversion 'unsigned long' -> bool [readability-implicit-bool-conversion,-warnings-as-errors]
if (brightness && assert)
^
( != 0u)
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../physical.cpp:46:27: error: implicit conversion 'unsigned long' -> bool [readability-implicit-bool-conversion,-warnings-as-errors]
if (brightness && assert)
^
( != 0u)
```

Change-Id: I556d7d24cd1bd6372285d58c78fd1b17339b2ebe
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...


# a48f76d2 26-Mar-2021 Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

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, t

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>

show more ...


# db21bc00 26-Mar-2021 Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

Add test cases to validate state of physical LED

This commit adds code that verifies the state of
physical LED is appropriately set in various cases

Change-Id: I9eab752f6f2b47e719934c14ef95e775d36b

Add test cases to validate state of physical LED

This commit adds code that verifies the state of
physical LED is appropriately set in various cases

Change-Id: I9eab752f6f2b47e719934c14ef95e775d36bcaa0
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

show more ...


# 9e500aa8 22-Apr-2019 tony lee <tony.lee@quantatw.com>

Fix an issue and read Period from D-bus

1. Change the order of setTrigger(), setDelayOn() and setDelayOff(),
because delay_on and delay_off were only displayed after the setTrigger() was excuted.

Fix an issue and read Period from D-bus

1. Change the order of setTrigger(), setDelayOn() and setDelayOff(),
because delay_on and delay_off were only displayed after the setTrigger() was excuted.

2. Read Period from D-bus instead of "periodMs = 1000" when the blinkOperation() was excuted.

Change-Id: Ia1ed328aa986be9ccc4072a4a5b48da4a07978db
Signed-off-by: tony lee <tony.lee@quantatw.com>

show more ...


# 97ddb723 16-Apr-2019 Alexander Soldatov <a.soldatov@yadro.com>

Add ability to set LED colors in DBus

phosphor-led-sysfs parses sysfs LED node names
in the form of "devicename:colour:function" as
described in

https://github.com/torvalds/linux/blob/master/Docume

Add ability to set LED colors in DBus

phosphor-led-sysfs parses sysfs LED node names
in the form of "devicename:colour:function" as
described in

https://github.com/torvalds/linux/blob/master/Documentation/leds/leds-class.txt#L46

and then converts the "colour" part into the proper
value of the DBus 'Color' property using the
xyz.openbmc_project.Led.Physical.Palette interface.

In order for the led nodes to have their Color set,
the corresponding led nodes in devicetree must have
correct 'label' properties, e.g.:

leds {
compatible = "gpio-leds";

heartbeat {
label = "bmc:green:hearbeat";
gpios = <&gpio ASPEED_GPIO(R, 4) GPIO_ACTIVE_LOW>;
};
power_red {
label = "system:red:power";
gpios = <&gpio ASPEED_GPIO(N, 1) GPIO_ACTIVE_LOW>;
};
}

Change-Id: I094f0e434bdd262995752576a3c792ccd5dbb3e2
Signed-off-by: Alexander Soldatov <a.soldatov@yadro.com>
Signed-off-by: Alexander Amelkin <a.amelkin@yadro.com>

show more ...


# 5b1417bd 18-Mar-2019 Andrew Jeffery <andrew@aj.id.au>

physical: Conform to LED class kernel ABI

The kernel says the following about the LED sysfs interface:

> LED handling under Linux
> ========================
>
> In its simplest form, the LED class

physical: Conform to LED class kernel ABI

The kernel says the following about the LED sysfs interface:

> LED handling under Linux
> ========================
>
> In its simplest form, the LED class just allows control of LEDs from
> userspace. LEDs appear in /sys/class/leds/. The maximum brightness of the
> LED is defined in max_brightness file. The brightness file will set the brightness
> of the LED (taking a value 0-max_brightness). Most LEDs don't have hardware
> brightness support so will just be turned on for non-zero brightness settings.

The existing code assumed that max_brightness always held a value of
255 and defined a constant for it. Instead, use a class variable to
cache the max brightness for the associated LED.

Change-Id: I2d8f46de0cddac5f9d8ff5444449518bb4056130
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...


# 2332e91f 25-May-2018 Andrew Jeffery <andrew@aj.id.au>

physical: Avoid unreachable statement in driveLED()

This also slightly improves the branch coverage statistics

Change-Id: I27d5168994831789a8f8dafeecc843242a7e406a
Signed-off-by: Andrew Jeffery <an

physical: Avoid unreachable statement in driveLED()

This also slightly improves the branch coverage statistics

Change-Id: I27d5168994831789a8f8dafeecc843242a7e406a
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>

show more ...


# bf0b0a92 25-May-2018 Andrew Jeffery <andrew@aj.id.au>

physical: Cleanup unnecessary variables

Change-Id: Ib5897e4f7226993c2deb1feb6e2e39d5a0f0cb5a
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>


# 30552c95 25-May-2018 Andrew Jeffery <andrew@aj.id.au>

physical: Rework commentary for brevity

Change-Id: I84341c6418853ad7fb44aa6f02ab298cc70842f6
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>


# e5c40fea 25-May-2018 Andrew Jeffery <andrew@aj.id.au>

physical: 'frequency' is really periodicity

Change-Id: I1007d2a7104fa07351c89c52a860cde83b2d509c
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>


# 42e02d34 23-May-2018 Andrew Jeffery <andrew@aj.id.au>

sysfs: Integrate class into Physical and tests

Change-Id: I7d5ad19df5ef1258a4e669ea3243b7411f371d9c
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>


# c41bf5b7 25-May-2018 Andrew Jeffery <andrew@aj.id.au>

Add OpenBMC C++ clang-format file and format code

Change-Id: Ib3a388bf5392159440682265b577fba023c3c3aa
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>


# 61675c32 30-Nov-2016 Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

Add methods to trigger action on LED

Implements the ON, OFF and BLINK operations on a given LED.

Change-Id: I74b5ac01d8e76961999a2673d52d73296f5603d7
Signed-off-by: Vishwanatha Subbanna <vishwa@lin

Add methods to trigger action on LED

Implements the ON, OFF and BLINK operations on a given LED.

Change-Id: I74b5ac01d8e76961999a2673d52d73296f5603d7
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

show more ...


# 75b5510f 30-Nov-2016 Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

Add overriding methods for the base interface definition

Defines the functions that override the default setter for
the led state property.

Change-Id: Ic3a8d43cc783003c43f53df8f7e90d7fc4d6715a
Sign

Add overriding methods for the base interface definition

Defines the functions that override the default setter for
the led state property.

Change-Id: Ic3a8d43cc783003c43f53df8f7e90d7fc4d6715a
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>

show more ...