Skip to content

Commit

Permalink
gpio: dln2: Fix gpio output value in dln2_gpio_direction_output()
Browse files Browse the repository at this point in the history
dln2_gpio_direction_output() ignored the state passed into it. Fix it.
Also make dln2_gpio_pin_set_out_val return int, so we can check the error value.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Tested-by: Daniel Baluta <daniel.baluta@intel.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Octavian Purdila <octavian.purdila@intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Axel Lin authored and Linus Walleij committed Jan 7, 2015
1 parent 0acb0e7 commit 5afb287
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions drivers/gpio/gpio-dln2.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ static int dln2_gpio_pin_get_out_val(struct dln2_gpio *dln2, unsigned int pin)
return !!ret;
}

static void dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2,
unsigned int pin, int value)
static int dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2,
unsigned int pin, int value)
{
struct dln2_gpio_pin_val req = {
.pin = cpu_to_le16(pin),
.value = value,
};

dln2_transfer_tx(dln2->pdev, DLN2_GPIO_PIN_SET_OUT_VAL, &req,
sizeof(req));
return dln2_transfer_tx(dln2->pdev, DLN2_GPIO_PIN_SET_OUT_VAL, &req,
sizeof(req));
}

#define DLN2_GPIO_DIRECTION_IN 0
Expand Down Expand Up @@ -266,6 +266,13 @@ static int dln2_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
int value)
{
struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio);
int ret;

ret = dln2_gpio_pin_set_out_val(dln2, offset, value);
if (ret < 0)
return ret;

return dln2_gpio_set_direction(chip, offset, DLN2_GPIO_DIRECTION_OUT);
}

Expand Down

0 comments on commit 5afb287

Please sign in to comment.