Linux LED subsystem development
 help / color / mirror / Atom feed
* [PATCH] leds: tps6105x: add brightness_get callback
@ 2026-11-29  9:20 Daniil Demakov
  2026-11-29  9:26 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Daniil Demakov @ 2026-11-29  9:20 UTC (permalink / raw)
  To: lee; +Cc: pavel, griffin, linux-leds, Daniil Demakov

Read the torch current setting from the hardware register when the LED

core requests the current brightness. Keep the reported brightness in

sync with the device state.

Signed-off-by: Daniil Demakov <t3127430@gmail.com>
---
 drivers/leds/leds-tps6105x.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/leds/leds-tps6105x.c b/drivers/leds/leds-tps6105x.c
index 71418fc28cd6..ea62b37efe33 100644
--- a/drivers/leds/leds-tps6105x.c
+++ b/drivers/leds/leds-tps6105x.c
@@ -33,6 +33,22 @@ static int tps6105x_brightness_set(struct led_classdev *cdev,
 				  brightness << TPS6105X_REG0_TORCHC_SHIFT);
 }
 
+static enum led_brightness tps6105x_brightness_get(struct led_classdev *cdev)
+{
+	struct tps6105x_priv *priv = container_of(cdev, struct tps6105x_priv,
+							cdev);
+	unsigned int reg;
+	int ret;
+
+	ret = regmap_read(priv->regmap, TPS6105X_REG_0, &reg);
+
+	if (ret)
+		return ret;
+
+	return (reg & TPS6105X_REG0_TORCHC_MASK) >>
+		TPS6105X_REG0_TORCHC_SHIFT;
+}
+
 static int tps6105x_led_probe(struct platform_device *pdev)
 {
 	struct tps6105x *tps6105x = dev_get_platdata(&pdev->dev);
@@ -58,6 +74,7 @@ static int tps6105x_led_probe(struct platform_device *pdev)
 		return ret;
 	priv->regmap = tps6105x->regmap;
 	priv->cdev.brightness_set_blocking = tps6105x_brightness_set;
+	priv->cdev.brightness_get = tps6105x_brightness_get;
 	priv->cdev.max_brightness = 7;
 	init_data.devicename = "tps6105x";
 	init_data.default_label = ":torch";
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-29  9:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29  9:20 [PATCH] leds: tps6105x: add brightness_get callback Daniil Demakov
2026-11-29  9:26 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox