mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ruslan Koreev <koreev.r@gmail.com>
To: lee@kernel.org, pavel@kernel.org, rillian.grant@gmail.com
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ruslan Koreev <koreev.r@gmail.com>
Subject: [PATCH 1/2] leds: flash: lm3643: Return to standby when the last output is switched off
Date: Thu, 24 Sep 2026 20:20:39 +0300	[thread overview]
Message-ID: <20260924172040.1185688-2-koreev.r@gmail.com> (raw)
In-Reply-To: <20260924172040.1185688-1-koreev.r@gmail.com>

Setting the torch brightness of an output to 0 only cleared its enable
bit and left the mode bits at torch (or flash), so the chip kept its
boost converter running with no output enabled. Likewise switching the
strobe off returned early when the output's enable bit had already been
cleared, leaving the mode bits at flash. Both were flagged by the
Sashiko review of the RFC, which Lee Jones asked to have addressed.

Clear the mode bits together with the enable bit whenever the sibling
output is not active, so that the chip goes back to standby when its
last output is switched off.

Signed-off-by: Ruslan Koreev <koreev.r@gmail.com>
---
 drivers/leds/flash/leds-lm3643.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/flash/leds-lm3643.c b/drivers/leds/flash/leds-lm3643.c
index 48e164261..bbe9358c9 100644
--- a/drivers/leds/flash/leds-lm3643.c
+++ b/drivers/leds/flash/leds-lm3643.c
@@ -271,9 +271,15 @@ static int lm3643_torch_set_brightness(struct led_classdev *led_cdev,
 	    mode != LM3643_MODE_TORCH)
 		return -EBUSY;
 
-	if (brightness == 0)
-		return regmap_update_bits(led->regmap, LM3643_REG_ENABLE,
-				chan->enable_bit, 0);
+	if (brightness == 0) {
+		unsigned int mask = chan->enable_bit;
+
+		/* Last active output: leave torch mode, back to standby */
+		if (!(enable & sibling_bit))
+			mask |= LM3643_MODE_MASK;
+
+		return regmap_update_bits(led->regmap, LM3643_REG_ENABLE, mask, 0);
+	}
 
 	ret = regmap_update_bits(led->regmap, chan->torch_br_reg, LM3643_TORCH_BR_MASK,
 				 LM3643_TORCH_BR_CDEV_TO_CODE(brightness));
@@ -365,11 +371,16 @@ static int lm3643_flash_strobe_set(struct led_classdev_flash *fled_cdev, bool st
 	mode = enable_reg & LM3643_MODE_MASK;
 
 	if (!state) {
-		if (mode != LM3643_MODE_FLASH || !(enable_reg & chan->enable_bit))
+		unsigned int mask = chan->enable_bit;
+
+		if (mode != LM3643_MODE_FLASH)
 			return 0;
 
-		return regmap_update_bits(led->regmap, LM3643_REG_ENABLE,
-			LM3643_MODE_MASK, LM3643_MODE_STANDBY);
+		/* Leave flash mode once no other output is strobing */
+		if (!(enable_reg & sibling_bit))
+			mask |= LM3643_MODE_MASK;
+
+		return regmap_update_bits(led->regmap, LM3643_REG_ENABLE, mask, 0);
 	}
 	if ((enable_reg & sibling_bit) && mode != LM3643_MODE_STANDBY)
 		return -EBUSY;
-- 
2.55.0


  reply	other threads:[~2026-09-24 17:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260821083620.68324-1-rillian.grant@gmail.com>
2026-08-21  8:36 ` [RFC PATCH 1/2] dt-bindings: leds: Document TI LM3643 dual LED flash driver Rillian Grant
2026-08-21  8:36 ` [RFC PATCH 2/2] leds: flash: Add support for the " Rillian Grant
2026-09-24 17:20 ` [PATCH 0/2] leds: flash: lm3643: standby fix and ACPI LED description Ruslan Koreev
2026-09-24 17:20   ` Ruslan Koreev [this message]
2026-09-24 17:20   ` [PATCH 2/2] leds: flash: lm3643: Describe the LED of ACPI boards without LED nodes Ruslan Koreev

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=20260924172040.1185688-2-koreev.r@gmail.com \
    --to=koreev.r@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=rillian.grant@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®