Re: [PATCH] leds: lp5860: Fix DOTONOFF register offsets
From: Peter LaDow
Date: Mon Nov 30 2026 - 13:10:59 EST
Also here, before I submit the updated patch, I have just one real
question on the last comment.
On Fri, Nov 27, 2026 at 1:57 AM Lee Jones <lee@xxxxxxxxxx> wrote:
> > From: Peter LaDow <pladow@xxxxxxxxx>
>
> Also, please keep lines within the 100-character limit and consider
> making this comment block much more concise - we don't need to duplicate
> the entire datasheet register table and repeat the C arithmetic in
> prose.
Fair enough. I was quite verbose. I've removed the block comment.
and corrected the C++ style comments.
> If you must provide this level of documentation, put it in Documentation.
I don't think it necessary other than to explain the math for the
patch reviewers. Perhaps better to put into the cover letter on why
the original code was problematic?
> > 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;
>
> What's the difference between a line and a channel?
For the LP5860 there are 11 scanlines (line) each made of 18 channels
(current sinks). The original code called these channels dots.
>
> > +
> > + // Calculate the register offset.
> > + unsigned int offset = line * DIV_ROUND_UP(LP5860_MAX_LED_CONSTANT, LP5860_MAX_DOT_ONOFF_GROUP_NUM) +
> > + channel / LP5860_MAX_DOT_ONOFF_GROUP_NUM;
> > +
> > + // The bit within the register.
> > + unsigned int mask = BIT(channel % LP5860_MAX_DOT_ONOFF_GROUP_NUM);
> >
> These comments merely state the obvious from the variable names and can
> be dropped. Please also keep all variable declarations together at the
> top of the function without blank lines in between, and wrap lines at
> 100 characters.
Done.
> > if (dot > LP5860_MAX_LED)
> > return -EINVAL;
>
> If you used AI to draft this patch, you need to teach it about the
> kernel coding guidelines. Did you / it run checkpatch.pl?
Is this in regard to the code above? This code is already present in
the kernel (see drivers/leds/rgb/leds-lp5860-core.c#L27-L28).
I did run checkpatch.pl, it only complained about the long lines for
the comments. Which is why I mentioned in cover letter about
exceeding the line lengths for the comments.
--
To love for the sake of being loved is human, but to love for the sake
of loving is angelic. -- Alphonse de Lamartine.