Linux LED subsystem development
 help / color / mirror / Atom feed
From: Nora Schiffer <nora.schiffer@ew.tq-group.com>
To: sashiko-reviews@lists.linux.dev, lee@kernel.org
Cc: robh@kernel.org, devicetree@vger.kernel.org,
	linux-leds@vger.kernel.org, conor+dt@kernel.org,
	linux@ew.tq-group.com
Subject: Re: [PATCH v4 08/10] leds: pca995x: Add sysfs files for error reporting
Date: Thu, 01 Oct 2026 10:03:27 +0200	[thread overview]
Message-ID: <addd45d2eed383ba0885fe841ba5fafc2be7accb.camel@ew.tq-group.com> (raw)
In-Reply-To: <20260930154824.5083C1F000FF@smtp.kernel.org>

On Wed, 2026-09-30 at 15:48 +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] leds: pca995x: unintentional overwrite of MODE2 register during probe
> --
> 
> commit 1bf2389241c12cac5965e7df3db32ae52db81482
> Author: Nora Schiffer <nora.schiffer@ew.tq-group.com>
> 
> leds: pca995x: Add sysfs files for error reporting
> 
> The PCA995x has builtin failure detection. Provide sysfs files for
> individual LED status (reporting "okay", "short-circuit" or
> "open-circuit") as well as a global "has_errors" flag. has_errors is
> sticky and must be cleared by writing "clear" to the sysfs file.
> 
> > diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c
> > index df3f7ab2e1f87..1fc8de5a77bbc 100644
> > --- a/drivers/leds/leds-pca995x.c
> > +++ b/drivers/leds/leds-pca995x.c
> [ ... ]
> > @@ -185,11 +279,20 @@ static int pca995x_probe(struct i2c_client *client)
> >  	if (ret)
> >  		goto err_put_nodes;
> >  
> > +	/* Clear errors on probe */
> > +	ret = regmap_write(chip->regmap, PCA995X_MODE2, PCA995X_MODE2_CFG);
> 
> [Severity: High]
> Does this unconditional write clobber the entire MODE2 register?
> 
> Using regmap_write() instead of regmap_update_bits() zeroes out all other
> bits in the MODE2 register.
> 
> This clobbers the power-on reset defaults of the hardware, specifically the
> OUTDRV bit (typically bit 2), which defaults to 1 (totem-pole output).
> 
> Clearing it changes the output driver to open-drain, which can cause the
> LEDs to fail to light up or behave erratically.
> 
> Could regmap_update_bits() be used here instead to only set the CLRERR bit,
> similar to how it is handled in has_errors_store()?

Okay, while the description of the specific flag is nonsense (none of the
PCA995x have an "OUTDRV" bit), the unconditional initialization of MODE2 will
have to differ between the PCA9952 and PCA9955B/PCA9956B, and only the latter
implement the error reporting as handled by my patch - I'll fix this in the next
revision.

One question: The AI reviews made conflicting suggestions in different revisions
of my series. First it suggested to fully initialize MODE2 instead of relying on
reset defaults. Now it suggested the opposite. Which should I go with?

@Lee Jones: Patches 8-10 will definitely need another revision, but if patches
1-7 look good to you, they could be applied by themselves, so the next series
would be smaller.

Best,
Nora




> 
> > +	if (ret)
> > +		goto err_put_nodes;
> > +
> 

-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/

  reply	other threads:[~2026-10-01  8:03 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 14:25 [PATCH v4 00/10] leds: pca995x: Minor fixes; reset, output-gain, error reporting and group brightness support Nora Schiffer
2026-09-30 14:25 ` [PATCH v4 01/10] dt-bindings: leds: pca995x: Describe reset-gpios property Nora Schiffer
2026-09-30 15:02   ` sashiko-bot
2026-09-30 14:25 ` [PATCH v4 02/10] dt-bindings: leds: pca995x: Describe nxp,output-gain property Nora Schiffer
2026-09-30 15:09   ` sashiko-bot
2026-09-30 14:25 ` [PATCH v4 03/10] leds: pca995x: Fix maximum LED index for 16-channel variants Nora Schiffer
2026-09-30 14:58   ` Griffin Kroah-Hartman
2026-09-30 15:15   ` sashiko-bot
2026-09-30 14:25 ` [PATCH v4 04/10] leds: pca995x: Fix fwnode handle leaks in error paths Nora Schiffer
2026-09-30 15:24   ` sashiko-bot
2026-09-30 14:25 ` [PATCH v4 05/10] leds: pca995x: Write global registers before creating LED devices Nora Schiffer
2026-09-30 15:33   ` sashiko-bot
2026-09-30 14:25 ` [PATCH v4 06/10] leds: pca995x: Add support for reset GPIO Nora Schiffer
2026-09-30 15:37   ` sashiko-bot
2026-09-30 14:25 ` [PATCH v4 07/10] leds: pca995x: Make output gain configurable Nora Schiffer
2026-09-30 15:41   ` sashiko-bot
2026-09-30 14:25 ` [PATCH v4 08/10] leds: pca995x: Add sysfs files for error reporting Nora Schiffer
2026-09-30 15:48   ` sashiko-bot
2026-10-01  8:03     ` Nora Schiffer [this message]
2026-09-30 14:25 ` [PATCH v4 09/10] leds: pca995x: Do not use full on LED mode Nora Schiffer
2026-09-30 15:54   ` sashiko-bot
2026-09-30 14:25 ` [PATCH v4 10/10] leds: pca995x: Add support for group brightness control Nora Schiffer
2026-09-30 16:03   ` sashiko-bot

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=addd45d2eed383ba0885fe841ba5fafc2be7accb.camel@ew.tq-group.com \
    --to=nora.schiffer@ew.tq-group.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux@ew.tq-group.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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