Skip to contentSkip to conversation

leds: gpio: Set max brightness to 1

PATCH Superseded [email protected] 1 participant 1 message Dec 27, 2020 LED

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: gpio: Set max brightness to 1

From: Dylan Van Assche <[email protected]>

GPIO LEDs only know 2 states: ON or OFF and do not have PWM capabilities. However, the max brightness is reported as 255.

This patch sets the max brightness value of a GPIO controlled LED to 1.

Tested on my PinePhone 1.2.

---
 drivers/leds/leds-gpio.c | 3 ++-
 include/linux/leds.h     | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/leds/leds-gpio.c +2 -1
index 93f5b1b60fde..0d66f19d71ba 100644
@@ -96,7 +96,8 @@ static int create_gpio_led(const struct gpio_led *template,
 	} else {
 		state = (template->default_state == LEDS_GPIO_DEFSTATE_ON);
 	}
-	led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
+	led_dat->cdev.brightness = state ? LED_ON : LED_OFF;
+	led_dat->cdev.max_brightness = LED_ON;
 	if (!template->retain_state_suspended)
 		led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
 	if (template->panic_indicator)
include/linux/leds.h +1 -0
index 6a8d6409c993..43f0cac2a87b 100644
@@ -514,6 +514,7 @@ struct gpio_led {
 	const char *name;
 	const char *default_trigger;
 	unsigned 	gpio;
+	unsigned	max_brightness;
 	unsigned	active_low : 1;
 	unsigned	retain_state_suspended : 1;
 	unsigned	panic_indicator : 1;
Signature · 1 line
2.26.2