leds: pca9532: Fix inverted GPIO output polarity
Subsystems (3)
PATCH 1/1 leds: pca9532: Fix inverted GPIO output polarity
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.
--- drivers/leds/leds-pca9532.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/leds/leds-pca9532.c +3 -3
@@ -325,9 +325,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);
@@ -347,7 +347,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 ; }
Signature · 1 line
2.43.0
Lee Jones
maintainerQuoted 6 lines · Cosmo Chou
The
pca9532_gpio_set_value()function incorrectly mapped the requested value toPCA9532_ONandPCA9532_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.
Quoted 8 lines
Correct the mapping so that val=1 yields
PCA9532_OFF(pin released / high-impedance) and val=0 yieldsPCA9532_ON(pin driven low).
pca9532_gpio_direction_input()is also updated to pass val=1 topca9532_gpio_set_value()to align with the corrected polarity mapping, ensuring the pin remains not driven when configured as an input.Fixes <3c1ab50d0a31b27bb4e55168f4901dd91e6e5ea4> ("drivers/leds/leds-pca9532.c: add gpio capability")
'Fixes: 3c1ab50d0a31 ("drivers/leds/leds-pca9532.c: add gpio capability")'
Quoted 33 lines
Signed-off-by Cosmo Chou <[email protected]>--- drivers/leds/leds-pca9532.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/leds/leds-pca9532.c +3
-3@@ -325,9 +325,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);@@ -347,7 +347,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 ; }Signature · 1 line
2.43.0
Signature · 1 line
Lee Jones