From: Lee Jones <lee@kernel.org>
To: Jie Gu <jie.gu@leica-geosystems.com>
Cc: Matthias Fend <matthias.fend@emfend.at>,
Pavel Machek <pavel@kernel.org>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
Jie Gu <jie.gu@leica-geosystems.com.cn>
Subject: Re: [PATCH v2 2/2] leds: tps6131x: Clear torch brightness cache on flash takeover
Date: Fri, 27 Nov 2026 09:47:04 +0000 [thread overview]
Message-ID: <20261127094704.GR38590@joneslee-macbookpro.roam.internal> (raw)
In-Reply-To: <20261120075859.731257-3-jie.gu@leica-geosystems.com>
On Fri, 20 Nov 2026, Jie Gu wrote:
> From: Jie Gu <jie.gu@leica-geosystems.com.cn>
>
> When the device switches from torch mode to flash or external strobe
> mode, the hardware torch output is disabled, but the LED class
> brightness cache may still keep the previous non-zero torch value.
>
> This leaves sysfs brightness reporting an enabled torch state even
> though the light is already off.
>
> Update the cached LED brightness to LED_OFF when flash control takes
> over so userspace state matches the actual hardware state.
>
> Fixes: b338a2ae9b31 ("leds: tps6131x: Add support for Texas Instruments TPS6131X flash LED driver")
>
Nit: The trailers should not have blank lines.
> Reviewed-by: Matthias Fend <matthias.fend@emfend.at>
> Tested-by: Matthias Fend <matthias.fend@emfend.at>
> Signed-off-by: Jie Gu <jie.gu@leica-geosystems.com.cn>
> ---
> drivers/leds/flash/leds-tps6131x.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/leds/flash/leds-tps6131x.c b/drivers/leds/flash/leds-tps6131x.c
> index 823e0462939c..21957e4e3db4 100644
> --- a/drivers/leds/flash/leds-tps6131x.c
> +++ b/drivers/leds/flash/leds-tps6131x.c
> @@ -398,6 +398,8 @@ static int tps6131x_strobe_set(struct led_classdev_flash *fled_cdev, bool state)
> if (ret)
> return ret;
>
> + fled_cdev->led_cdev.brightness = LED_OFF;
> +
> return 0;
> }
>
> @@ -697,12 +699,19 @@ static int tps6131x_flash_external_strobe_set(struct v4l2_flash *v4l2_flash, boo
> {
> struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev;
> struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
> + int ret;
>
> cancel_delayed_work_sync(&tps6131x->torch_refresh_work);
> guard(mutex)(&tps6131x->lock);
>
> - return tps6131x_set_mode(tps6131x, enable ? TPS6131X_MODE_FLASH : TPS6131X_MODE_SHUTDOWN,
> - false);
> + ret = tps6131x_set_mode(tps6131x, enable ? TPS6131X_MODE_FLASH : TPS6131X_MODE_SHUTDOWN,
> + false);
> + if (ret)
> + return ret;
> +
> + fled_cdev->led_cdev.brightness = LED_OFF;
> +
> + return 0;
> }
>
> static const struct v4l2_flash_ops tps6131x_v4l2_flash_ops = {
> --
> 2.43.0
>
--
Lee Jones
prev parent reply other threads:[~2026-11-27 9:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 7:58 [PATCH v2 0/2] leds: tps6131x: Fix torch-to-flash transitions Jie Gu
2026-11-20 7:58 ` [PATCH v2 1/2] leds: tps6131x: Cancel torch refresh on flash mode switch Jie Gu
2026-11-20 7:58 ` [PATCH v2 2/2] leds: tps6131x: Clear torch brightness cache on flash takeover Jie Gu
2026-11-27 9:47 ` Lee Jones [this message]
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=20261127094704.GR38590@joneslee-macbookpro.roam.internal \
--to=lee@kernel.org \
--cc=jie.gu@leica-geosystems.com \
--cc=jie.gu@leica-geosystems.com.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=matthias.fend@emfend.at \
--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 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®