Thread (22 messages) 22 messages, 6 authors, 2013-09-23

Re: [RFC 2/5] gpiolib: export descriptor-based GPIO interface

From: Stephen Warren <hidden>
Date: 2013-09-04 19:58:20
Also in: linux-arch, linux-gpio, lkml

On 09/04/2013 05:29 AM, Alexandre Courbot wrote:
This patch exports the gpiod_* family of API functions, a safer
alternative to the legacy gpio interface. Differences between the gpiod
and gpio APIs are:

- gpio works with integers, whereas gpiod operates on opaque handlers
  which cannot be forged or used before proper acquisition
- gpiod get/set functions are aware of the active low state of a GPIO
- gpio consumers should now include <linux/gpio/consumer.h> to access
  the new interface, whereas chips drivers will use
  <linux/gpio/driver.h>

The legacy gpio API is now built as inline functions on top of gpiod.
quoted hunk ↗ jump to hunk
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
+struct gpio_chip {
+	int			(*get_direction)(struct gpio_chip *chip,
+						unsigned offset);
+	int			(*direction_input)(struct gpio_chip *chip,
+						unsigned offset);
+	int			(*get)(struct gpio_chip *chip,
+						unsigned offset);
+	int			(*direction_output)(struct gpio_chip *chip,
+						unsigned offset, int value);
+	int			(*set_debounce)(struct gpio_chip *chip,
+						unsigned offset,
+						unsigned debounce);
+
+	void			(*set)(struct gpio_chip *chip,
+						unsigned offset, int value);
+
Minor nit: It might be nice to sort/group these entries more cohesively,
i.e. get_direction, direction_input, direction_output, get, set,
set_debounce?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help