* [PATCH v2] leds: pca9532: Fix inverted GPIO output polarity
@ 2026-07-03 1:42 Cosmo Chou
2026-07-03 8:12 ` Bartosz Golaszewski
2026-07-09 9:29 ` (subset) " Lee Jones
0 siblings, 2 replies; 3+ messages in thread
From: Cosmo Chou @ 2026-07-03 1:42 UTC (permalink / raw)
To: lee, pavel, riku.voipio
Cc: linusw, brgl, linux-leds, linux-gpio, linux-kernel, cosmo.chou,
Cosmo Chou
The pca9532_gpio_set_value() function incorrectly mapped the requested
value to PCA9532_ON and PCA9532_OFF, inverting the GPIO output polarity.
A requested logical high (val=1) incorrectly enabled the LED output
driver, which on this open-drain device pulls the pin low, while a
requested logical low (val=0) released the pin.
Correct the mapping so that val=1 yields PCA9532_OFF (pin released /
high-impedance) and val=0 yields PCA9532_ON (pin driven low).
pca9532_gpio_direction_input() is also updated to pass val=1 to
pca9532_gpio_set_value() to align with the corrected polarity mapping,
ensuring the pin remains not driven when configured as an input.
Fixes: 3c1ab50d0a31 ("drivers/leds/leds-pca9532.c: add gpio capability")
Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com>
---
Changes in v2:
- Correct the format of "Fixes:" tag.
drivers/leds/leds-pca9532.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index f3bf59495b68..2d37e00e459d 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -327,9 +327,9 @@ static int pca9532_gpio_set_value(struct gpio_chip *gc, unsigned int offset,
struct pca9532_led *led = &data->leds[offset];
if (val)
- led->state = PCA9532_ON;
- else
led->state = PCA9532_OFF;
+ else
+ led->state = PCA9532_ON;
pca9532_setled(led);
@@ -349,7 +349,7 @@ static int pca9532_gpio_get_value(struct gpio_chip *gc, unsigned offset)
static int pca9532_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
{
/* To use as input ensure pin is not driven */
- pca9532_gpio_set_value(gc, offset, 0);
+ pca9532_gpio_set_value(gc, offset, 1);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] leds: pca9532: Fix inverted GPIO output polarity
2026-07-03 1:42 [PATCH v2] leds: pca9532: Fix inverted GPIO output polarity Cosmo Chou
@ 2026-07-03 8:12 ` Bartosz Golaszewski
2026-07-09 9:29 ` (subset) " Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-07-03 8:12 UTC (permalink / raw)
To: Cosmo Chou
Cc: lee, pavel, riku.voipio, linusw, brgl, linux-leds, linux-gpio,
linux-kernel, cosmo.chou
On Fri, 3 Jul 2026 03:42:01 +0200, Cosmo Chou <chou.cosmo@gmail.com> said:
> The pca9532_gpio_set_value() function incorrectly mapped the requested
> value to PCA9532_ON and PCA9532_OFF, inverting the GPIO output polarity.
> A requested logical high (val=1) incorrectly enabled the LED output
> driver, which on this open-drain device pulls the pin low, while a
> requested logical low (val=0) released the pin.
>
> Correct the mapping so that val=1 yields PCA9532_OFF (pin released /
> high-impedance) and val=0 yields PCA9532_ON (pin driven low).
>
> pca9532_gpio_direction_input() is also updated to pass val=1 to
> pca9532_gpio_set_value() to align with the corrected polarity mapping,
> ensuring the pin remains not driven when configured as an input.
>
> Fixes: 3c1ab50d0a31 ("drivers/leds/leds-pca9532.c: add gpio capability")
> Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com>
> ---
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: (subset) [PATCH v2] leds: pca9532: Fix inverted GPIO output polarity
2026-07-03 1:42 [PATCH v2] leds: pca9532: Fix inverted GPIO output polarity Cosmo Chou
2026-07-03 8:12 ` Bartosz Golaszewski
@ 2026-07-09 9:29 ` Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2026-07-09 9:29 UTC (permalink / raw)
To: lee, pavel, riku.voipio, Cosmo Chou
Cc: linusw, brgl, linux-leds, linux-gpio, linux-kernel, cosmo.chou
On Fri, 03 Jul 2026 09:42:01 +0800, Cosmo Chou wrote:
> The pca9532_gpio_set_value() function incorrectly mapped the requested
> value to PCA9532_ON and PCA9532_OFF, inverting the GPIO output polarity.
> A requested logical high (val=1) incorrectly enabled the LED output
> driver, which on this open-drain device pulls the pin low, while a
> requested logical low (val=0) released the pin.
>
> Correct the mapping so that val=1 yields PCA9532_OFF (pin released /
> high-impedance) and val=0 yields PCA9532_ON (pin driven low).
>
> [...]
Applied, thanks!
[1/1] leds: pca9532: Fix inverted GPIO output polarity
commit: 65a38a28a0b04af19a5e1fbf3869051412eeac96
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-09 9:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 1:42 [PATCH v2] leds: pca9532: Fix inverted GPIO output polarity Cosmo Chou
2026-07-03 8:12 ` Bartosz Golaszewski
2026-07-09 9:29 ` (subset) " Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox