[PATCH 1/5] of/gpio: export of_simple_xlate function

Anton Vorontsov avorontsov at ru.mvista.com
Thu Mar 27 07:24:16 EST 2008


So we'll able to use it for the non-memory mapped drivers (like
I2C GPIO expanders).

Signed-off-by: Anton Vorontsov <avorontsov at ru.mvista.com>
---

Depends on the previous OF GPIO work.

 drivers/of/gpio.c       |    6 +++---
 include/linux/of_gpio.h |   13 +++++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
index a6775ff..03e2fed 100644
--- a/drivers/of/gpio.c
+++ b/drivers/of/gpio.c
@@ -106,9 +106,8 @@ err0:
 }
 EXPORT_SYMBOL(of_get_gpio);
 
-static int of_gpio_simple_xlate(struct of_gpio_chip *of_gc,
-				struct device_node *np,
-				const void *gpio_spec)
+int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,
+			 const void *gpio_spec)
 {
 	const u32 *gpio = gpio_spec;
 
@@ -117,6 +116,7 @@ static int of_gpio_simple_xlate(struct of_gpio_chip *of_gc,
 
 	return *gpio;
 }
+EXPORT_SYMBOL(of_gpio_simple_xlate);
 
 int of_mm_gpiochip_add(struct device_node *np,
 		       struct of_mm_gpio_chip *mm_gc)
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index ca313f0..75c209c 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -83,6 +83,19 @@ extern int of_get_gpio(struct device_node *np, int index);
 extern int of_mm_gpiochip_add(struct device_node *np,
 			      struct of_mm_gpio_chip *mm_gc);
 
+/**
+ * of_gpio_simple_xlate - translate gpio_spec to the GPIO number
+ * @of_gc:	pointer to the of_gpio_chip structure
+ * @np:		device node of the GPIO chip
+ * @gpio_spec:	gpio specifier as found in the device tree
+ *
+ * This is simple translation function, suitable for the most 1:1 mapped
+ * gpio chips. This function performs only one sanity check: whether gpio
+ * is less than ngpios (that is specified in the gpio_chip).
+ */
+extern int of_gpio_simple_xlate(struct of_gpio_chip *of_gc,
+				struct device_node *np,
+				const void *gpio_spec);
 #else
 
 /* Drivers may not strictly depend on the GPIO support, so let them link. */
-- 
1.5.2.2




More information about the Linuxppc-dev mailing list