From a19e3da5bc5fc6c10ab73f310bea80f3845b4531 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Tue, 8 Jun 2010 07:48:16 -0600 Subject: of/gpio: Kill of_gpio_chip and add members directly to gpio_chip The OF gpio infrastructure is great for describing GPIO connections within the device tree. However, using a GPIO binding still requires changes to the gpio controller just to add an of_gpio structure. In most cases, the gpio controller doesn't actually need any special support and the simple OF gpio mapping function is more than sufficient. Additional, the current scheme of using of_gpio_chip requires a convoluted scheme to maintain 1:1 mappings between of_gpio_chip and gpio_chip instances. If the struct of_gpio_chip data members were moved into struct gpio_chip, then it would simplify the processing of OF gpio bindings, and it would make it trivial to use device tree OF connections on existing gpiolib controller drivers. This patch eliminates the of_gpio_chip structure and moves the relevant fields into struct gpio_chip (conditional on CONFIG_OF_GPIO). This move simplifies the existing code and prepares for adding automatic device tree support to existing drivers. Signed-off-by: Grant Likely Cc: Andrew Morton Cc: Anton Vorontsov Cc: Grant Likely Cc: David Brownell Cc: Bill Gatliff Cc: Dmitry Eremin-Solenikov Cc: Benjamin Herrenschmidt Cc: Jean Delvare --- arch/microblaze/kernel/reset.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'arch/microblaze/kernel/reset.c') diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c index a1721a3..5476d3c 100644 --- a/arch/microblaze/kernel/reset.c +++ b/arch/microblaze/kernel/reset.c @@ -24,8 +24,8 @@ static int of_reset_gpio_handle(void) int ret; /* variable which stored handle reset gpio pin */ struct device_node *root; /* root node */ struct device_node *gpio; /* gpio node */ - struct of_gpio_chip *of_gc = NULL; - enum of_gpio_flags flags ; + struct gpio_chip *gc; + u32 flags; const void *gpio_spec; /* find out root node */ @@ -39,19 +39,19 @@ static int of_reset_gpio_handle(void) goto err0; } - of_gc = gpio->data; - if (!of_gc) { + gc = gpio->data; + if (!gc) { pr_debug("%s: gpio controller %s isn't registered\n", root->full_name, gpio->full_name); ret = -ENODEV; goto err1; } - ret = of_gc->xlate(of_gc, root, gpio_spec, &flags); + ret = gc->of_xlate(gc, root, gpio_spec, &flags); if (ret < 0) goto err1; - ret += of_gc->gc.base; + ret += gc->base; err1: of_node_put(gpio); err0: -- cgit v1.1 From 594fa265e084073443390c5b93d5410fd28e9bcd Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Tue, 8 Jun 2010 07:48:16 -0600 Subject: 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 CC: Andrew Morton CC: Anton Vorontsov CC: Grant Likely CC: David Brownell CC: Bill Gatliff CC: Dmitry Eremin-Solenikov CC: Benjamin Herrenschmidt CC: Jean Delvare CC: linux-kernel@vger.kernel.org CC: devicetree-discuss@lists.ozlabs.org --- arch/microblaze/kernel/reset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/microblaze/kernel/reset.c') diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c index 5476d3c..bd8ccab 100644 --- a/arch/microblaze/kernel/reset.c +++ b/arch/microblaze/kernel/reset.c @@ -39,7 +39,7 @@ static int of_reset_gpio_handle(void) goto err0; } - gc = gpio->data; + gc = of_node_to_gpiochip(gpio); if (!gc) { pr_debug("%s: gpio controller %s isn't registered\n", root->full_name, gpio->full_name); -- cgit v1.1