aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-06-08 09:48:16 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-07-05 18:14:30 -0400
commit594fa265e084073443390c5b93d5410fd28e9bcd (patch)
tree42c0e5536ae2fd016159e1e1bd1f27f0a9f3cac2 /include
parenta19e3da5bc5fc6c10ab73f310bea80f3845b4531 (diff)
of/gpio: stop using device_node data pointer to find gpio_chip
Currently the kernel uses the struct device_node.data pointer to resolve a struct gpio_chip pointer from a device tree node. However, the .data member doesn't provide any type checking and there aren't any rules enforced on what it should be used for. There's no guarantee that the data stored in it actually points to an gpio_chip pointer. Instead of relying on the .data pointer, this patch modifies the code to add a lookup function which scans through the registered gpio_chips and returns the gpio_chip that has a pointer to the specified device_node. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> CC: Andrew Morton <akpm@linux-foundation.org> CC: Anton Vorontsov <avorontsov@ru.mvista.com> CC: Grant Likely <grant.likely@secretlab.ca> CC: David Brownell <dbrownell@users.sourceforge.net> CC: Bill Gatliff <bgat@billgatliff.com> CC: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org> CC: Jean Delvare <khali@linux-fr.org> CC: linux-kernel@vger.kernel.org CC: devicetree-discuss@lists.ozlabs.org
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/gpio.h3
-rw-r--r--include/linux/of_gpio.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index af2544ef0b59..c7376bf80b06 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -127,6 +127,9 @@ extern int __must_check gpiochip_reserve(int start, int ngpio);
127/* add/remove chips */ 127/* add/remove chips */
128extern int gpiochip_add(struct gpio_chip *chip); 128extern int gpiochip_add(struct gpio_chip *chip);
129extern int __must_check gpiochip_remove(struct gpio_chip *chip); 129extern int __must_check gpiochip_remove(struct gpio_chip *chip);
130extern struct gpio_chip *gpiochip_find(void *data,
131 int (*match)(struct gpio_chip *chip,
132 void *data));
130 133
131 134
132/* Always use the library code for GPIO management calls, 135/* Always use the library code for GPIO management calls,
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index 460d6810c5eb..1020587efed1 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -54,6 +54,9 @@ extern int of_mm_gpiochip_add(struct device_node *np,
54 struct of_mm_gpio_chip *mm_gc); 54 struct of_mm_gpio_chip *mm_gc);
55extern int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, 55extern int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np,
56 const void *gpio_spec, u32 *flags); 56 const void *gpio_spec, u32 *flags);
57
58extern struct gpio_chip *of_node_to_gpiochip(struct device_node *np);
59
57#else /* CONFIG_OF_GPIO */ 60#else /* CONFIG_OF_GPIO */
58 61
59/* Drivers may not strictly depend on the GPIO support, so let them link. */ 62/* Drivers may not strictly depend on the GPIO support, so let them link. */