Skip to contentSkip to conversation

gpio: pca953x: Read irq trigger type from DT

PATCH In review Vignesh Raghavendra 2 participants 3 messages Dec 5, 2019 – Dec 9, 2019 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: pca953x: Read irq trigger type from DT

Instead of hardcoding irq trigger type to IRQF_TRIGGER_LOW, let's respect settings specified in DT. Default to IRQF_TRIGGER_LOW, if DT does not provide a flag.

---
 drivers/gpio/gpio-pca953x.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpio/gpio-pca953x.c +7 -2
index 6652bee01966..e0e2a77ef6ad 100644
@@ -744,6 +744,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base)
 	struct irq_chip *irq_chip = &chip->irq_chip;
 	DECLARE_BITMAP(reg_direction, MAX_LINE);
 	DECLARE_BITMAP(irq_stat, MAX_LINE);
+	unsigned long irqflags;
 	int ret;
 
 	if (!client->irq)
@@ -768,10 +769,14 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base)
 	bitmap_and(chip->irq_stat, irq_stat, reg_direction, chip->gpio_chip.ngpio);
 	mutex_init(&chip->irq_lock);
 
+	irqflags = irq_get_trigger_type(client->irq);
+	if (irqflags == IRQF_TRIGGER_NONE)
+		irqflags = IRQF_TRIGGER_LOW;
+	irqflags |= IRQF_ONESHOT | IRQF_SHARED;
+
 	ret = devm_request_threaded_irq(&client->dev, client->irq,
 					NULL, pca953x_irq_handler,
-					IRQF_TRIGGER_LOW | IRQF_ONESHOT |
-					IRQF_SHARED,
+					irqflags,
 					dev_name(&client->dev), chip);
 	if (ret) {
 		dev_err(&client->dev, "failed to request irq %d\n",
Signature · 1 line
2.24.0
#1 lore raw
Quoted 22 lines · Vignesh Raghavendra

Instead of hardcoding irq trigger type to IRQF_TRIGGER_LOW, let's respect settings specified in DT. Default to IRQF_TRIGGER_LOW, if DT does not provide a flag.

---
  drivers/gpio/gpio-pca953x.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpio/gpio-pca953x.c +1 -0
index 6652bee01966..e0e2a77ef6ad 100644
@@ -744,6 +744,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base)
  	struct irq_chip *irq_chip = &chip->irq_chip;
  	DECLARE_BITMAP(reg_direction, MAX_LINE);
  	DECLARE_BITMAP(irq_stat, MAX_LINE);
+	unsigned long irqflags;
  	int ret;
 
  	if (!client->irq)

drivers/gpio/gpio-pca953x.c static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base) · line 774

Quoted 6 lines
drivers/gpio/gpio-pca953x.c +3 -0
@@ -768,10 +769,14 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base)
  	bitmap_and(chip->irq_stat, irq_stat, reg_direction, chip->gpio_chip.ngpio);
  	mutex_init(&chip->irq_lock);
 
+	irqflags = irq_get_trigger_type(client->irq);
+	if (irqflags == IRQF_TRIGGER_NONE)
+		irqflags = IRQF_TRIGGER_LOW;

I think you can just drop IRQF_TRIGGER_LOW:
- for paltform code it will be set from resources in platform_get_irq_optional()
- for DT code it will be set in __setup_irq()

Quoted 11 lines
drivers/gpio/gpio-pca953x.c +3 -2
+	irqflags |= IRQF_ONESHOT | IRQF_SHARED;
+
  	ret = devm_request_threaded_irq(&client->dev, client->irq,
  					NULL, pca953x_irq_handler,
-					IRQF_TRIGGER_LOW | IRQF_ONESHOT |
-					IRQF_SHARED,
+					irqflags,
  					dev_name(&client->dev), chip);
  	if (ret) {
  		dev_err(&client->dev, "failed to request irq %d\n",
Signature · 2 lines
Best regards,
grygorii
#2 lore raw

Hi Grygorii,

Quoted 3 lines · Grygorii Strashko

On 05/12/2019 16:45, Vignesh Raghavendra wrote:

[...]

Quoted 5 lines
Quoted 5 lines
(quoted diff) +0 -0
@@ -768,10 +769,14 @@ static int pca953x_irq_setup(struct pca953x_chip
 *chip, int irq_base)
       bitmap_and(chip->irq_stat, irq_stat, reg_direction,
 chip->gpio_chip.ngpio);
       mutex_init(&chip->irq_lock);
Quoted 9 lines

drivers/gpio/gpio-pca953x.c static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base) · line 774

Quoted 3 lines
drivers/gpio/gpio-pca953x.c +2 -0
   +    irqflags = irq_get_trigger_type(client->irq);
+    if (irqflags == IRQF_TRIGGER_NONE)
+        irqflags = IRQF_TRIGGER_LOW;

I think you can just drop IRQF_TRIGGER_LOW:
- for paltform code it will be set from resources in platform_get_irq_optional()
- for DT code it will be set in __setup_irq()

Ok, will drop setting IRQF_TRIGGER_LOW in v2.

Thanks for the review!

Quoted 12 lines
Quoted 11 lines
drivers/gpio/gpio-pca953x.c +3 -2
+    irqflags |= IRQF_ONESHOT | IRQF_SHARED;
+
       ret = devm_request_threaded_irq(&client->dev, client->irq,
                       NULL, pca953x_irq_handler,
-                    IRQF_TRIGGER_LOW | IRQF_ONESHOT |
-                    IRQF_SHARED,
+                    irqflags,
                       dev_name(&client->dev), chip);

      if (ret) {
          dev_err(&client->dev, "failed to request irq %d\n",

Signature · 2 lines
Regards
Vignesh