summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKlemens Nanni <kn@cvs.openbsd.org>2021-11-07 16:43:13 +0000
committerKlemens Nanni <kn@cvs.openbsd.org>2021-11-07 16:43:13 +0000
commitc4c4d50c51a344b4ae31a9a0e4bedc9adcb86717 (patch)
treeb6ac6da057d029f5580a6e9d6e7b32a0347c8700 /sys
parent59f934354af2b4225483ed0541fe36ef88382b85 (diff)
Fall back to label if function is missing
The "label" property is obsolete and "function" should be used, but devices like the Raspberry Pi 4b still use it. Detect LEDs on such machines: -gpioleds0 at mainbus0: no LEDs +gpioleds0 at mainbus0: "led0", "led1" OK patrick
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/fdt/gpioleds.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/dev/fdt/gpioleds.c b/sys/dev/fdt/gpioleds.c
index 626c0846195..6a58344ac8b 100644
--- a/sys/dev/fdt/gpioleds.c
+++ b/sys/dev/fdt/gpioleds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gpioleds.c,v 1.2 2021/11/07 16:40:30 kn Exp $ */
+/* $OpenBSD: gpioleds.c,v 1.3 2021/11/07 16:43:12 kn Exp $ */
/*
* Copyright (c) 2021 Klemens Nanni <kn@openbsd.org>
*
@@ -60,15 +60,20 @@ gpioleds_attach(struct device *parent, struct device *self, void *aux)
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, struct device *self, void *aux)
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);