Some device trees such as on my Raspberry Pi 4b use the deprecated
"label" property rather than "function".
Fall back to it such that LEDs won't be skipped:
-gpioleds0 at mainbus0: no LEDs
+gpioleds0 at mainbus0: "led0", "led1"
OK?
Index: gpioleds.c
===================================================================
RCS file: /cvs/src/sys/dev/fdt/gpioleds.c,v
retrieving revision 1.1
diff -u -p -r1.1 gpioleds.c
--- gpioleds.c 25 Sep 2021 10:43:24 -0000 1.1
+++ gpioleds.c 3 Nov 2021 18:41:44 -0000
@@ -60,15 +60,20 @@ gpioleds_attach(struct device *parent, s
struct fdt_attach_args *faa = aux;
uint32_t *led_pin;
char *function, *default_state;
+ char *function_prop = "function";
int function_len, default_state_len, gpios_len;
int node, leds = 0;
pinctrl_byname(faa->fa_node, "default");
for (node = OF_child(faa->fa_node); node; node = OF_peer(node)) {
- function_len = OF_getproplen(node, "function");
- if (function_len <= 0)
- continue;
+ function_len = OF_getproplen(node, function_prop);
+ if (function_len <= 0) {
+ function_prop = "label";
+ function_len = OF_getproplen(node, function_prop);
+ if (function_len <= 0)
+ continue;
+ }
default_state_len = OF_getproplen(node, "default-state");
if (default_state_len <= 0)
continue;
@@ -77,7 +82,7 @@ gpioleds_attach(struct device *parent, s
continue;
function = malloc(function_len, M_TEMP, M_WAITOK);
- OF_getprop(node, "function", function, function_len);
+ OF_getprop(node, function_prop, function, function_len);
default_state = malloc(default_state_len, M_TEMP, M_WAITOK);
OF_getprop(node, "default-state", default_state,
default_state_len);
led_pin = malloc(gpios_len, M_TEMP, M_WAITOK);
@@ -94,9 +99,7 @@ gpioleds_attach(struct device *parent, s
free(led_pin, M_TEMP, gpios_len);
}
- if (leds == 0) {
- printf(": no LEDs\n");
- return;
- }
+ if (leds == 0)
+ printf(": no LEDs");
printf("\n");
}