diff mbox series

[1/1] pinctrl: iproc: Set irq handler based on trig type

Message ID 20191212220923.15089-2-hamish.martin@alliedtelesis.co.nz (mailing list archive)
State New, archived
Headers show
Series pinctrl: iproc: Fix level interrupt handling | expand

Commit Message

Hamish Martin Dec. 12, 2019, 10:09 p.m. UTC
Rather than always using handle_simple_irq() as the gpio_irq_chip
handler, set a more appropriate handler based on the IRQ trigger type
requested.
This is important for level triggered interrupts which need to be
masked during handling.

Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
---
 drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Ray Jui Dec. 13, 2019, 12:55 a.m. UTC | #1
On 2019-12-12 2:09 p.m., Hamish Martin wrote:
> Rather than always using handle_simple_irq() as the gpio_irq_chip
> handler, set a more appropriate handler based on the IRQ trigger type
> requested.
> This is important for level triggered interrupts which need to be
> masked during handling.
> 
> Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
> ---
>   drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
> index 831a9318c384..c79e91eb1a47 100644
> --- a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
> +++ b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
> @@ -288,6 +288,11 @@ static int iproc_gpio_irq_set_type(struct irq_data *d, unsigned int type)
>   		       rising_or_high);
>   	raw_spin_unlock_irqrestore(&chip->lock, flags);
>   
> +	if (type & IRQ_TYPE_EDGE_BOTH)
> +		irq_set_handler_locked(d, handle_edge_irq);
> +	else
> +		irq_set_handler_locked(d, handle_level_irq);
> +

I think it would make more sense to put them under the above spinlock 
protection, right?

In addition, with this, can the default assignment in 'iproc_gpio_probe' 
be removed?

girq->handler = handle_simple_irq;

Thanks,

Ray

>   	dev_dbg(chip->dev,
>   		"gpio:%u level_triggered:%d dual_edge:%d rising_or_high:%d\n",
>   		gpio, level_triggered, dual_edge, rising_or_high);
>
diff mbox series

Patch

diff --git a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
index 831a9318c384..c79e91eb1a47 100644
--- a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
+++ b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
@@ -288,6 +288,11 @@  static int iproc_gpio_irq_set_type(struct irq_data *d, unsigned int type)
 		       rising_or_high);
 	raw_spin_unlock_irqrestore(&chip->lock, flags);
 
+	if (type & IRQ_TYPE_EDGE_BOTH)
+		irq_set_handler_locked(d, handle_edge_irq);
+	else
+		irq_set_handler_locked(d, handle_level_irq);
+
 	dev_dbg(chip->dev,
 		"gpio:%u level_triggered:%d dual_edge:%d rising_or_high:%d\n",
 		gpio, level_triggered, dual_edge, rising_or_high);