public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/7] gpio/mxs: convert to use linear irqdomain
@ 2012-10-16 19:22 Linus Walleij
  2012-10-18  6:22 ` Shawn Guo
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2012-10-16 19:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rob Herring, Grant Likely, Linus Walleij, Shawn Guo

The MXS driver tries to do the work of irq_domain_add_linear()
by reserving a bunch of descriptors somewhere and keeping track
of the base offset, then calling irq_domain_add_legacy(). Let's
stop doing that and simply use the linear IRQ domain.

Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-mxs.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index 796fb13..71fd5b1 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -223,7 +223,6 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
 	static void __iomem *base;
 	struct mxs_gpio_port *port;
 	struct resource *iores = NULL;
-	int irq_base;
 	int err;
 
 	port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
@@ -272,16 +271,10 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
 	/* clear address has to be used to clear IRQSTAT bits */
 	writel(~0U, port->base + PINCTRL_IRQSTAT(port) + MXS_CLR);
 
-	irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id());
-	if (irq_base < 0)
-		return irq_base;
-
-	port->domain = irq_domain_add_legacy(np, 32, irq_base, 0,
+	port->domain = irq_domain_add_linear(np, 32,
 					     &irq_domain_simple_ops, NULL);
-	if (!port->domain) {
-		err = -ENODEV;
-		goto out_irqdesc_free;
-	}
+	if (!port->domain)
+		return -ENODEV;
 
 	/* gpio-mxs can be a generic irq chip */
 	mxs_gpio_init_gc(port, irq_base);
@@ -295,7 +288,7 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
 			 port->base + PINCTRL_DOUT(port), NULL,
 			 port->base + PINCTRL_DOE(port), NULL, 0);
 	if (err)
-		goto out_irqdesc_free;
+		goto out_irqdomain_remove;
 
 	port->bgc.gc.to_irq = mxs_gpio_to_irq;
 	port->bgc.gc.base = port->id * 32;
@@ -308,8 +301,8 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
 
 out_bgpio_remove:
 	bgpio_remove(&port->bgc);
-out_irqdesc_free:
-	irq_free_descs(irq_base, 32);
+out_irqdomain_remove:
+	irq_domain_remove(port->domain);
 	return err;
 }
 
-- 
1.7.11.7


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

* Re: [PATCH 4/7] gpio/mxs: convert to use linear irqdomain
  2012-10-16 19:22 [PATCH 4/7] gpio/mxs: convert to use linear irqdomain Linus Walleij
@ 2012-10-18  6:22 ` Shawn Guo
  2012-10-18 14:56   ` Rob Herring
  2012-10-19 10:22   ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Shawn Guo @ 2012-10-18  6:22 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel, Rob Herring, Grant Likely

On Tue, Oct 16, 2012 at 09:22:56PM +0200, Linus Walleij wrote:
> The MXS driver tries to do the work of irq_domain_add_linear()
> by reserving a bunch of descriptors somewhere and keeping track
> of the base offset, then calling irq_domain_add_legacy(). Let's
> stop doing that and simply use the linear IRQ domain.
> 
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpio/gpio-mxs.c | 19 ++++++-------------
>  1 file changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
> index 796fb13..71fd5b1 100644
> --- a/drivers/gpio/gpio-mxs.c
> +++ b/drivers/gpio/gpio-mxs.c
> @@ -223,7 +223,6 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
>  	static void __iomem *base;
>  	struct mxs_gpio_port *port;
>  	struct resource *iores = NULL;
> -	int irq_base;

...

>  	int err;
>  
>  	port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
> @@ -272,16 +271,10 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
>  	/* clear address has to be used to clear IRQSTAT bits */
>  	writel(~0U, port->base + PINCTRL_IRQSTAT(port) + MXS_CLR);
>  
> -	irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id());
> -	if (irq_base < 0)
> -		return irq_base;
> -
> -	port->domain = irq_domain_add_legacy(np, 32, irq_base, 0,
> +	port->domain = irq_domain_add_linear(np, 32,
>  					     &irq_domain_simple_ops, NULL);
> -	if (!port->domain) {
> -		err = -ENODEV;
> -		goto out_irqdesc_free;
> -	}
> +	if (!port->domain)
> +		return -ENODEV;
>  
>  	/* gpio-mxs can be a generic irq chip */
>  	mxs_gpio_init_gc(port, irq_base);
                               ^^^^^^^^

So I know this one is not compile-tested.

This is exactly the reason why I have to use irq_domain_add_legacy
other than irq_domain_add_linear when I add irqdomain support for the
driver.  The driver uses generic-irq infrastructural which needs
irq_base for setup.  So sadly, before generic-irq gets improved, any
irq chip that uses generic-irq will have to use irq_domain_add_legacy.

Shawn

> @@ -295,7 +288,7 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
>  			 port->base + PINCTRL_DOUT(port), NULL,
>  			 port->base + PINCTRL_DOE(port), NULL, 0);
>  	if (err)
> -		goto out_irqdesc_free;
> +		goto out_irqdomain_remove;
>  
>  	port->bgc.gc.to_irq = mxs_gpio_to_irq;
>  	port->bgc.gc.base = port->id * 32;
> @@ -308,8 +301,8 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
>  
>  out_bgpio_remove:
>  	bgpio_remove(&port->bgc);
> -out_irqdesc_free:
> -	irq_free_descs(irq_base, 32);
> +out_irqdomain_remove:
> +	irq_domain_remove(port->domain);
>  	return err;
>  }
>  
> -- 
> 1.7.11.7
> 

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

* Re: [PATCH 4/7] gpio/mxs: convert to use linear irqdomain
  2012-10-18  6:22 ` Shawn Guo
@ 2012-10-18 14:56   ` Rob Herring
  2012-10-19 10:22   ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Rob Herring @ 2012-10-18 14:56 UTC (permalink / raw)
  To: Shawn Guo; +Cc: Linus Walleij, linux-kernel, Grant Likely

On 10/18/2012 01:22 AM, Shawn Guo wrote:
> On Tue, Oct 16, 2012 at 09:22:56PM +0200, Linus Walleij wrote:
>> The MXS driver tries to do the work of irq_domain_add_linear()
>> by reserving a bunch of descriptors somewhere and keeping track
>> of the base offset, then calling irq_domain_add_legacy(). Let's
>> stop doing that and simply use the linear IRQ domain.
>>
>> Cc: Rob Herring <rob.herring@calxeda.com>
>> Cc: Grant Likely <grant.likely@secretlab.ca>
>> Cc: Shawn Guo <shawn.guo@linaro.org>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>> ---
>>  drivers/gpio/gpio-mxs.c | 19 ++++++-------------
>>  1 file changed, 6 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
>> index 796fb13..71fd5b1 100644
>> --- a/drivers/gpio/gpio-mxs.c
>> +++ b/drivers/gpio/gpio-mxs.c
>> @@ -223,7 +223,6 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
>>  	static void __iomem *base;
>>  	struct mxs_gpio_port *port;
>>  	struct resource *iores = NULL;
>> -	int irq_base;
> 
> ...
> 
>>  	int err;
>>  
>>  	port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
>> @@ -272,16 +271,10 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
>>  	/* clear address has to be used to clear IRQSTAT bits */
>>  	writel(~0U, port->base + PINCTRL_IRQSTAT(port) + MXS_CLR);
>>  
>> -	irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id());
>> -	if (irq_base < 0)
>> -		return irq_base;
>> -
>> -	port->domain = irq_domain_add_legacy(np, 32, irq_base, 0,
>> +	port->domain = irq_domain_add_linear(np, 32,
>>  					     &irq_domain_simple_ops, NULL);
>> -	if (!port->domain) {
>> -		err = -ENODEV;
>> -		goto out_irqdesc_free;
>> -	}
>> +	if (!port->domain)
>> +		return -ENODEV;
>>  
>>  	/* gpio-mxs can be a generic irq chip */
>>  	mxs_gpio_init_gc(port, irq_base);
>                                ^^^^^^^^
> 
> So I know this one is not compile-tested.
> 
> This is exactly the reason why I have to use irq_domain_add_legacy
> other than irq_domain_add_linear when I add irqdomain support for the
> driver.  The driver uses generic-irq infrastructural which needs
> irq_base for setup.  So sadly, before generic-irq gets improved, any
> irq chip that uses generic-irq will have to use irq_domain_add_legacy.

We should get someone to work on that. ;)

I think I need to go back and just fix this aspect rather than try and
integrate irqdomains into generic-irqchip.

Rob

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

* Re: [PATCH 4/7] gpio/mxs: convert to use linear irqdomain
  2012-10-18  6:22 ` Shawn Guo
  2012-10-18 14:56   ` Rob Herring
@ 2012-10-19 10:22   ` Linus Walleij
  2012-10-19 15:30     ` Shawn Guo
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2012-10-19 10:22 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-kernel, Rob Herring, Grant Likely

On Thu, Oct 18, 2012 at 8:22 AM, Shawn Guo <shawn.guo@linaro.org> wrote:

>>       /* gpio-mxs can be a generic irq chip */
>>       mxs_gpio_init_gc(port, irq_base);
>                                ^^^^^^^^
>
> So I know this one is not compile-tested.

No, which defconfig shall I use for this driver?

> This is exactly the reason why I have to use irq_domain_add_legacy
> other than irq_domain_add_linear when I add irqdomain support for the
> driver.  The driver uses generic-irq infrastructural which needs
> irq_base for setup.  So sadly, before generic-irq gets improved, any
> irq chip that uses generic-irq will have to use irq_domain_add_legacy.

Bah, I'm dropping this and a lot of the other patches as well.

I obviously do not understand the inner transcendental meaning of
irqdomains yet.

Yours,
Linus Walleij

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

* Re: [PATCH 4/7] gpio/mxs: convert to use linear irqdomain
  2012-10-19 10:22   ` Linus Walleij
@ 2012-10-19 15:30     ` Shawn Guo
  0 siblings, 0 replies; 5+ messages in thread
From: Shawn Guo @ 2012-10-19 15:30 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel, Rob Herring, Grant Likely

On 19 October 2012 18:22, Linus Walleij <linus.walleij@linaro.org> wrote:
> No, which defconfig shall I use for this driver?
>
mxs_defconfig

Shawn

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

end of thread, other threads:[~2012-10-19 15:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-16 19:22 [PATCH 4/7] gpio/mxs: convert to use linear irqdomain Linus Walleij
2012-10-18  6:22 ` Shawn Guo
2012-10-18 14:56   ` Rob Herring
2012-10-19 10:22   ` Linus Walleij
2012-10-19 15:30     ` Shawn Guo

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