mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] Improvement for pca953x drivers
@ 2013-01-25 16:59 Gregory CLEMENT
  2013-01-25 16:59 ` [PATCH 1/2] gpio: pca953x: use simple irqdomain Gregory CLEMENT
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Gregory CLEMENT @ 2013-01-25 16:59 UTC (permalink / raw)
  To: Linus Walleij, Grant Likely
  Cc: Maxime Ripard, Andreas Schallenberg, Roland Stigge, Jason Cooper,
	Andrew Lunn, Thomas Petazzoni, Sebastian Hesselbarth,
	linux-arm-kernel, linux-kernel, Gregory CLEMENT

Hi Linus,

those two patches are the begining of the improvement work we have
spoken about earlier. I started with the two patches you sent.

I've just made a small fix to make it build on the 2nd patch so I keep
your autorship and signed-off.

For the second one, it didn't build too, but I made a more substantial
change on it by moving the setting of the irq to the map function. So
for this one, I took the authorship and remove your signed-off to not
make you responsible of my possible bug! :)

I've compiled and run it, but as I don't have support for the pca905
interrupt on my board, I can't say it didn't break anything. Maybe
this time again Maxime will be willing to test it.

For the remaining improvement related to the PWA and MMP #ifdef, I
hope to be able to work on it this week-end.

Regards

Gregory CLEMENT (1):
  gpio: pca953x: use simple irqdomain

Linus Walleij (1):
  gpio: pca953x: use managed resources

 drivers/gpio/gpio-pca953x.c |   97 ++++++++++++++++---------------------------
 1 file changed, 36 insertions(+), 61 deletions(-)

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH 1/2] gpio: pca953x: use simple irqdomain
@ 2013-01-25  8:46 Linus Walleij
  0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2013-01-25  8:46 UTC (permalink / raw)
  To: Gregory CLEMENT, Maxime Ripard
  Cc: linux-kernel, linux-arm-kernel, Andreas Schallenberg,
	Thomas Petazzoni, Linus Walleij

This switches the legacy irqdomain to the simple one, which will
auto-allocate descriptors, and also make sure that we use
irq_create_mapping() in the to_irq function.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-pca953x.c | 35 ++++++++++-------------------------
 1 file changed, 10 insertions(+), 25 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 3a68aed..51e7f15 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -89,7 +89,6 @@ struct pca953x_chip {
 	u8 irq_stat[MAX_BANK];
 	u8 irq_trig_raise[MAX_BANK];
 	u8 irq_trig_fall[MAX_BANK];
-	int	 irq_base;
 	struct irq_domain *domain;
 #endif
 
@@ -372,7 +371,7 @@ static int pca953x_gpio_to_irq(struct gpio_chip *gc, unsigned off)
 	struct pca953x_chip *chip;
 
 	chip = container_of(gc, struct pca953x_chip, gpio_chip);
-	return chip->irq_base + off;
+	return irq_create_mapping(chip->domain, off);
 }
 
 static void pca953x_irq_mask(struct irq_data *d)
@@ -552,20 +551,13 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 			chip->irq_stat[i] &= chip->reg_direction[i];
 		mutex_init(&chip->irq_lock);
 
-		chip->irq_base = irq_alloc_descs(-1, irq_base, chip->gpio_chip.ngpio, -1);
-		if (chip->irq_base < 0)
-			goto out_failed;
-
-		chip->domain = irq_domain_add_legacy(client->dev.of_node,
+		chip->domain = irq_domain_add_simple(client->dev.of_node,
 						chip->gpio_chip.ngpio,
-						chip->irq_base,
-						0,
+						irq_base,
 						&irq_domain_simple_ops,
 						NULL);
-		if (!chip->domain) {
-			ret = -ENODEV;
-			goto out_irqdesc_free;
-		}
+		if (!chip->domain)
+			return -ENODEV;
 
 		for (lvl = 0; lvl < chip->gpio_chip.ngpio; lvl++) {
 			int irq = lvl + chip->irq_base;
@@ -582,32 +574,25 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 		}
 
 		ret = request_threaded_irq(client->irq,
-					   NULL,
-					   pca953x_irq_handler,
-					   IRQF_TRIGGER_LOW | IRQF_ONESHOT,
-					   dev_name(&client->dev), chip);
+					NULL,
+					pca953x_irq_handler,
+					IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+					dev_name(&client->dev), chip);
 		if (ret) {
 			dev_err(&client->dev, "failed to request irq %d\n",
 				client->irq);
-			goto out_irqdesc_free;
+			return ret;
 		}
 
 		chip->gpio_chip.to_irq = pca953x_gpio_to_irq;
 	}
 
 	return 0;
-
-out_irqdesc_free:
-	irq_free_descs(chip->irq_base, chip->gpio_chip.ngpio);
-out_failed:
-	chip->irq_base = -1;
-	return ret;
 }
 
 static void pca953x_irq_teardown(struct pca953x_chip *chip)
 {
 	if (chip->irq_base != -1) {
-		irq_free_descs(chip->irq_base, chip->gpio_chip.ngpio);
 		free_irq(chip->client->irq, chip);
 	}
 }
-- 
1.8.1


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

end of thread, other threads:[~2013-01-28 15:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-25 16:59 [PATCH 0/2] Improvement for pca953x drivers Gregory CLEMENT
2013-01-25 16:59 ` [PATCH 1/2] gpio: pca953x: use simple irqdomain Gregory CLEMENT
2013-01-28 10:16   ` Linus Walleij
2013-01-25 16:59 ` [PATCH 2/2] gpio: pca953x: use managed resources Gregory CLEMENT
2013-01-28 10:17   ` Linus Walleij
2013-01-28 15:04     ` Russell King - ARM Linux
2013-01-28 10:14 ` [PATCH 0/2] Improvement for pca953x drivers Linus Walleij
  -- strict thread matches above, loose matches on Subject: below --
2013-01-25  8:46 [PATCH 1/2] gpio: pca953x: use simple irqdomain Linus Walleij

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

all inboxes | Powered by JetHome®