This implements default-state support as described in:
https://www.kernel.org/doc/Documentation/devicetree/bindings/leds/leds-gpio.txt Without this booting the VSATV102 causes the blue "working" led to turn off when the kernel starts up. With this the led (which is turned on by the firmware) stays on since that's the default state specified in the FDT. Expanded the meaning of the led_create_state state parameter in order to implement support for "keep". The original values were: == 0 Off != 0 On The new values are: == -1 don't change / keep current setting == 0 Off != -1 && != 0 On This should have no effect on acpi_asus_attach which only calls led_create_state with state set to 1. Updated acpi_ibm_attach in order to avoid surprises. Differential Revision: https://reviews.freebsd.org/D2615 Submitted by: John Wehle Reviewed by: gonzo, loos
This commit is contained in:
parent
5db06fccd8
commit
3a9ac40382
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=283360
@ -445,7 +445,8 @@ acpi_ibm_attach(device_t dev)
|
||||
|
||||
/* Hook up light to led(4) */
|
||||
if (sc->light_set_supported)
|
||||
sc->led_dev = led_create_state(ibm_led, sc, "thinklight", sc->light_val);
|
||||
sc->led_dev = led_create_state(ibm_led, sc, "thinklight",
|
||||
(sc->light_val ? 1 : 0));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -166,8 +166,10 @@ static int
|
||||
gpioled_attach(device_t dev)
|
||||
{
|
||||
struct gpioled_softc *sc;
|
||||
int state;
|
||||
#ifdef FDT
|
||||
phandle_t node;
|
||||
char *default_state;
|
||||
char *name;
|
||||
#else
|
||||
const char *name;
|
||||
@ -177,10 +179,29 @@ gpioled_attach(device_t dev)
|
||||
sc->sc_dev = dev;
|
||||
sc->sc_busdev = device_get_parent(dev);
|
||||
GPIOLED_LOCK_INIT(sc);
|
||||
|
||||
state = 0;
|
||||
|
||||
#ifdef FDT
|
||||
name = NULL;
|
||||
if ((node = ofw_bus_get_node(dev)) == -1)
|
||||
return (ENXIO);
|
||||
|
||||
if (OF_getprop_alloc(node, "default-state",
|
||||
sizeof(char), (void **)&default_state) != -1) {
|
||||
if (strcasecmp(default_state, "on") == 0)
|
||||
state = 1;
|
||||
else if (strcasecmp(default_state, "off") == 0)
|
||||
state = 0;
|
||||
else if (strcasecmp(default_state, "keep") == 0)
|
||||
state = -1;
|
||||
else {
|
||||
device_printf(dev,
|
||||
"unknown value for default-state in FDT\n");
|
||||
}
|
||||
free(default_state, M_OFWPROP);
|
||||
}
|
||||
|
||||
name = NULL;
|
||||
if (OF_getprop_alloc(node, "label", 1, (void **)&name) == -1)
|
||||
OF_getprop_alloc(node, "name", 1, (void **)&name);
|
||||
#else
|
||||
@ -189,8 +210,8 @@ gpioled_attach(device_t dev)
|
||||
name = NULL;
|
||||
#endif
|
||||
|
||||
sc->sc_leddev = led_create(gpioled_control, sc, name ? name :
|
||||
device_get_nameunit(dev));
|
||||
sc->sc_leddev = led_create_state(gpioled_control, sc, name ? name :
|
||||
device_get_nameunit(dev), state);
|
||||
#ifdef FDT
|
||||
if (name != NULL)
|
||||
free(name, M_OFWPROP);
|
||||
|
@ -293,7 +293,8 @@ led_create_state(led_t *func, void *priv, char const *name, int state)
|
||||
mtx_lock(&led_mtx);
|
||||
sc->dev->si_drv1 = sc;
|
||||
LIST_INSERT_HEAD(&led_list, sc, list);
|
||||
sc->func(sc->private, state != 0);
|
||||
if (state != -1)
|
||||
sc->func(sc->private, state != 0);
|
||||
mtx_unlock(&led_mtx);
|
||||
|
||||
return (sc->dev);
|
||||
|
Loading…
Reference in New Issue
Block a user