Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: William Breathitt Gray <vilhelm.gray@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [PATCH] gpio: 104-dio-48e: Use irqchip template
Date: Wed, 22 Jul 2020 13:22:36 -0400	[thread overview]
Message-ID: <20200722172236.GB93793@shinobu> (raw)
In-Reply-To: <20200722103915.162156-1-linus.walleij@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 3014 bytes --]

On Wed, Jul 22, 2020 at 12:39:15PM +0200, Linus Walleij wrote:
> This makes the driver use the irqchip template to assign
> properties to the gpio_irq_chip instead of using the
> explicit call to gpiochip_irqchip_add().
> 
> The irqchip is instead added while adding the gpiochip.
> Also move the IRQ initialization to the special .init_hw()
> callback.
> 
> Cc: William Breathitt Gray <vilhelm.gray@gmail.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>

> ---
>  drivers/gpio/gpio-104-dio-48e.c | 35 ++++++++++++++++++++++-----------
>  1 file changed, 23 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
> index 1f7d9bbec0fc..7a9021c4fa48 100644
> --- a/drivers/gpio/gpio-104-dio-48e.c
> +++ b/drivers/gpio/gpio-104-dio-48e.c
> @@ -368,10 +368,21 @@ static const char *dio48e_names[DIO48E_NGPIO] = {
>  	"PPI Group 1 Port C 5", "PPI Group 1 Port C 6", "PPI Group 1 Port C 7"
>  };
>  
> +static int dio48e_irq_init_hw(struct gpio_chip *gc)
> +{
> +	struct dio48e_gpio *const dio48egpio = gpiochip_get_data(gc);
> +
> +	/* Disable IRQ by default */
> +	inb(dio48egpio->base + 0xB);
> +
> +	return 0;
> +}
> +
>  static int dio48e_probe(struct device *dev, unsigned int id)
>  {
>  	struct dio48e_gpio *dio48egpio;
>  	const char *const name = dev_name(dev);
> +	struct gpio_irq_chip *girq;
>  	int err;
>  
>  	dio48egpio = devm_kzalloc(dev, sizeof(*dio48egpio), GFP_KERNEL);
> @@ -399,13 +410,17 @@ static int dio48e_probe(struct device *dev, unsigned int id)
>  	dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple;
>  	dio48egpio->base = base[id];
>  
> -	raw_spin_lock_init(&dio48egpio->lock);
> +	girq = &dio48egpio->chip.irq;
> +	girq->chip = &dio48e_irqchip;
> +	/* This will let us handle the parent IRQ in the driver */
> +	girq->parent_handler = NULL;
> +	girq->num_parents = 0;
> +	girq->parents = NULL;
> +	girq->default_type = IRQ_TYPE_NONE;
> +	girq->handler = handle_edge_irq;
> +	girq->init_hw = dio48e_irq_init_hw;
>  
> -	err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio);
> -	if (err) {
> -		dev_err(dev, "GPIO registering failed (%d)\n", err);
> -		return err;
> -	}
> +	raw_spin_lock_init(&dio48egpio->lock);
>  
>  	/* initialize all GPIO as output */
>  	outb(0x80, base[id] + 3);
> @@ -419,13 +434,9 @@ static int dio48e_probe(struct device *dev, unsigned int id)
>  	outb(0x00, base[id] + 6);
>  	outb(0x00, base[id] + 7);
>  
> -	/* disable IRQ by default */
> -	inb(base[id] + 0xB);
> -
> -	err = gpiochip_irqchip_add(&dio48egpio->chip, &dio48e_irqchip, 0,
> -		handle_edge_irq, IRQ_TYPE_NONE);
> +	err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio);
>  	if (err) {
> -		dev_err(dev, "Could not add irqchip (%d)\n", err);
> +		dev_err(dev, "GPIO registering failed (%d)\n", err);
>  		return err;
>  	}
>  
> -- 
> 2.26.2
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2020-07-22 17:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 10:39 [PATCH] gpio: 104-dio-48e: Use irqchip template Linus Walleij
2020-07-22 17:22 ` William Breathitt Gray [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=20200722172236.GB93793@shinobu \
    --to=vilhelm.gray@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@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