From: me@dylanvanassche.be
To: pavel@ucw.cz, dmurphy@ti.com, linux-leds@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Dylan Van Assche <me@dylanvanassche.be>
Subject: [PATCH] leds: gpio: Set max brightness to 1
Date: Sun, 27 Dec 2020 15:40:15 +0100 [thread overview]
Message-ID: <20201227144014.6590-1-me@dylanvanassche.be> (raw)
From: Dylan Van Assche <me@dylanvanassche.be>
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.
Signed-off-by: Dylan Van Assche <me@dylanvanassche.be>
---
drivers/leds/leds-gpio.c | 3 ++-
include/linux/leds.h | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 93f5b1b60fde..0d66f19d71ba 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -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)
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 6a8d6409c993..43f0cac2a87b 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -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;
--
2.26.2
reply other threads:[~2020-12-27 14:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201227144014.6590-1-me@dylanvanassche.be \
--to=me@dylanvanassche.be \
--cc=dmurphy@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.