Linux LED subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Loic Poulain" <loic.poulain@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, linux-leds@vger.kernel.org,
	lee@kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 3/4] leds: pca963x: add multicolor LED class support
Date: Wed, 15 Jul 2026 13:57:25 +0000	[thread overview]
Message-ID: <20260715135725.8A4A91F01560@smtp.kernel.org> (raw)
In-Reply-To: <20260715-monza-leds-v6-3-d1724bb7fe3d@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [Low] Commit Message Capitalization Violation

Pre-existing issues:
- [High] Silent truncation of negative error codes from I2C reads leads to hardware register corruption.
- [High] Unprotected I2C writes to shared global hardware blinking registers.
--

--- Patch [3]: [PATCH v6 3/4] leds: pca963x: add multicolor LED class support ---
commit 9035bb6a1e69dbc8b0e467061aaa0b06a70a0f89
Author: Loic Poulain <loic.poulain@oss.qualcomm.com>

leds: pca963x: add multicolor LED class support

Allow grouping of individual PCA963x PWM channels into a single
multicolor LED device by adding support for the LED multicolor class.
A child node with sub-children is treated as a multicolor group,
others are treated as single leds, keeping full backwards compatibility.

> leds: pca963x: add multicolor LED class support

[Severity: Low]
This isn't a bug, but the subsystem prefix description should be capitalized.
Should it be "leds: pca963x: Add multicolor LED class support"?

> diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
> index e3a81c60ee27c..f3e4d65e48b4c 100644
> --- a/drivers/leds/leds-pca963x.c
> +++ b/drivers/leds/leds-pca963x.c
> @@ -199,20 +203,24 @@ static void pca963x_blink(struct pca963x_led *led)
>  	led->blinking = true;
>  }

[Severity: High]
This is a pre-existing issue, but are global chip registers modified without
acquiring the chip mutex here?

drivers/leds/leds-pca963x.c:pca963x_blink() {
        ...
        i2c_smbus_write_byte_data(client, chipdef->grppwm, led->gdc);
        i2c_smbus_write_byte_data(client, chipdef->grpfreq, led->gfrq);
        
        if (!(mode2 & PCA963X_MODE2_DMBLNK))
                i2c_smbus_write_byte_data(client, PCA963X_MODE2,
                                          mode2 | PCA963X_MODE2_DMBLNK);
        
        mutex_lock(&led->chip->mutex);
        ...
}

If user-space initiates hardware blinking for two different LEDs concurrently,
could their writes to these global frequency and duty cycle registers
interleave and corrupt the hardware blink state for the entire chip?

[ ... ]

> @@ -221,22 +229,54 @@ static int pca963x_led_set(struct led_classdev *led_cdev,
>  			   enum led_brightness value)
>  {
>  	struct pca963x_led *led;
> +	unsigned long cached_leds;
>  	int ret;
>  
>  	led = container_of(led_cdev, struct pca963x_led, led_cdev);
>  
>  	mutex_lock(&led->chip->mutex);
>  
> +	cached_leds = led->chip->leds_on;
>  	ret = pca963x_brightness(led, value);

[Severity: High]
This is a pre-existing issue, but does assigning the result of
i2c_smbus_read_byte_data() directly to a u8 silently truncate negative error
codes?

If the read fails and returns -EIO, this would truncate the negative error
code into a garbage unsigned 8-bit integer, and we then write it back to the
chip in pca963x_brightness():

drivers/leds/leds-pca963x.c:pca963x_brightness() {
        ...
        ledout = i2c_smbus_read_byte_data(client, ledout_addr);
        ...
        val = (ledout & ~mask) | (PCA963X_LED_ON << shift);
        ret = i2c_smbus_write_byte_data(client, ledout_addr, val);
        ...
}

The same pattern appears in pca963x_blink() with the mode2 variable. Could
this cause hardware register corruption during a transient I2C failure?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260715-monza-leds-v6-0-d1724bb7fe3d@oss.qualcomm.com?part=3

  reply	other threads:[~2026-07-15 13:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15 13:44 [PATCH v6 0/4] leds: pca963x: Add multicolor support and enable Monza RGB LEDs Loic Poulain
2026-07-15 13:44 ` [PATCH v6 1/4] dt-bindings: leds: nxp,pca963x: fix reg maximum for pca9635 Loic Poulain
2026-07-15 13:51   ` sashiko-bot
2026-07-15 13:44 ` [PATCH v6 2/4] dt-bindings: leds: nxp,pca963x: add multicolor LED support Loic Poulain
2026-07-15 13:52   ` sashiko-bot
2026-07-15 13:44 ` [PATCH v6 3/4] leds: pca963x: add multicolor LED class support Loic Poulain
2026-07-15 13:57   ` sashiko-bot [this message]
2026-07-15 13:44 ` [PATCH v6 4/4] arm64: dts: monaco-arduino-monza: microcontroller LEDs Loic Poulain
2026-07-15 13:54   ` 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=20260715135725.8A4A91F01560@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=loic.poulain@oss.qualcomm.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