Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of/gpio: export of_gpio_simple_xlate

Allow GPIO drivers to use of_gpio_simple_xlate. This is useful for the
generic GPIO driver for example where gpio_chip is embedded in
bgpio_chip and doesn't need of_mm_gpio_chip but has a simple 1:1 GPIO
mapping.

Cc: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

authored by

Jamie Iles and committed by
Grant Likely
3038bbdf 95b68865

+12 -2
+3 -2
drivers/of/gpio.c
··· 127 127 * gpio chips. This function performs only one sanity check: whether gpio 128 128 * is less than ngpios (that is specified in the gpio_chip). 129 129 */ 130 - static int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, 131 - const void *gpio_spec, u32 *flags) 130 + int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, 131 + const void *gpio_spec, u32 *flags) 132 132 { 133 133 const __be32 *gpio = gpio_spec; 134 134 const u32 n = be32_to_cpup(gpio); ··· 152 152 153 153 return n; 154 154 } 155 + EXPORT_SYMBOL(of_gpio_simple_xlate); 155 156 156 157 /** 157 158 * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank)
+9
include/linux/of_gpio.h
··· 57 57 extern void of_gpiochip_add(struct gpio_chip *gc); 58 58 extern void of_gpiochip_remove(struct gpio_chip *gc); 59 59 extern struct gpio_chip *of_node_to_gpiochip(struct device_node *np); 60 + extern int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, 61 + const void *gpio_spec, u32 *flags); 60 62 61 63 #else /* CONFIG_OF_GPIO */ 62 64 ··· 72 70 static inline unsigned int of_gpio_count(struct device_node *np) 73 71 { 74 72 return 0; 73 + } 74 + 75 + static inline int of_gpio_simple_xlate(struct gpio_chip *gc, 76 + struct device_node *np, 77 + const void *gpio_spec, u32 *flags) 78 + { 79 + return -ENOSYS; 75 80 } 76 81 77 82 static inline void of_gpiochip_add(struct gpio_chip *gc) { }