Re: [PATCH v2 1/2] gpio: davinci: don't create irq_domain in case of unbanked irqs

2013-12-23 Thread Grygorii Strashko

On 12/22/2013 05:52 PM, Sekhar Nori wrote:

On Wednesday 18 December 2013 03:37 PM, Grygorii Strashko wrote:

The system may crash if:
- there are more then 1 bank


s/then/than


- unbanked irqs are enabled
- someone will call gpio_to_irq() for GPIO from bank2 or above

Hence, fix it by not creating irq_domain if unbanked irqs are enabled
and correct gpio_to_irq_banked() to handle this properly.

Cc: Linus Walleij 
Cc: Alexandre Courbot 
Cc: Sekhar Nori 

Acked-by: Santosh Shilimkar 
Signed-off-by: Grygorii Strashko 
---
  drivers/gpio/gpio-davinci.c |   34 +++---
  1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 5d163c0..1b33806 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -351,7 +351,10 @@ static int gpio_to_irq_banked(struct gpio_chip *chip, 
unsigned offset)
  {
struct davinci_gpio_controller *d = chip2controller(chip);

-   return irq_create_mapping(d->irq_domain, d->chip.base + offset);
+   if (d->irq_domain)
+   return irq_create_mapping(d->irq_domain, d->chip.base + offset);
+   else
+   return -ENXIO;
  }

  static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
@@ -429,7 +432,7 @@ static int davinci_gpio_irq_setup(struct platform_device 
*pdev)
struct davinci_gpio_controller *chips = platform_get_drvdata(pdev);
struct davinci_gpio_platform_data *pdata = dev->platform_data;
struct davinci_gpio_regs __iomem *g;
-   struct irq_domain   *irq_domain;
+   struct irq_domain   *irq_domain = NULL;

ngpio = pdata->ngpio;
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -453,18 +456,20 @@ static int davinci_gpio_irq_setup(struct platform_device 
*pdev)
}
clk_prepare_enable(clk);

-   irq = irq_alloc_descs(-1, 0, ngpio, 0);
-   if (irq < 0) {
-   dev_err(dev, "Couldn't allocate IRQ numbers\n");
-   return irq;
-   }
+   if (!pdata->gpio_unbanked) {
+   irq = irq_alloc_descs(-1, 0, ngpio, 0);
+   if (irq < 0) {
+   dev_err(dev, "Couldn't allocate IRQ numbers\n");
+   return -ENODEV;


The code was correct before moving. Any objections to doing

return irq;

instead?


This is mistake. I'll update. Thanks



Thanks,
Sekhar



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/2] gpio: davinci: don't create irq_domain in case of unbanked irqs

2013-12-23 Thread Grygorii Strashko

On 12/22/2013 05:52 PM, Sekhar Nori wrote:

On Wednesday 18 December 2013 03:37 PM, Grygorii Strashko wrote:

The system may crash if:
- there are more then 1 bank


s/then/than


- unbanked irqs are enabled
- someone will call gpio_to_irq() for GPIO from bank2 or above

Hence, fix it by not creating irq_domain if unbanked irqs are enabled
and correct gpio_to_irq_banked() to handle this properly.

Cc: Linus Walleij linus.wall...@linaro.org
Cc: Alexandre Courbot gnu...@gmail.com
Cc: Sekhar Nori nsek...@ti.com

Acked-by: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Grygorii Strashko grygorii.stras...@ti.com
---
  drivers/gpio/gpio-davinci.c |   34 +++---
  1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 5d163c0..1b33806 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -351,7 +351,10 @@ static int gpio_to_irq_banked(struct gpio_chip *chip, 
unsigned offset)
  {
struct davinci_gpio_controller *d = chip2controller(chip);

-   return irq_create_mapping(d-irq_domain, d-chip.base + offset);
+   if (d-irq_domain)
+   return irq_create_mapping(d-irq_domain, d-chip.base + offset);
+   else
+   return -ENXIO;
  }

  static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
@@ -429,7 +432,7 @@ static int davinci_gpio_irq_setup(struct platform_device 
*pdev)
struct davinci_gpio_controller *chips = platform_get_drvdata(pdev);
struct davinci_gpio_platform_data *pdata = dev-platform_data;
struct davinci_gpio_regs __iomem *g;
-   struct irq_domain   *irq_domain;
+   struct irq_domain   *irq_domain = NULL;

ngpio = pdata-ngpio;
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -453,18 +456,20 @@ static int davinci_gpio_irq_setup(struct platform_device 
*pdev)
}
clk_prepare_enable(clk);

-   irq = irq_alloc_descs(-1, 0, ngpio, 0);
-   if (irq  0) {
-   dev_err(dev, Couldn't allocate IRQ numbers\n);
-   return irq;
-   }
+   if (!pdata-gpio_unbanked) {
+   irq = irq_alloc_descs(-1, 0, ngpio, 0);
+   if (irq  0) {
+   dev_err(dev, Couldn't allocate IRQ numbers\n);
+   return -ENODEV;


The code was correct before moving. Any objections to doing

return irq;

instead?


This is mistake. I'll update. Thanks



Thanks,
Sekhar



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/2] gpio: davinci: don't create irq_domain in case of unbanked irqs

2013-12-22 Thread Sekhar Nori
On Wednesday 18 December 2013 03:37 PM, Grygorii Strashko wrote:
> The system may crash if:
> - there are more then 1 bank

s/then/than

> - unbanked irqs are enabled
> - someone will call gpio_to_irq() for GPIO from bank2 or above
> 
> Hence, fix it by not creating irq_domain if unbanked irqs are enabled
> and correct gpio_to_irq_banked() to handle this properly.
> 
> Cc: Linus Walleij 
> Cc: Alexandre Courbot 
> Cc: Sekhar Nori 
> 
> Acked-by: Santosh Shilimkar 
> Signed-off-by: Grygorii Strashko 
> ---
>  drivers/gpio/gpio-davinci.c |   34 +++---
>  1 file changed, 19 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
> index 5d163c0..1b33806 100644
> --- a/drivers/gpio/gpio-davinci.c
> +++ b/drivers/gpio/gpio-davinci.c
> @@ -351,7 +351,10 @@ static int gpio_to_irq_banked(struct gpio_chip *chip, 
> unsigned offset)
>  {
>   struct davinci_gpio_controller *d = chip2controller(chip);
>  
> - return irq_create_mapping(d->irq_domain, d->chip.base + offset);
> + if (d->irq_domain)
> + return irq_create_mapping(d->irq_domain, d->chip.base + offset);
> + else
> + return -ENXIO;
>  }
>  
>  static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
> @@ -429,7 +432,7 @@ static int davinci_gpio_irq_setup(struct platform_device 
> *pdev)
>   struct davinci_gpio_controller *chips = platform_get_drvdata(pdev);
>   struct davinci_gpio_platform_data *pdata = dev->platform_data;
>   struct davinci_gpio_regs __iomem *g;
> - struct irq_domain   *irq_domain;
> + struct irq_domain   *irq_domain = NULL;
>  
>   ngpio = pdata->ngpio;
>   res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> @@ -453,18 +456,20 @@ static int davinci_gpio_irq_setup(struct 
> platform_device *pdev)
>   }
>   clk_prepare_enable(clk);
>  
> - irq = irq_alloc_descs(-1, 0, ngpio, 0);
> - if (irq < 0) {
> - dev_err(dev, "Couldn't allocate IRQ numbers\n");
> - return irq;
> - }
> + if (!pdata->gpio_unbanked) {
> + irq = irq_alloc_descs(-1, 0, ngpio, 0);
> + if (irq < 0) {
> + dev_err(dev, "Couldn't allocate IRQ numbers\n");
> + return -ENODEV;

The code was correct before moving. Any objections to doing

return irq;

instead?

Thanks,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/2] gpio: davinci: don't create irq_domain in case of unbanked irqs

2013-12-22 Thread Sekhar Nori
On Wednesday 18 December 2013 03:37 PM, Grygorii Strashko wrote:
 The system may crash if:
 - there are more then 1 bank

s/then/than

 - unbanked irqs are enabled
 - someone will call gpio_to_irq() for GPIO from bank2 or above
 
 Hence, fix it by not creating irq_domain if unbanked irqs are enabled
 and correct gpio_to_irq_banked() to handle this properly.
 
 Cc: Linus Walleij linus.wall...@linaro.org
 Cc: Alexandre Courbot gnu...@gmail.com
 Cc: Sekhar Nori nsek...@ti.com
 
 Acked-by: Santosh Shilimkar santosh.shilim...@ti.com
 Signed-off-by: Grygorii Strashko grygorii.stras...@ti.com
 ---
  drivers/gpio/gpio-davinci.c |   34 +++---
  1 file changed, 19 insertions(+), 15 deletions(-)
 
 diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
 index 5d163c0..1b33806 100644
 --- a/drivers/gpio/gpio-davinci.c
 +++ b/drivers/gpio/gpio-davinci.c
 @@ -351,7 +351,10 @@ static int gpio_to_irq_banked(struct gpio_chip *chip, 
 unsigned offset)
  {
   struct davinci_gpio_controller *d = chip2controller(chip);
  
 - return irq_create_mapping(d-irq_domain, d-chip.base + offset);
 + if (d-irq_domain)
 + return irq_create_mapping(d-irq_domain, d-chip.base + offset);
 + else
 + return -ENXIO;
  }
  
  static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
 @@ -429,7 +432,7 @@ static int davinci_gpio_irq_setup(struct platform_device 
 *pdev)
   struct davinci_gpio_controller *chips = platform_get_drvdata(pdev);
   struct davinci_gpio_platform_data *pdata = dev-platform_data;
   struct davinci_gpio_regs __iomem *g;
 - struct irq_domain   *irq_domain;
 + struct irq_domain   *irq_domain = NULL;
  
   ngpio = pdata-ngpio;
   res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 @@ -453,18 +456,20 @@ static int davinci_gpio_irq_setup(struct 
 platform_device *pdev)
   }
   clk_prepare_enable(clk);
  
 - irq = irq_alloc_descs(-1, 0, ngpio, 0);
 - if (irq  0) {
 - dev_err(dev, Couldn't allocate IRQ numbers\n);
 - return irq;
 - }
 + if (!pdata-gpio_unbanked) {
 + irq = irq_alloc_descs(-1, 0, ngpio, 0);
 + if (irq  0) {
 + dev_err(dev, Couldn't allocate IRQ numbers\n);
 + return -ENODEV;

The code was correct before moving. Any objections to doing

return irq;

instead?

Thanks,
Sekhar
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/2] gpio: davinci: don't create irq_domain in case of unbanked irqs

2013-12-21 Thread Prabhakar Lad
On Wed, Dec 18, 2013 at 3:37 PM, Grygorii Strashko
 wrote:
> The system may crash if:
> - there are more then 1 bank
> - unbanked irqs are enabled
> - someone will call gpio_to_irq() for GPIO from bank2 or above
>
> Hence, fix it by not creating irq_domain if unbanked irqs are enabled
> and correct gpio_to_irq_banked() to handle this properly.
>
> Cc: Linus Walleij 
> Cc: Alexandre Courbot 
> Cc: Sekhar Nori 
>
> Acked-by: Santosh Shilimkar 
> Signed-off-by: Grygorii Strashko 

Acked-by: Lad, Prabhakar 

Regards,
--Prabhakar Lad
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/2] gpio: davinci: don't create irq_domain in case of unbanked irqs

2013-12-21 Thread Prabhakar Lad
On Wed, Dec 18, 2013 at 3:37 PM, Grygorii Strashko
grygorii.stras...@ti.com wrote:
 The system may crash if:
 - there are more then 1 bank
 - unbanked irqs are enabled
 - someone will call gpio_to_irq() for GPIO from bank2 or above

 Hence, fix it by not creating irq_domain if unbanked irqs are enabled
 and correct gpio_to_irq_banked() to handle this properly.

 Cc: Linus Walleij linus.wall...@linaro.org
 Cc: Alexandre Courbot gnu...@gmail.com
 Cc: Sekhar Nori nsek...@ti.com

 Acked-by: Santosh Shilimkar santosh.shilim...@ti.com
 Signed-off-by: Grygorii Strashko grygorii.stras...@ti.com

Acked-by: Lad, Prabhakar prabhakar.cse...@gmail.com

Regards,
--Prabhakar Lad
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/