From: Manuel Fombuena <fombuena@outlook.com>
To: lee@kernel.org, pavel@kernel.org,
vicentiu.galanopulo@remote-tech.co.uk,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 01/10] leds: st1202: stop pattern sequence before reprogramming
Date: Sun, 24 May 2026 23:22:31 +0100 [thread overview]
Message-ID: <WA0P291MB03858E777D8E9DABFE03DBDEC50D2@WA0P291MB0385.POLP291.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <WA0P291MB03855101311F0506B6448A8EC50D2@WA0P291MB0385.POLP291.PROD.OUTLOOK.COM>
The LED1202 datasheet (section 4.8) states that modifications to the
Pattern Sequence Repetition register (PAT_REP) and pattern duration
registers are only applied after the sequence has completed or been
stopped. When the device is running in infinite loop mode (PAT_REP =
0xFF) the sequence never completes on its own, so these writes are
silently ignored by the hardware.
Neither pattern_clear() nor pattern_set() stop the running sequence
before modifying pattern registers, causing any subsequent pattern
reprogramming to have no effect when the previous pattern was set to
infinite repeat.
Fix this by clearing PATS in the Configuration register before touching
any pattern registers in both functions, ensuring the hardware accepts
the new values immediately.
Fixes: 259230378c65 ("leds: Add LED1202 I2C driver")
Signed-off-by: Manuel Fombuena <fombuena@outlook.com>
Assisted-by: Claude:claude-sonnet-4-6
---
drivers/leds/leds-st1202.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
index 2b68cd3c45f8..28e3f1e2314c 100644
--- a/drivers/leds/leds-st1202.c
+++ b/drivers/leds/leds-st1202.c
@@ -200,6 +200,10 @@ static int st1202_led_pattern_clear(struct led_classdev *ldev)
guard(mutex)(&chip->lock);
+ ret = st1202_write_reg(chip, ST1202_CONFIG_REG, ST1202_CONFIG_REG_SHFT);
+ if (ret != 0)
+ return ret;
+
for (int patt = 0; patt < ST1202_MAX_PATTERNS; patt++) {
ret = st1202_pwm_pattern_write(chip, led->led_num, patt, LED_OFF);
if (ret != 0)
@@ -226,6 +230,10 @@ static int st1202_led_pattern_set(struct led_classdev *ldev,
guard(mutex)(&chip->lock);
+ ret = st1202_write_reg(chip, ST1202_CONFIG_REG, ST1202_CONFIG_REG_SHFT);
+ if (ret != 0)
+ return ret;
+
for (int patt = 0; patt < len; patt++) {
if (pattern[patt].delta_t < ST1202_MILLIS_PATTERN_DUR_MIN ||
pattern[patt].delta_t > ST1202_MILLIS_PATTERN_DUR_MAX)
--
2.54.0
next prev parent reply other threads:[~2026-05-24 22:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-24 22:17 [PATCH v2 00/10] leds: st1202: fix multiple bugs in pattern engine and brightness handling Manuel Fombuena
2026-05-24 22:22 ` Manuel Fombuena [this message]
2026-05-24 22:23 ` [PATCH v2 02/10] leds: st1202: validate pattern input before stopping the sequence Manuel Fombuena
2026-05-24 22:24 ` [PATCH v2 03/10] leds: st1202: fix pattern duration register calculation Manuel Fombuena
2026-05-24 22:25 ` [PATCH v2 04/10] leds: st1202: fix pattern_clear to explicitly mark unused slots as skip Manuel Fombuena
2026-05-24 22:26 ` [PATCH v2 05/10] leds: st1202: reset PAT_REP to POR default in pattern_clear Manuel Fombuena
2026-05-24 22:27 ` [PATCH v2 06/10] leds: st1202: restore Pattern0 PWM to full on after clearing pattern Manuel Fombuena
2026-05-24 22:28 ` [PATCH v2 07/10] leds: st1202: fix spurious pattern sequence start in setup Manuel Fombuena
2026-05-24 22:29 ` [PATCH v2 08/10] leds: st1202: fix brightness having no effect while pattern mode is active Manuel Fombuena
2026-05-24 22:30 ` [PATCH v2 09/10] leds: st1202: disable channel when brightness is set to zero Manuel Fombuena
2026-05-24 22:30 ` [PATCH v2 10/10] leds: st1202: correct and extend hw_pattern documentation Manuel Fombuena
2026-06-04 15:20 ` [PATCH v2 00/10] leds: st1202: fix multiple bugs in pattern engine and brightness handling Lee Jones
2026-06-05 14:40 ` Manuel Fombuena
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=WA0P291MB03858E777D8E9DABFE03DBDEC50D2@WA0P291MB0385.POLP291.PROD.OUTLOOK.COM \
--to=fombuena@outlook.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=vicentiu.galanopulo@remote-tech.co.uk \
/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®