Test found:
/Sys/devices/platform/keyboard-backlight/LEDs/keyboard-Backlight
/Sys/class/LEDs/keyboard-Backlight
Cat brightness is always 0 at each boot, regardless of whether the LED is on.
The status of each boot keyboard led depends on the status of the last shutdown.
Driver path kernel/Drivers/LEDs/leds-sprd-kb.c
The driver does not implement the brightness_get callback function:
LED-> cdev. brightness_get = NULL;
This causes no LED-> cdev. before brightness_set is called, the value of cat brightness is always 0, and only once led-> cdev. after brightness_set and then Cat brightness, you can get the value you just set.
Why can't I get the value for the first time, but it can be obtained later? This takes a look at the implementation of these sys files, as well as the corresponding show and store functions, see: kernel/Drivers/LEDs/leds-class.c
Static ssize_t led_brightness_show (struct device * Dev,
Struct device_attribute * ATTR, char * BUF)
{
Struct led_classdev * led_cdev = dev_get_drvdata (Dev );
/* No lock needed for this */
Led_update_brightness (led_cdev );
Return sprintf (BUF, "% u \ n", led_cdev-> brightness );
}
The led_update_brightness function updates brightness Based on the get function implemented by the driver, but our driver does not implement this function. Therefore, this update function does not work. So brightness is always 0 at the first read.