1
0
Files
linux/Documentation
Thierry Reding 29a1f2333e gpio: Add helpers for optional GPIOs
Introduce gpiod_get_optional() and gpiod_get_index_optional() helpers
that make it easier for drivers to handle optional GPIOs.

Currently in order to handle optional GPIOs, a driver needs to special
case error handling for -ENOENT, such as this:

	gpio = gpiod_get(dev, "foo");
	if (IS_ERR(gpio)) {
		if (PTR_ERR(gpio) != -ENOENT)
			return PTR_ERR(gpio);

		gpio = NULL;
	}

	if (gpio) {
		/* set up GPIO */
	}

With these new helpers the above is reduced to:

	gpio = gpiod_get_optional(dev, "foo");
	if (IS_ERR(gpio))
		return PTR_ERR(gpio);

	if (gpio) {
		/* set up GPIO */
	}

While at it, device-managed variants of these functions are also
provided.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-05-09 13:48:30 +02:00
..
2014-04-07 16:36:02 -07:00
2014-03-27 16:56:23 -04:00
2014-03-11 06:55:49 -03:00
2014-02-10 16:01:40 -08:00
2014-02-28 15:12:08 -08:00
2014-02-10 16:01:40 -08:00
2014-03-21 13:16:58 +01:00
2014-03-21 13:16:58 +01:00
2014-03-21 13:16:58 +01:00
2014-02-18 08:09:40 -08:00
2014-02-07 08:03:07 -02:00
2014-03-21 13:16:58 +01:00
2014-03-21 13:16:58 +01:00