linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: pca953x: Read irq trigger type from DT
@ 2019-12-05 14:45 Vignesh Raghavendra
  2019-12-05 15:01 ` Grygorii Strashko
  0 siblings, 1 reply; 3+ messages in thread
From: Vignesh Raghavendra @ 2019-12-05 14:45 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-omap, linux-kernel, 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.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
 drivers/gpio/gpio-pca953x.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 6652bee01966..e0e2a77ef6ad 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -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",
-- 
2.24.0


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

* Re: [PATCH] gpio: pca953x: Read irq trigger type from DT
  2019-12-05 14:45 [PATCH] gpio: pca953x: Read irq trigger type from DT Vignesh Raghavendra
@ 2019-12-05 15:01 ` Grygorii Strashko
  2019-12-09  5:15   ` Vignesh Raghavendra
  0 siblings, 1 reply; 3+ messages in thread
From: Grygorii Strashko @ 2019-12-05 15:01 UTC (permalink / raw)
  To: Vignesh Raghavendra, Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-omap, linux-kernel



On 05/12/2019 16:45, Vignesh Raghavendra wrote:
> 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.
> 
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> ---
>   drivers/gpio/gpio-pca953x.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 6652bee01966..e0e2a77ef6ad 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -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;

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()

> +	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",
> 

-- 
Best regards,
grygorii

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

* Re: [PATCH] gpio: pca953x: Read irq trigger type from DT
  2019-12-05 15:01 ` Grygorii Strashko
@ 2019-12-09  5:15   ` Vignesh Raghavendra
  0 siblings, 0 replies; 3+ messages in thread
From: Vignesh Raghavendra @ 2019-12-09  5:15 UTC (permalink / raw)
  To: Grygorii Strashko, Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-omap, linux-kernel

Hi Grygorii,

On 05/12/19 8:31 pm, Grygorii Strashko wrote:
> 
> 
> On 05/12/2019 16:45, Vignesh Raghavendra wrote:
[...]

>> @@ -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()
> 

Ok, will drop setting IRQF_TRIGGER_LOW in v2.

Thanks for the review!

>> +    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",
>>
> 

-- 
Regards
Vignesh

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

end of thread, other threads:[~2019-12-09  5:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-05 14:45 [PATCH] gpio: pca953x: Read irq trigger type from DT Vignesh Raghavendra
2019-12-05 15:01 ` Grygorii Strashko
2019-12-09  5:15   ` Vignesh Raghavendra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).