public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
* [PATCH] of/gpio: use dynamic base allocation
@ 2008-04-29 14:05 Anton Vorontsov
  2008-05-19 17:28 ` Anton Vorontsov
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Vorontsov @ 2008-04-29 14:05 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, David Miller

Since gpiolib-dynamic-gpio-number-allocation.patch -mm patch was recently
merged into Linus' tree (commit 8d0aab2f16c4fa170f32e7a74a52cd0122bbafef),
we can use dynamic GPIO base allocation now.

This, in turn, removes number of gpios per chip constraint.

Signed-off-by: Anton Vorontsov <avorontsov@ru•mvista.com>
---
 drivers/of/gpio.c |   38 +-------------------------------------
 1 files changed, 1 insertions(+), 37 deletions(-)

diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
index 000681e..1c9cab8 100644
--- a/drivers/of/gpio.c
+++ b/drivers/of/gpio.c
@@ -137,38 +137,6 @@ int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,
 }
 EXPORT_SYMBOL(of_gpio_simple_xlate);
 
-/* Should be sufficient for now, later we'll use dynamic bases. */
-#if defined(CONFIG_PPC32) || defined(CONFIG_SPARC32)
-#define GPIOS_PER_CHIP 32
-#else
-#define GPIOS_PER_CHIP 64
-#endif
-
-static int of_get_gpiochip_base(struct device_node *np)
-{
-	struct device_node *gc = NULL;
-	int gpiochip_base = 0;
-
-	while ((gc = of_find_all_nodes(gc))) {
-		if (!of_get_property(gc, "gpio-controller", NULL))
-			continue;
-
-		if (gc != np) {
-			gpiochip_base += GPIOS_PER_CHIP;
-			continue;
-		}
-
-		of_node_put(gc);
-
-		if (gpiochip_base >= ARCH_NR_GPIOS)
-			return -ENOSPC;
-
-		return gpiochip_base;
-	}
-
-	return -ENOENT;
-}
-
 /**
  * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank)
  * @np:		device node of the GPIO chip
@@ -205,11 +173,7 @@ int of_mm_gpiochip_add(struct device_node *np,
 	if (!mm_gc->regs)
 		goto err1;
 
-	gc->base = of_get_gpiochip_base(np);
-	if (gc->base < 0) {
-		ret = gc->base;
-		goto err1;
-	}
+	gc->base = -1;
 
 	if (!of_gc->xlate)
 		of_gc->xlate = of_gpio_simple_xlate;
-- 
1.5.5.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] of/gpio: use dynamic base allocation
  2008-04-29 14:05 [PATCH] of/gpio: use dynamic base allocation Anton Vorontsov
@ 2008-05-19 17:28 ` Anton Vorontsov
  0 siblings, 0 replies; 2+ messages in thread
From: Anton Vorontsov @ 2008-05-19 17:28 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, David Miller

On Tue, Apr 29, 2008 at 06:05:24PM +0400, Anton Vorontsov wrote:
> Since gpiolib-dynamic-gpio-number-allocation.patch -mm patch was recently
> merged into Linus' tree (commit 8d0aab2f16c4fa170f32e7a74a52cd0122bbafef),
> we can use dynamic GPIO base allocation now.
> 
> This, in turn, removes number of gpios per chip constraint.
> 
> Signed-off-by: Anton Vorontsov <avorontsov@ru•mvista.com>
> ---

Paul, could you please apply this for the powerpc-next?

Thanks.

>  drivers/of/gpio.c |   38 +-------------------------------------
>  1 files changed, 1 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
> index 000681e..1c9cab8 100644
> --- a/drivers/of/gpio.c
> +++ b/drivers/of/gpio.c
> @@ -137,38 +137,6 @@ int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,
>  }
>  EXPORT_SYMBOL(of_gpio_simple_xlate);
>  
> -/* Should be sufficient for now, later we'll use dynamic bases. */
> -#if defined(CONFIG_PPC32) || defined(CONFIG_SPARC32)
> -#define GPIOS_PER_CHIP 32
> -#else
> -#define GPIOS_PER_CHIP 64
> -#endif
> -
> -static int of_get_gpiochip_base(struct device_node *np)
> -{
> -	struct device_node *gc = NULL;
> -	int gpiochip_base = 0;
> -
> -	while ((gc = of_find_all_nodes(gc))) {
> -		if (!of_get_property(gc, "gpio-controller", NULL))
> -			continue;
> -
> -		if (gc != np) {
> -			gpiochip_base += GPIOS_PER_CHIP;
> -			continue;
> -		}
> -
> -		of_node_put(gc);
> -
> -		if (gpiochip_base >= ARCH_NR_GPIOS)
> -			return -ENOSPC;
> -
> -		return gpiochip_base;
> -	}
> -
> -	return -ENOENT;
> -}
> -
>  /**
>   * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank)
>   * @np:		device node of the GPIO chip
> @@ -205,11 +173,7 @@ int of_mm_gpiochip_add(struct device_node *np,
>  	if (!mm_gc->regs)
>  		goto err1;
>  
> -	gc->base = of_get_gpiochip_base(np);
> -	if (gc->base < 0) {
> -		ret = gc->base;
> -		goto err1;
> -	}
> +	gc->base = -1;
>  
>  	if (!of_gc->xlate)
>  		of_gc->xlate = of_gpio_simple_xlate;
> -- 
> 1.5.5.1

-- 
Anton Vorontsov
email: cbouatmailru@gmail•com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-05-19 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-29 14:05 [PATCH] of/gpio: use dynamic base allocation Anton Vorontsov
2008-05-19 17:28 ` Anton Vorontsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox