Repository navigation
base-files: support parse DT LED color and function - #13837
DragonBluep wants to merge 2 commits into
Conversation
|
Hi! @csharper2005 Perhaps you are interested in these patches. I think we can finally remove all LED labels from the device tree (include those referenced in aliases node). |
| #define LED_FUNCTION_FLASH "flash" | ||
| #define LED_FUNCTION_HEARTBEAT "heartbeat" | ||
| #define LED_FUNCTION_INDICATOR "indicator" | ||
| +#define LED_FUNCTION_INTERNET "internet" |
There was a problem hiding this comment.
Another function that makes sense IMHO to have is cellular connectivity (LTE, 5G, etc).
There was a problem hiding this comment.
The patch has already been sent to the mailing list so we need another patch to add it. I think it can be later.
There was a problem hiding this comment.
Would be nice also get mesh function.
+#define LED_FUNCTION_MESH "mesh"
|
The pending patch should not be difficult to accept, although it may take some time. This PR can be reviewed now. |
|
(edited the entire message, mostly reordering sentences) These are two unrelated commits. Why have a combined PR for both? The main commit is specific to OpenWrt, and is required to drop the label property from several (all?) DTS LEDs. The other commit is an upstream patch, and should address IMHO the other missing function (cellular/modem/LTE/5g) too, so I sent a message to the kernel mailing list about these. |
We have to sync the LED colors with the upstream to ensure that we don't need to edit this script again. It unlikely to add any new colors.
If reviewers say it's okay, I'd like to extend the patch to include more functions.
If red > yellow, It's amber, else orange. Purple is the mixture of the blue and red. Violet is the pure 'purple'. All monochrome LEDs are violet. Anyway, they are not very different. |
This PR is fine by me then.
I messed up with the email (responded to an earlier version of the patch, and used gmail so did not respect the thread order) so it will probably be ignored :/
This is defined anywhere? I'm just thinking of people adding support for LEDs in the future, and picking a color at random. |
| drivers/leds/led-core.c | 5 +++++ | ||
| 1 file changed, 5 insertions(+) | ||
|
|
||
| (limited to 'drivers/leds/led-core.c') |
There was a problem hiding this comment.
please generate this from the full commit
There was a problem hiding this comment.
Fixed. The diff parts are the same. torvalds/linux@a067943
Openwrt supports hundreds of devices. These newly added LED colors and functions can help developers better describe LED indicators. Signed-off-by: Shiji Yang <[email protected]>
| "purple" "orange" "pink" "cyan" "lime" | ||
| do | ||
| [ $idx -eq 0 ] && label="$color" && break | ||
| idx=$(($idx-1)) |
There was a problem hiding this comment.
Shellchecker found this.
idx=$(($idx-1))
^-- [SC2004](https://www.shellcheck.net/wiki/SC2004) (style): $/${} is unnecessary on arithmetic variables.
``
| [ -e "$1/function-enumerator" ] && \ | ||
| enum=$((0x$(hexdump -n 4 -e '4/1 "%02x"' "$1/function-enumerator"))) | ||
|
|
||
| [ -z "$idx" -o -z "$func" ] && return 2 |
There was a problem hiding this comment.
shellchecker:
[ -z "$idx" -o -z "$func" ] && return 2
^-- [SC2166](https://www.shellcheck.net/wiki/SC2166) (warning): Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
There was a problem hiding this comment.
Thanks for your review. I searched the Linux led code and found that one of function and color property could be missing. So I changed some logic to match this behavior. I haven't tested the new changes yet, but it shouldn't have introduced any other errors.
The git force-push diff:
https://github.com/openwrt/openwrt/compare/9d2262c4fc44fa253b7f65da12d5fee5168c1476..ac049e3ab5adc5ff025d466c382da931846745e3
There was a problem hiding this comment.
Test result shows all LEDs still work.
dts:
aliases {
led-boot = &led_status_red;
led-failsafe = &led_status_blue;
led-running = &led_status_yellow;
led-upgrade = &led_status_blue;
};
leds {
compatible = "gpio-leds";
led_status_blue: led-blue {
color = <LED_COLOR_ID_BLUE>;
gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
};
led_status_red: led-red {
function = LED_FUNCTION_STATUS;
function-enumerator = <0>;
gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
};
led_status_yellow: led-yellow {
color = <LED_COLOR_ID_YELLOW>;
function = LED_FUNCTION_STATUS;
function-enumerator = <100>;
gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
};
};
root@OpenWrt:~# ls /sys/class/leds/
:status-0 mt76-phy0 rt2800soc-phy1::quality yellow:status-100
blue: rt2800soc-phy1::assoc rt2800soc-phy1::radio
root@OpenWrt:~# ls /sys/firmware/devicetree/base/leds/led-blue/
color gpios name
root@OpenWrt:~# ls /sys/firmware/devicetree/base/leds/led-red/
function function-enumerator gpios name
root@OpenWrt:~# ls /sys/firmware/devicetree/base/leds/led-yellow/
color function function-enumerator gpios name
chunkeey
left a comment
There was a problem hiding this comment.
Thanks! Tested it, it works.
|
@chunkeey once the shellchecker comments are fixed, who's allowed to merge this? are responsibilities somehow partitioned between the different devs with commit access? |
According to the rules https://openwrt.org/rules all committers have such rights. Other factors may be at play: e.g. lack of time, information to fully assess the changes. |
The 'label' property in led node has been deprecated and we'd better to avoid using it. This patch allows us to extract DT OF LED name from the newly introduced LED properties "color", "function" and "function-enumerator". Signed-off-by: Shiji Yang <[email protected]>
|
Merged. Thanks! |
|
Thanks a lot for working on this solution. I was looking for a way of matching color + function to generated label but I wasn't sure how to handle that. FWIW I sent an e-mail to DT and LEDs developers asking if there is an option for upstream binding describing LED's function. No answer so far but I'm keep an eye on that |
The 'label' property in led node has been deprecated and we'd better to avoid using it. This patch allows us to extract DT OF LED name from the newly introduced LED properties "color", "function" and "function-enumerator".