* [PATCH v2] leds: rgb: lp5860: Fix DOTONOFF register offsets
@ 2026-12-02 23:17 ` Peter LaDow
0 siblings, 0 replies; 3+ messages in thread
From: Peter LaDow via B4 Relay @ 2026-12-02 23:17 UTC (permalink / raw)
To: Lee Jones, Pavel Machek, Griffin Kroah-Hartman, Steffen Trumtrar
Cc: linux-leds, linux-kernel, Peter LaDow
From: Peter LaDow <pladow@gmail.com>
In the TI LP5860, the 18 current sinks for each scan line are spread
across three 8-bit registers (Dot_onoff0..2 for L0, Dot_onoff3..5 for
L1, and so on, with bits [7:2] reserved in the third register of each
line). The current driver assumes the dot enable bits are tightly
packed across consecutive registers without padding, resulting in
incorrect register offsets and bitmasks for lines after L0.
Calculate the target scan line first to determine the base register
offset for that line, then compute the sub-register offset and bitmask
for the current sink.
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222303
Fixes: f0a66563aa2d ("leds: Add support for TI LP5860 LED driver chip")
Signed-off-by: Peter LaDow <pladow@gmail.com>
---
Changes in v2:
- Remove the long ASCII register table and inline comments
- Wrap the register offset calculation to stay under 100 columns
- Include <linux/math.h> for DIV_ROUND_UP
- Add Closes: tag for Bugzilla #222303
- Link to v1: https://lore.kernel.org/r/20261120-fix-lp5860-dotonoff-register-offset-calculation-v1-1-ec1e78842380@gmail.com
---
drivers/leds/rgb/leds-lp5860-core.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/rgb/leds-lp5860-core.c b/drivers/leds/rgb/leds-lp5860-core.c
index e21d5f2302be..6310fb21894c 100644
--- a/drivers/leds/rgb/leds-lp5860-core.c
+++ b/drivers/leds/rgb/leds-lp5860-core.c
@@ -8,6 +8,7 @@
#include <linux/led-class-multicolor.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/math.h>
#include <linux/of_platform.h>
#include <linux/property.h>
#include <linux/regmap.h>
@@ -21,8 +22,13 @@ static struct lp5860_led *mcled_cdev_to_led(struct led_classdev_mc *mc_cdev)
static int lp5860_set_dot_onoff(struct lp5860_led *led, unsigned int dot, bool enable)
{
- unsigned int offset = dot / LP5860_MAX_DOT_ONOFF_GROUP_NUM;
- unsigned int mask = BIT(dot % LP5860_MAX_DOT_ONOFF_GROUP_NUM);
+ unsigned int line = dot / LP5860_MAX_LED_CONSTANT;
+ unsigned int channel = dot % LP5860_MAX_LED_CONSTANT;
+ unsigned int reg_per_line = DIV_ROUND_UP(LP5860_MAX_LED_CONSTANT,
+ LP5860_MAX_DOT_ONOFF_GROUP_NUM);
+ unsigned int offset = line * reg_per_line +
+ channel / LP5860_MAX_DOT_ONOFF_GROUP_NUM;
+ unsigned int mask = BIT(channel % LP5860_MAX_DOT_ONOFF_GROUP_NUM);
if (dot > LP5860_MAX_LED)
return -EINVAL;
---
base-commit: 5d3bdf40e316f47e7e3f8220b97bbec658852a96
change-id: 20261120-fix-lp5860-dotonoff-register-offset-calculation-bb55622a9975
Best regards,
--
Peter LaDow <pladow@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2] leds: rgb: lp5860: Fix DOTONOFF register offsets
@ 2026-12-02 23:17 ` Peter LaDow
0 siblings, 0 replies; 3+ messages in thread
From: Peter LaDow @ 2026-12-02 23:17 UTC (permalink / raw)
To: Lee Jones, Pavel Machek, Griffin Kroah-Hartman, Steffen Trumtrar
Cc: linux-leds, linux-kernel, Peter LaDow
In the TI LP5860, the 18 current sinks for each scan line are spread
across three 8-bit registers (Dot_onoff0..2 for L0, Dot_onoff3..5 for
L1, and so on, with bits [7:2] reserved in the third register of each
line). The current driver assumes the dot enable bits are tightly
packed across consecutive registers without padding, resulting in
incorrect register offsets and bitmasks for lines after L0.
Calculate the target scan line first to determine the base register
offset for that line, then compute the sub-register offset and bitmask
for the current sink.
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222303
Fixes: f0a66563aa2d ("leds: Add support for TI LP5860 LED driver chip")
Signed-off-by: Peter LaDow <pladow@gmail.com>
---
Changes in v2:
- Remove the long ASCII register table and inline comments
- Wrap the register offset calculation to stay under 100 columns
- Include <linux/math.h> for DIV_ROUND_UP
- Add Closes: tag for Bugzilla #222303
- Link to v1: https://lore.kernel.org/r/20261120-fix-lp5860-dotonoff-register-offset-calculation-v1-1-ec1e78842380@gmail.com
---
drivers/leds/rgb/leds-lp5860-core.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/rgb/leds-lp5860-core.c b/drivers/leds/rgb/leds-lp5860-core.c
index e21d5f2302be..6310fb21894c 100644
--- a/drivers/leds/rgb/leds-lp5860-core.c
+++ b/drivers/leds/rgb/leds-lp5860-core.c
@@ -8,6 +8,7 @@
#include <linux/led-class-multicolor.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/math.h>
#include <linux/of_platform.h>
#include <linux/property.h>
#include <linux/regmap.h>
@@ -21,8 +22,13 @@ static struct lp5860_led *mcled_cdev_to_led(struct led_classdev_mc *mc_cdev)
static int lp5860_set_dot_onoff(struct lp5860_led *led, unsigned int dot, bool enable)
{
- unsigned int offset = dot / LP5860_MAX_DOT_ONOFF_GROUP_NUM;
- unsigned int mask = BIT(dot % LP5860_MAX_DOT_ONOFF_GROUP_NUM);
+ unsigned int line = dot / LP5860_MAX_LED_CONSTANT;
+ unsigned int channel = dot % LP5860_MAX_LED_CONSTANT;
+ unsigned int reg_per_line = DIV_ROUND_UP(LP5860_MAX_LED_CONSTANT,
+ LP5860_MAX_DOT_ONOFF_GROUP_NUM);
+ unsigned int offset = line * reg_per_line +
+ channel / LP5860_MAX_DOT_ONOFF_GROUP_NUM;
+ unsigned int mask = BIT(channel % LP5860_MAX_DOT_ONOFF_GROUP_NUM);
if (dot > LP5860_MAX_LED)
return -EINVAL;
---
base-commit: 5d3bdf40e316f47e7e3f8220b97bbec658852a96
change-id: 20261120-fix-lp5860-dotonoff-register-offset-calculation-bb55622a9975
Best regards,
--
Peter LaDow <pladow@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] leds: rgb: lp5860: Fix DOTONOFF register offsets
2026-12-02 23:17 ` Peter LaDow
(?)
@ 2026-12-02 23:24 ` sashiko-bot
-1 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-02 23:24 UTC (permalink / raw)
To: Peter LaDow; +Cc: linux-leds, lee
> From: Peter LaDow <pladow@gmail.com>
>
> In the TI LP5860, the 18 current sinks for each scan line are spread
> across three 8-bit registers (Dot_onoff0..2 for L0, Dot_onoff3..5 for
> L1, and so on, with bits [7:2] reserved in the third register of each
> line). The current driver assumes the dot enable bits are tightly
> packed across consecutive registers without padding, resulting in
> incorrect register offsets and bitmasks for lines after L0.
>
> Calculate the target scan line first to determine the base register
> offset for that line, then compute the sub-register offset and bitmask
> for the current sink.
>
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222303
> Fixes: f0a66563aa2d ("leds: Add support for TI LP5860 LED driver chip")
> Signed-off-by: Peter LaDow <pladow@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-fix-lp5860-dotonoff-register-offset-calculation-v2-1-341a53c20e6a@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-02 23:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 23:17 [PATCH v2] leds: rgb: lp5860: Fix DOTONOFF register offsets Peter LaDow via B4 Relay
2026-12-02 23:17 ` Peter LaDow
2026-12-02 23:24 ` sashiko-bot
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.