diff options
author | Chris Packham <chris.packham@alliedtelesis.co.nz> | 2019-07-08 08:35:58 +1200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-06 19:08:16 +0200 |
commit | cda67846b748a9d9005587e3bed35ba22e2d0d5e (patch) | |
tree | 53af6867df132dccbfbee35f90e1472700bfa678 /drivers | |
parent | 8acd3fc56a6f6dd2b5de148033e2d8fbfd871947 (diff) | |
download | linux-stable-cda67846b748a9d9005587e3bed35ba22e2d0d5e.tar.gz linux-stable-cda67846b748a9d9005587e3bed35ba22e2d0d5e.tar.bz2 linux-stable-cda67846b748a9d9005587e3bed35ba22e2d0d5e.zip |
gpiolib: Preserve desc->flags when setting state
commit d95da993383c78f7efd25957ba3af23af4b1c613 upstream.
desc->flags may already have values set by of_gpiochip_add() so make
sure that this isn't undone when setting the initial direction.
Cc: stable@vger.kernel.org
Fixes: 3edfb7bd76bd1cba ("gpiolib: Show correct direction from the beginning")
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20190707203558.10993-1-chris.packham@alliedtelesis.co.nz
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpio/gpiolib.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index bb3104d2eb0c..773d3d787ca3 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1392,12 +1392,17 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, for (i = 0; i < chip->ngpio; i++) { struct gpio_desc *desc = &gdev->descs[i]; - if (chip->get_direction && gpiochip_line_is_valid(chip, i)) - desc->flags = !chip->get_direction(chip, i) ? - (1 << FLAG_IS_OUT) : 0; - else - desc->flags = !chip->direction_input ? - (1 << FLAG_IS_OUT) : 0; + if (chip->get_direction && gpiochip_line_is_valid(chip, i)) { + if (!chip->get_direction(chip, i)) + set_bit(FLAG_IS_OUT, &desc->flags); + else + clear_bit(FLAG_IS_OUT, &desc->flags); + } else { + if (!chip->direction_input) + set_bit(FLAG_IS_OUT, &desc->flags); + else + clear_bit(FLAG_IS_OUT, &desc->flags); + } } acpi_gpiochip_add(chip); |