All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniil Demakov <t3127430@gmail.com>
To: lee@kernel.org
Cc: pavel@kernel.org, griffin@kroah.com, linux-leds@vger.kernel.org,
	Daniil Demakov <t3127430@gmail.com>
Subject: [PATCH] leds: tps6105x: add brightness_get callback
Date: Sun, 29 Nov 2026 09:20:17 +0000	[thread overview]
Message-ID: <20261129092017.41185-1-t3127430@gmail.com> (raw)

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


             reply	other threads:[~2026-11-29  9:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  9:20 Daniil Demakov [this message]
2026-11-29  9:26 ` [PATCH] leds: tps6105x: add brightness_get callback sashiko-bot

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=20261129092017.41185-1-t3127430@gmail.com \
    --to=t3127430@gmail.com \
    --cc=griffin@kroah.com \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    /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.