Skip to contentSkip to conversation

gpio: davinci: driver fixes

PATCH In review Keerthy 4 participants 9 messages Jan 28, 2016 – Feb 10, 2016

Subsystems (2)
lore
Share & tools
lore
author maintainer
#5 lore raw

PATCH 2/2 gpio: davinci: Fix the number of controllers allocated

In reply to Keerthy

From: Lokesh Vutla <[email protected]>

Driver only needs to allocate for [ngpio / 32] controllers, as each controller handles 32 gpios. But the current driver allocates for ngpio of which the extra allocated are unused. Fix it be registering only the required number of controllers.

---
 drivers/gpio/gpio-davinci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpio/gpio-davinci.c +3 -2
index c889f31..cd007a6 100644
@@ -195,7 +195,7 @@ static int davinci_gpio_of_xlate(struct gpio_chip *gc,
 static int davinci_gpio_probe(struct platform_device *pdev)
 {
 	int i, base;
-	unsigned ngpio;
+	unsigned ngpio, nbank;
 	struct davinci_gpio_controller *chips;
 	struct davinci_gpio_platform_data *pdata;
 	struct davinci_gpio_regs __iomem *regs;
@@ -224,8 +224,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
 	if (WARN_ON(ARCH_NR_GPIOS < ngpio))
 		ngpio = ARCH_NR_GPIOS;
 
+	nbank = DIV_ROUND_UP(ngpio, 32);
 	chips = devm_kzalloc(dev,
-			     ngpio * sizeof(struct davinci_gpio_controller),
+			     nbank * sizeof(struct davinci_gpio_controller),
 			     GFP_KERNEL);
 	if (!chips)
 		return -ENOMEM;
Signature · 1 line
1.9.1

Keerthy

author maintainer
#0 lore raw

cover gpio: davinci: driver fixes

The series has couple of for the gpio driver.

Keerthy (1):
gpio: davinci: Add the missing of-node pointer in the
irq_domain_add_legacy function call

Lokesh Vutla (1):
gpio: davinci: Fix the number of controllers allocated

 drivers/gpio/gpio-davinci.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.1
author maintainer
#1 lore raw

PATCH 1/2 gpio: davinci: Add the missing of-node pointer in the irq_domain_add_legacy function call

Currently the first parameter of irq_domain_add_legacy is NULL. irq_find_host function returns NULL when we do not populate the of_node and hence irq_of_parse_and_map call fails whenever we want to request a gpio irq. This fixes the request_irq failures for gpio interrupts.

---
 drivers/gpio/gpio-davinci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-davinci.c +1 -1
index ec58f42..c889f31 100644
@@ -511,7 +511,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
 			return irq;
 		}
 
-		irq_domain = irq_domain_add_legacy(NULL, ngpio, irq, 0,
+		irq_domain = irq_domain_add_legacy(dev->of_node, ngpio, irq, 0,
 							&davinci_gpio_irq_ops,
 							chips);
 		if (!irq_domain) {
Signature · 1 line
1.9.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] gpio: davinci: Add the missing of-node pointer in the irq_domain_add_legacy function call

Quoted 6 lines · Keerthy

Currently the first parameter of irq_domain_add_legacy is NULL. irq_find_host function returns NULL when we do not populate the of_node and hence irq_of_parse_and_map call fails whenever we want to request a gpio irq. This fixes the request_irq failures for gpio interrupts.

Quoted 18 lines
---
  drivers/gpio/gpio-davinci.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-davinci.c +1 -1
index ec58f42..c889f31 100644
@@ -511,7 +511,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
  			return irq;
  		}
 
-		irq_domain = irq_domain_add_legacy(NULL, ngpio, irq, 0,
+		irq_domain = irq_domain_add_legacy(dev->of_node, ngpio, irq, 0,
  							&davinci_gpio_irq_ops,
  							chips);
  		if (!irq_domain) {
Signature · 2 lines
regards,
-grygorii
Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] gpio: davinci: Fix the number of controllers allocated

In reply to Keerthy
Quoted 9 lines · Keerthy

From: Lokesh Vutla <[email protected]>

Driver only needs to allocate for [ngpio / 32] controllers, as each controller handles 32 gpios. But the current driver allocates for ngpio of which the extra allocated are unused. Fix it be registering only the required number of controllers.

Quoted 29 lines
---
  drivers/gpio/gpio-davinci.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpio/gpio-davinci.c +3 -2
index c889f31..cd007a6 100644
@@ -195,7 +195,7 @@ static int davinci_gpio_of_xlate(struct gpio_chip *gc,
  static int davinci_gpio_probe(struct platform_device *pdev)
  {
  	int i, base;
-	unsigned ngpio;
+	unsigned ngpio, nbank;
  	struct davinci_gpio_controller *chips;
  	struct davinci_gpio_platform_data *pdata;
  	struct davinci_gpio_regs __iomem *regs;
@@ -224,8 +224,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
  	if (WARN_ON(ARCH_NR_GPIOS < ngpio))
  		ngpio = ARCH_NR_GPIOS;
 
+	nbank = DIV_ROUND_UP(ngpio, 32);
  	chips = devm_kzalloc(dev,
-			     ngpio * sizeof(struct davinci_gpio_controller),
+			     nbank * sizeof(struct davinci_gpio_controller),
  			     GFP_KERNEL);
  	if (!chips)
  		return -ENOMEM;
Signature · 2 lines
regards,
-grygorii
#7 lore raw

Re: [PATCH 2/2] gpio: davinci: Fix the number of controllers allocated

Quoted 8 lines · Grygorii Strashko
Quoted 7 lines · Keerthy

From: Lokesh Vutla <[email protected]>

Driver only needs to allocate for [ngpio / 32] controllers, as each controller handles 32 gpios. But the current driver allocates for ngpio of which the extra allocated are unused. Fix it be registering only the required number of controllers.

Quoted 4 lines
Quoted 2 lines

A gentle ping on this patch. Thanks Grygorii for the review.

Quoted 34 lines
Quoted 32 lines
---
  drivers/gpio/gpio-davinci.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpio/gpio-davinci.c +1 -1
index c889f31..cd007a6 100644
@@ -195,7 +195,7 @@ static int davinci_gpio_of_xlate(struct gpio_chip
 *gc,
  static int davinci_gpio_probe(struct platform_device *pdev)
  {
      int i, base;
-    unsigned ngpio;
+    unsigned ngpio, nbank;
      struct davinci_gpio_controller *chips;
      struct davinci_gpio_platform_data *pdata;
      struct davinci_gpio_regs __iomem *regs;
drivers/gpio/gpio-davinci.c +2 -1
@@ -224,8 +224,9 @@ static int davinci_gpio_probe(struct
 platform_device *pdev)
      if (WARN_ON(ARCH_NR_GPIOS < ngpio))
          ngpio = ARCH_NR_GPIOS;
 
+    nbank = DIV_ROUND_UP(ngpio, 32);
      chips = devm_kzalloc(dev,
-                 ngpio * sizeof(struct davinci_gpio_controller),
+                 nbank * sizeof(struct davinci_gpio_controller),
                   GFP_KERNEL);
      if (!chips)
          return -ENOMEM;
#3 lore raw

Re: [PATCH 1/2] gpio: davinci: Add the missing of-node pointer in the irq_domain_add_legacy function call

In reply to Grygorii Strashko
Quoted 9 lines · Grygorii Strashko
Quoted 6 lines · Keerthy

Currently the first parameter of irq_domain_add_legacy is NULL. irq_find_host function returns NULL when we do not populate the of_node and hence irq_of_parse_and_map call fails whenever we want to request a gpio irq. This fixes the request_irq failures for gpio interrupts.

A gentle ping on this patch. Thanks Grygorii for the review.

Quoted 22 lines
Quoted 20 lines
---
  drivers/gpio/gpio-davinci.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-davinci.c +1 -1
index ec58f42..c889f31 100644
@@ -511,7 +511,7 @@ static int davinci_gpio_irq_setup(struct
 platform_device *pdev)
              return irq;
          }
 
-        irq_domain = irq_domain_add_legacy(NULL, ngpio, irq, 0,
+        irq_domain = irq_domain_add_legacy(dev->of_node, ngpio, irq, 0,
                              &davinci_gpio_irq_ops,
                              chips);
          if (!irq_domain) {
#4 lore raw

Re: [PATCH 1/2] gpio: davinci: Add the missing of-node pointer in the irq_domain_add_legacy function call

In reply to Keerthy
Quoted 6 lines · Keerthy

Currently the first parameter of irq_domain_add_legacy is NULL. irq_find_host function returns NULL when we do not populate the of_node and hence irq_of_parse_and_map call fails whenever we want to request a gpio irq. This fixes the request_irq failures for gpio interrupts.

Patch applied for fixes with Grygorii's review tag.

Yours,
Linus Walleij

#8 lore raw

Re: [PATCH 2/2] gpio: davinci: Fix the number of controllers allocated

In reply to Keerthy
Quoted 9 lines · Keerthy

From: Lokesh Vutla <[email protected]>

Driver only needs to allocate for [ngpio / 32] controllers, as each controller handles 32 gpios. But the current driver allocates for ngpio of which the extra allocated are unused. Fix it be registering only the required number of controllers.

Patch applied for fixes with Grygorii's review tag.

Yours,
Linus Walleij