leds: pca955x: Fix GPIO request for input setting drain instead of Hi-Z
PATCH 1/1 leds: pca955x: Fix GPIO request for input setting drain instead of Hi-Z
The prior patch which fixed the problem with output inversion failed to account for a necessary fix to requesting a pin for input, which is affected by the open-drain nature of the hardware.
Previously pca955x_gpio_direction_input() called through pca955x_set_value() to configure the direction, however continuing down this route lead to a brain-haemorhaging level of necessary inversions. Instead, remove one layer by calling directly into pca955x_led_set(), and define PCA955X_GPIO_INPUT to paper over the rest of the confusion.
---
I'll send this upstream shortly. LEDs seem to rebase their branch quite often, so given the original patch is targeting 4.15 we might be able to get the two squashed together.
drivers/leds/leds-pca955x.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/leds/leds-pca955x.c +6 -2
@@ -61,6 +61,7 @@#define PCA955X_LS_BLINK0 0x2/* Blink at PWM0 rate */ #define PCA955X_LS_BLINK1 0x3/* Blink at PWM1 rate */ +#define PCA955X_GPIO_INPUT LED_OFF#define PCA955X_GPIO_HIGH LED_OFF#define PCA955X_GPIO_LOW LED_FULL
@@ -358,8 +359,11 @@ static int pca955x_gpio_get_value(struct gpio_chip *gc, unsigned int offset)static int pca955x_gpio_direction_input (struct gpio_chip *gc,unsigned int offset) { -/* To use as input ensure pin is not driven */ -return pca955x_set_value (gc, offset,0 ); +struct pca955x *pca955x =gpiochip_get_data (gc); +struct pca955x_led *led = &pca955x->leds[offset]; + +/* To use as input ensure pin is not driven. */ +return pca955x_led_set (&led->led_cdev,PCA955X_GPIO_INPUT ); } static int pca955x_gpio_direction_output(struct gpio_chip *gc,
Signature · 1 line
2.11.0