mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
leds: pwm: Add optional DT property default-brightness
When probing if default LED state is on then default brightness will be applied instead of max brightness. Signed-off-by: George Stark <gnstark@salutedevices.com> Link: https://lore.kernel.org/r/20241105185006.1380166-3-gnstark@salutedevices.com Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
44e04fb8d6
commit
8cb0810183
@ -62,6 +62,20 @@ static int led_pwm_set(struct led_classdev *led_cdev,
|
|||||||
return pwm_apply_might_sleep(led_dat->pwm, &led_dat->pwmstate);
|
return pwm_apply_might_sleep(led_dat->pwm, &led_dat->pwmstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int led_pwm_default_brightness_get(struct fwnode_handle *fwnode,
|
||||||
|
int max_brightness)
|
||||||
|
{
|
||||||
|
unsigned int default_brightness;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = fwnode_property_read_u32(fwnode, "default-brightness",
|
||||||
|
&default_brightness);
|
||||||
|
if (ret < 0 || default_brightness > max_brightness)
|
||||||
|
default_brightness = max_brightness;
|
||||||
|
|
||||||
|
return default_brightness;
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__((nonnull))
|
__attribute__((nonnull))
|
||||||
static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
|
static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
|
||||||
struct led_pwm *led, struct fwnode_handle *fwnode)
|
struct led_pwm *led, struct fwnode_handle *fwnode)
|
||||||
@ -103,7 +117,8 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
|
|||||||
/* set brightness */
|
/* set brightness */
|
||||||
switch (led->default_state) {
|
switch (led->default_state) {
|
||||||
case LEDS_DEFSTATE_ON:
|
case LEDS_DEFSTATE_ON:
|
||||||
led_data->cdev.brightness = led->max_brightness;
|
led_data->cdev.brightness =
|
||||||
|
led_pwm_default_brightness_get(fwnode, led->max_brightness);
|
||||||
break;
|
break;
|
||||||
case LEDS_DEFSTATE_KEEP:
|
case LEDS_DEFSTATE_KEEP:
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user