Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1288668

Re: [PATCH v2] gpiolib: return 0 or 1 in gpiod_get_value*() functions

From Linus Walleij <linus.walleij@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2] gpiolib: return 0 or 1 in gpiod_get_value*() functions
Date 2015-12-10 18:00 +0100
Message-ID <qEcJr-k8-1@gated-at.bofh.it> (permalink)
References <qAAAF-6D4-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Nov 30, 2015 at 6:30 PM, Jose Diaz de Grenu de Pedro
<Jose.DiazdeGrenudePedro@digi.com> wrote:

> Commit 79a9becda894 moved the awareness of active low state
> into the gpiod_get_value*() functions, but it only inverts the
> GPIO's raw value when it is active low. If the GPIO is active
> high, the gpiod_get_value*() functions return the raw value of
> the register, which can be any positive value.

No, because:

static int _gpiod_get_raw_value(const struct gpio_desc *desc)
{
        struct gpio_chip        *chip;
        int offset;
        int value;

        chip = desc->chip;
        offset = gpio_chip_hwgpio(desc);
        value = chip->get ? chip->get(chip, offset) : -EIO;
        value = value < 0 ? value : !!value;
        trace_gpio_value(desc_to_gpio(desc), 1, value);
        return value;
}

This returns a negative error code or the value clamped to [0,1]

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v2] gpiolib: return 0 or 1 in gpiod_get_value*() functions Jose Diaz de Grenu de Pedro <Jose.DiazdeGrenudePedro@digi.com> - 2015-11-30 18:40 +0100
  Re: [PATCH v2] gpiolib: return 0 or 1 in gpiod_get_value*() functions Bjorn Andersson <bjorn@kryo.se> - 2015-11-30 21:10 +0100
  Re: [PATCH v2] gpiolib: return 0 or 1 in gpiod_get_value*() functions Linus Walleij <linus.walleij@linaro.org> - 2015-12-10 18:00 +0100

csiph-web