All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniil Demakov" <t3127430@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH] leds: pca9532: Propagate I2C errors
Date: Sat, 28 Nov 2026 23:09:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-239138@kernel.org> (raw)
In-Reply-To: <20261128225901.224593-1-t3127430@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] leds: pca9532: stale PCA9532_PWM1 in pca9532_set_blink() on
  error
- [Medium] leds: pca9532: unchecked pca9532_gpio_set_value() in
  direction_input
- [Low] leds: pca9532: missing Fixes trailer for pca9532_setled() I2C
  error handling
--

commit 4d10e52bbfe129d5c32f60079f0dde38edbd4d8f
Author: Daniil Demakov <t3127430@gmail.com>

> leds: pca9532: Propagate I2C errors
>
> Check the return values of SMBus read and write operations
> in pca9532_setled() and propagate errors to callers.
>
> Unregister the LED class device if configuring the LED fails.
>
> Signed-off-by: Daniil Demakov <t3127430@gmail.com>

[Severity: Low]
This fixes the unchecked SMBus read and write operations in
pca9532_setled() and pca9532_configure().  Should it include:

  Fixes: e14fa82439d3 ("leds: Add pca9532 led driver")

> diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
> index c8085427696ff..7a2c3ba5c9d8d 100644
> --- a/drivers/leds/leds-pca9532.c
> +++ b/drivers/leds/leds-pca9532.c
[ ... ]
> @@ -257,9 +277,9 @@ static int pca9532_set_blink(struct led_classdev *led_cdev,
>  	if (err)
>  		return err;
>  
> -	pca9532_setled(led);
> +	err = pca9532_setled(led);
>  
> -	return 0;
> +	return err;
>  }

[Severity: Medium]
If pca9532_setled() fails here, does led->state stay set to PCA9532_PWM1
from pca9532_update_hw_blink()?

When blink_set returns an error, led_blink_setup() falls back to software
blinking, which calls pca9532_set_brightness().  Because
pca9532_set_brightness() returns early on non-zero brightness when
led->state == PCA9532_PWM1, software blinking will not turn the LED on,
and pca9532_update_hw_blink() will reject different blink timings on
other LEDs.

>  static int pca9532_event(struct input_dev *dev, unsigned int type,
> @@ -328,15 +348,15 @@ static int pca9532_gpio_set_value(struct gpio_chip *gc, unsigned int offset,
>  {
>  	struct pca9532_data *data = gpiochip_get_data(gc);
>  	struct pca9532_led *led = &data->leds[offset];
> -
> +	int err;
>  	if (val)
>  		led->state = PCA9532_OFF;
>  	else
>  		led->state = PCA9532_ON;
>  
> -	pca9532_setled(led);
> +	err = pca9532_setled(led);
>  
> -	return 0;
> +	return err;
>  }

[Severity: Medium]
Now that pca9532_gpio_set_value() returns the error from
pca9532_setled(), should pca9532_gpio_direction_input() propagate it the
way pca9532_gpio_direction_output() does?

drivers/leds/leds-pca9532.c:pca9532_gpio_direction_input() {
	/* To use as input ensure pin is not driven */
	pca9532_gpio_set_value(gc, offset, 1);

	return 0;
}

Otherwise an I2C failure leaves the open-drain pin driven in its previous
state while pca9532_gpio_direction_input() reports success.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128225901.224593-1-t3127430@gmail.com?part=1

  reply	other threads:[~2026-11-28 23:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 22:59 [PATCH] leds: pca9532: Propagate I2C errors Daniil Demakov
2026-11-28 23:09 ` sashiko-bot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-11-28 22:30 Daniil Demakov
2026-11-28 22:40 ` sashiko-bot
2026-11-17  7:05 Daniil Demakov
2026-11-17  7:22 ` sashiko-bot
2026-11-14 14:19 Daniil Demakov
2026-11-14 14:32 ` 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=sashiko-outbox-239138@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=t3127430@gmail.com \
    /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 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.