Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@xilinx.com>
To: Linus Walleij <linus.walleij@linaro.org>, linux-gpio@vger.kernel.org
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Michal Simek <michal.simek@xilinx.com>,
	Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>,
	Thierry Reding <treding@nvidia.com>
Subject: Re: [PATCH] gpio: zynq: Pass irqchip when adding gpiochip
Date: Wed, 14 Aug 2019 10:04:01 +0200	[thread overview]
Message-ID: <21218433-03c7-e525-e6b3-0dedfa9982b5@xilinx.com> (raw)
In-Reply-To: <20190809132649.25176-1-linus.walleij@linaro.org>

On 09. 08. 19 15:26, Linus Walleij wrote:
> We need to convert all old gpio irqchips to pass the irqchip
> setup along when adding the gpio_chip. For more info see
> drivers/gpio/TODO.
> 
> For chained irqchips this is a pretty straight-forward
> conversion.
> 
> Cc: Michal Simek <michal.simek@xilinx.com>
> Cc: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> Cc: Thierry Reding <treding@nvidia.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpio/gpio-zynq.c | 37 +++++++++++++++++++++----------------
>  1 file changed, 21 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index 86b0bd256c13..cd475ff4bcad 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -830,6 +830,7 @@ static int zynq_gpio_probe(struct platform_device *pdev)
>  	int ret, bank_num;
>  	struct zynq_gpio *gpio;
>  	struct gpio_chip *chip;
> +	struct gpio_irq_chip *girq;
>  	const struct of_device_id *match;
>  
>  	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
> @@ -885,34 +886,38 @@ static int zynq_gpio_probe(struct platform_device *pdev)
>  	if (ret < 0)
>  		goto err_pm_dis;
>  
> -	/* report a bug if gpio chip registration fails */
> -	ret = gpiochip_add_data(chip, gpio);
> -	if (ret) {
> -		dev_err(&pdev->dev, "Failed to add gpio chip\n");
> -		goto err_pm_put;
> -	}
> -
>  	/* disable interrupts for all banks */
>  	for (bank_num = 0; bank_num < gpio->p_data->max_bank; bank_num++)
>  		writel_relaxed(ZYNQ_GPIO_IXR_DISABLE_ALL, gpio->base_addr +
>  			       ZYNQ_GPIO_INTDIS_OFFSET(bank_num));
>  
> -	ret = gpiochip_irqchip_add(chip, &zynq_gpio_edge_irqchip, 0,
> -				   handle_level_irq, IRQ_TYPE_NONE);
> -	if (ret) {
> -		dev_err(&pdev->dev, "Failed to add irq chip\n");
> -		goto err_rm_gpiochip;
> +	/* Set up the GPIO irqchip */
> +	girq = &chip->irq;
> +	girq->chip = &zynq_gpio_edge_irqchip;
> +	girq->parent_handler = zynq_gpio_irqhandler;
> +	girq->num_parents = 1;
> +	girq->parents = devm_kcalloc(&pdev->dev, 1,
> +				     sizeof(*girq->parents),
> +				     GFP_KERNEL);
> +	if (!girq->parents) {
> +		ret = -ENOMEM;
> +		goto err_pm_put;
>  	}
> +	girq->parents[0] = gpio->irq;
> +	girq->default_type = IRQ_TYPE_NONE;
> +	girq->handler = handle_level_irq;
>  
> -	gpiochip_set_chained_irqchip(chip, &zynq_gpio_edge_irqchip, gpio->irq,
> -				     zynq_gpio_irqhandler);
> +	/* report a bug if gpio chip registration fails */
> +	ret = gpiochip_add_data(chip, gpio);
> +	if (ret) {
> +		dev_err(&pdev->dev, "Failed to add gpio chip\n");
> +		goto err_pm_put;
> +	}
>  
>  	pm_runtime_put(&pdev->dev);
>  
>  	return 0;
>  
> -err_rm_gpiochip:
> -	gpiochip_remove(chip);
>  err_pm_put:
>  	pm_runtime_put(&pdev->dev);
>  err_pm_dis:
> 

Shubhrajyoti: Please retest it.

Thanks,
Michal

      reply	other threads:[~2019-08-14  8:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 13:26 [PATCH] gpio: zynq: Pass irqchip when adding gpiochip Linus Walleij
2019-08-14  8:04 ` Michal Simek [this message]

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=21218433-03c7-e525-e6b3-0dedfa9982b5@xilinx.com \
    --to=michal.simek@xilinx.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=shubhrajyoti.datta@xilinx.com \
    --cc=treding@nvidia.com \
    /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