From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: ChiaEn Wu <chiaen_wu@richtek.com>,
pavel@ucw.cz, lee@kernel.org, matthias.bgg@gmail.com
Cc: linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, peterwu.pub@gmail.com,
cy_huang@richtek.com
Subject: Re: [PATCH] leds: mt6360: Fix the second LED can not enable torch mode by V4L2
Date: Tue, 9 Apr 2024 13:45:41 +0200 [thread overview]
Message-ID: <c98ea7c9-6c9b-466d-bc49-ec76874ac6da@collabora.com> (raw)
In-Reply-To: <d1d1419bb322e2b0f40d34edd3a66979015b668c.1712657386.git.chiaen_wu@richtek.com>
Il 09/04/24 12:21, ChiaEn Wu ha scritto:
> V4L2 will disable strobe mode of the LED device when enable torch mode,
> but this logic will conflict with the "priv->fled_torch_used"
> in "mt6360_strobe_set()". So after enabling torch mode of the first
> LED, the second LED will not be able to enable torch mode correctly.
>
> Therefore, at the beginning of "mt6360_strobe_set()", check whether the
> state of the upcoming change and the current LED device state are the
> same, so as to avoid the above problem.
>
> Signed-off-by: ChiaEn Wu <chiaen_wu@richtek.com>
> ---
> drivers/leds/flash/leds-mt6360.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6360.c
> index a90de82f4568..1b75b4d36834 100644
> --- a/drivers/leds/flash/leds-mt6360.c
> +++ b/drivers/leds/flash/leds-mt6360.c
> @@ -241,10 +241,20 @@ static int mt6360_strobe_set(struct led_classdev_flash *fl_cdev, bool state)
> u32 enable_mask = MT6360_STROBEN_MASK | MT6360_FLCSEN_MASK(led->led_no);
> u32 val = state ? MT6360_FLCSEN_MASK(led->led_no) : 0;
> u32 prev = priv->fled_strobe_used, curr;
> - int ret;
> + int ret = 0;
I prefer that you leave ret uninitialized here, and...
>
> mutex_lock(&priv->lock);
>
> + /*
> + * If the state of the upcoming change is the same as the current LED
> + * device state, then skip the subsequent code to avoid conflict
> + * with the flow of turning on LED torch mode in V4L2.
> + */
> + if (state == !!(BIT(led->led_no) & prev)) {
> + dev_info(lcdev->dev, "No change in strobe state [0x%x]\n", prev);
...that you do here, instead
ret = 0;
goto unlock;
With that addressed,
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collaobra.com>
next parent reply other threads:[~2024-04-09 11:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <d1d1419bb322e2b0f40d34edd3a66979015b668c.1712657386.git.chiaen_wu@richtek.com>
2024-04-09 11:45 ` AngeloGioacchino Del Regno [this message]
2024-04-11 6:55 ` [PATCH] leds: mt6360: Fix the second LED can not enable torch mode by V4L2 Lee Jones
2024-04-09 10:21 ChiaEn Wu
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=c98ea7c9-6c9b-466d-bc49-ec76874ac6da@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=chiaen_wu@richtek.com \
--cc=cy_huang@richtek.com \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=pavel@ucw.cz \
--cc=peterwu.pub@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).