diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2013-10-17 13:21:37 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-10-19 17:24:52 -0400 |
commit | af8b6375a8291fe2cf77707f3edec86b98a999cc (patch) | |
tree | 2e4970d4e726411586dbc2143f27ba49ff50142e /include/linux/of_gpio.h | |
parent | 79a9becda8940deb2274b5aa4577c86d52ee7ecb (diff) |
gpiolib: port of_ functions to use gpiod
Refactor the of_ functions of gpiolib to use the now public gpiod
interface, and export of_get_named_gpiod_flags() and
of_get_gpiod_flags() functions.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/of_gpio.h')
-rw-r--r-- | include/linux/of_gpio.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index a83dc6f5008e..d71f2cc141ae 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/of.h> | 21 | #include <linux/of.h> |
22 | 22 | ||
23 | struct device_node; | 23 | struct device_node; |
24 | struct gpio_desc; | ||
24 | 25 | ||
25 | /* | 26 | /* |
26 | * This is Linux-specific flags. By default controllers' and Linux' mapping | 27 | * This is Linux-specific flags. By default controllers' and Linux' mapping |
@@ -47,7 +48,7 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) | |||
47 | return container_of(gc, struct of_mm_gpio_chip, gc); | 48 | return container_of(gc, struct of_mm_gpio_chip, gc); |
48 | } | 49 | } |
49 | 50 | ||
50 | extern int of_get_named_gpio_flags(struct device_node *np, | 51 | extern struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, |
51 | const char *list_name, int index, enum of_gpio_flags *flags); | 52 | const char *list_name, int index, enum of_gpio_flags *flags); |
52 | 53 | ||
53 | extern int of_mm_gpiochip_add(struct device_node *np, | 54 | extern int of_mm_gpiochip_add(struct device_node *np, |
@@ -62,10 +63,10 @@ extern int of_gpio_simple_xlate(struct gpio_chip *gc, | |||
62 | #else /* CONFIG_OF_GPIO */ | 63 | #else /* CONFIG_OF_GPIO */ |
63 | 64 | ||
64 | /* Drivers may not strictly depend on the GPIO support, so let them link. */ | 65 | /* Drivers may not strictly depend on the GPIO support, so let them link. */ |
65 | static inline int of_get_named_gpio_flags(struct device_node *np, | 66 | static inline struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, |
66 | const char *list_name, int index, enum of_gpio_flags *flags) | 67 | const char *list_name, int index, enum of_gpio_flags *flags) |
67 | { | 68 | { |
68 | return -ENOSYS; | 69 | return ERR_PTR(-ENOSYS); |
69 | } | 70 | } |
70 | 71 | ||
71 | static inline int of_gpio_simple_xlate(struct gpio_chip *gc, | 72 | static inline int of_gpio_simple_xlate(struct gpio_chip *gc, |
@@ -80,6 +81,18 @@ static inline void of_gpiochip_remove(struct gpio_chip *gc) { } | |||
80 | 81 | ||
81 | #endif /* CONFIG_OF_GPIO */ | 82 | #endif /* CONFIG_OF_GPIO */ |
82 | 83 | ||
84 | static inline int of_get_named_gpio_flags(struct device_node *np, | ||
85 | const char *list_name, int index, enum of_gpio_flags *flags) | ||
86 | { | ||
87 | struct gpio_desc *desc; | ||
88 | desc = of_get_named_gpiod_flags(np, list_name, index, flags); | ||
89 | |||
90 | if (IS_ERR(desc)) | ||
91 | return PTR_ERR(desc); | ||
92 | else | ||
93 | return desc_to_gpio(desc); | ||
94 | } | ||
95 | |||
83 | /** | 96 | /** |
84 | * of_gpio_named_count() - Count GPIOs for a device | 97 | * of_gpio_named_count() - Count GPIOs for a device |
85 | * @np: device node to count GPIOs for | 98 | * @np: device node to count GPIOs for |
@@ -117,15 +130,21 @@ static inline int of_gpio_count(struct device_node *np) | |||
117 | } | 130 | } |
118 | 131 | ||
119 | /** | 132 | /** |
120 | * of_get_gpio_flags() - Get a GPIO number and flags to use with GPIO API | 133 | * of_get_gpiod_flags() - Get a GPIO descriptor and flags to use with GPIO API |
121 | * @np: device node to get GPIO from | 134 | * @np: device node to get GPIO from |
122 | * @index: index of the GPIO | 135 | * @index: index of the GPIO |
123 | * @flags: a flags pointer to fill in | 136 | * @flags: a flags pointer to fill in |
124 | * | 137 | * |
125 | * Returns GPIO number to use with Linux generic GPIO API, or one of the errno | 138 | * Returns GPIO descriptor to use with Linux generic GPIO API, or a errno |
126 | * value on the error condition. If @flags is not NULL the function also fills | 139 | * value on the error condition. If @flags is not NULL the function also fills |
127 | * in flags for the GPIO. | 140 | * in flags for the GPIO. |
128 | */ | 141 | */ |
142 | static inline struct gpio_desc *of_get_gpiod_flags(struct device_node *np, | ||
143 | int index, enum of_gpio_flags *flags) | ||
144 | { | ||
145 | return of_get_named_gpiod_flags(np, "gpios", index, flags); | ||
146 | } | ||
147 | |||
129 | static inline int of_get_gpio_flags(struct device_node *np, int index, | 148 | static inline int of_get_gpio_flags(struct device_node *np, int index, |
130 | enum of_gpio_flags *flags) | 149 | enum of_gpio_flags *flags) |
131 | { | 150 | { |