From 0858d1198ef0f08ba3297b8aca71b767a456c139 Mon Sep 17 00:00:00 2001 From: Ryan Lattrel Date: Mon, 21 Dec 2020 16:44:33 -0600 Subject: [PATCH] gpio: pcal6408: fix set output Fix the set output function so that it will configure the gpio to the specified state. Change-Id: I265e53a83b64c6663eb52013087e1960de29f0d3 Signed-off-by: Ryan Lattrel Reviewed-on: https://gerrit.mot.com/1834058 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Reviewed-by: Konstantin Makariev Tested-by: Jira Key Submit-Approved: Jira Key --- drivers/gpio/pcal6408/gpio-pcal6408.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/pcal6408/gpio-pcal6408.c b/drivers/gpio/pcal6408/gpio-pcal6408.c index 74fbb291d38b..486f39bca255 100755 --- a/drivers/gpio/pcal6408/gpio-pcal6408.c +++ b/drivers/gpio/pcal6408/gpio-pcal6408.c @@ -273,6 +273,16 @@ static int pcal6048_direction_in(struct gpio_chip *gc, unsigned offset) return ret; } +static void pcal6048_set_gpio(struct gpio_chip *gc, unsigned offset, int value) +{ + struct pcal6048_dev *chip = gpiochip_get_data(gc); + + if (value) + pcal6048_set_reg(chip, offset, chip->conf->output); + else + pcal6048_clear_reg(chip, offset, chip->conf->output); +} + static int pcal6048_direction_out(struct gpio_chip *gc, unsigned offset, int value) { struct pcal6048_dev *chip = gpiochip_get_data(gc); @@ -287,6 +297,8 @@ static int pcal6048_direction_out(struct gpio_chip *gc, unsigned offset, int val else ret = pcal6048_clear_reg(chip, offset, chip->conf->direction); + pcal6048_set_gpio(gc, offset, value); + return ret; } @@ -310,16 +322,6 @@ static int pcal6048_get_gpio(struct gpio_chip *gc, unsigned offset) return pcal6048_read_reg(chip, offset, chip->conf->input); } -static void pcal6048_set_gpio(struct gpio_chip *gc, unsigned offset, int value) -{ - struct pcal6048_dev *chip = gpiochip_get_data(gc); - - if (value) - pcal6048_set_reg(chip, offset, chip->conf->output); - else - pcal6048_clear_reg(chip, offset, chip->conf->output); -} - static int pcal6048_set_config(struct gpio_chip *gc, unsigned int offset, unsigned long config) { struct pcal6048_dev *chip = gpiochip_get_data(gc);