public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: <Claudiu.Beznea@microchip.com>
To: <broonie@kernel.org>, <Ludovic.Desroches@microchip.com>,
	<linus.walleij@linaro.org>, <Nicolas.Ferre@microchip.com>,
	<alexandre.belloni@bootlin.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] pinctrl: at91: Make the irqchip immutable
Date: Fri, 17 Feb 2023 11:46:15 +0000	[thread overview]
Message-ID: <c5e900c4-92fe-b3cd-e3f6-9bfd18ee2b9e@microchip.com> (raw)
In-Reply-To: <20230216-gpio-at91-immutable-v1-1-44f52f148ab9@kernel.org>

On 16.02.2023 17:43, Mark Brown wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> To help gpiolib not fiddle around with the internals of the irqchip
> flag the chip as immutable, adding the calls into the gpiolib core
> required to do so.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>  drivers/pinctrl/pinctrl-at91.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index 1e1813d7c550..8ecf52ec9b9b 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -1536,6 +1536,20 @@ static void at91_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
>  #define at91_gpio_dbg_show     NULL
>  #endif
> 
> +static int gpio_irq_request_resources(struct irq_data *d)
> +{
> +       struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
> +
> +       return gpiochip_lock_as_irq(&at91_gpio->chip, irqd_to_hwirq(d));
> +}
> +
> +static void gpio_irq_release_resources(struct irq_data *d)
> +{
> +       struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
> +
> +       gpiochip_unlock_as_irq(&at91_gpio->chip, irqd_to_hwirq(d));
> +}
> +
>  /* Several AIC controller irqs are dispatched through this GPIO handler.
>   * To use any AT91_PIN_* as an externally triggered IRQ, first call
>   * at91_set_gpio_input() then maybe enable its glitch filter.
> @@ -1555,6 +1569,9 @@ static void gpio_irq_mask(struct irq_data *d)
>         struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
>         void __iomem    *pio = at91_gpio->regbase;
>         unsigned        mask = 1 << d->hwirq;
> +       unsigned        gpio = irqd_to_hwirq(d);

There are spaces b/w unsigned and gpio. Also, irqd_to_hwirq() returns a
irq_hw_number_t.

> +
> +       gpiochip_disable_irq(&at91_gpio->chip, gpio);
> 
>         if (pio)
>                 writel_relaxed(mask, pio + PIO_IDR);
> @@ -1565,6 +1582,9 @@ static void gpio_irq_unmask(struct irq_data *d)
>         struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
>         void __iomem    *pio = at91_gpio->regbase;
>         unsigned        mask = 1 << d->hwirq;
> +       unsigned        gpio = irqd_to_hwirq(d);

ditto.

> +
> +       gpiochip_enable_irq(&at91_gpio->chip, gpio);
> 
>         if (pio)
>                 writel_relaxed(mask, pio + PIO_IER);
> @@ -1731,12 +1751,15 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
>         at91_gpio->pioc_hwirq = irqd_to_hwirq(d);
> 
>         gpio_irqchip->name = "GPIO";
> +       gpio_irqchip->irq_request_resources = gpio_irq_request_resources;
> +       gpio_irqchip->irq_release_resources = gpio_irq_release_resources;
>         gpio_irqchip->irq_ack = gpio_irq_ack;
>         gpio_irqchip->irq_disable = gpio_irq_mask;
>         gpio_irqchip->irq_mask = gpio_irq_mask;
>         gpio_irqchip->irq_unmask = gpio_irq_unmask;
>         gpio_irqchip->irq_set_wake = pm_ptr(gpio_irq_set_wake);
>         gpio_irqchip->irq_set_type = at91_gpio->ops->irq_type;
> +       gpio_irqchip->flags = IRQCHIP_IMMUTABLE;
> 
>         /* Disable irqs of this PIO controller */
>         writel_relaxed(~0, at91_gpio->regbase + PIO_IDR);
> @@ -1747,7 +1770,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,
>          * interrupt.
>          */
>         girq = &at91_gpio->chip.irq;
> -       girq->chip = gpio_irqchip;
> +       gpio_irq_chip_set_chip(girq, gpio_irqchip);
>         girq->default_type = IRQ_TYPE_NONE;
>         girq->handler = handle_edge_irq;
> 
> 
> --
> 2.34.1
> 


  reply	other threads:[~2023-02-17 11:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16 15:43 [PATCH 0/2] pinctrl: at91: Minor cleanups Mark Brown
2023-02-16 15:43 ` [PATCH 1/2] pinctrl: at91: Make the irqchip immutable Mark Brown
2023-02-17 11:46   ` Claudiu.Beznea [this message]
2023-03-06 13:20   ` Linus Walleij
2023-03-06 13:42     ` Mark Brown
2023-03-07  3:31     ` Nicolas Ferre
2023-02-16 15:43 ` [PATCH 2/2] pinctrl: at91: Remove pioc_index from struct at91_gpio_chip Mark Brown
2023-02-17 11:47   ` Claudiu.Beznea

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c5e900c4-92fe-b3cd-e3f6-9bfd18ee2b9e@microchip.com \
    --to=claudiu.beznea@microchip.com \
    --cc=Ludovic.Desroches@microchip.com \
    --cc=Nicolas.Ferre@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox