From: Thorsten Scherer <thorsten.scherer@eckelmann.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Linus Walleij <linus.walleij@linaro.org>,
<linux-gpio@vger.kernel.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Thierry Reding <treding@nvidia.com>
Subject: Re: [PATCH] gpio: siox: Pass irqchip when adding gpiochip
Date: Wed, 26 Jun 2019 21:36:07 +0200 [thread overview]
Message-ID: <20190626193607.GA9834@NB041> (raw)
In-Reply-To: <20190625193328.sxvhastsatc62msh@pengutronix.de>
Hello,
On Tue, Jun 25, 2019 at 09:33:28PM +0200, Uwe Kleine-König wrote:
> Hello Linus,
>
> On Tue, Jun 25, 2019 at 12:53:46PM +0200, Linus Walleij wrote:
> > We need to convert all old gpio irqchips to pass the irqchip
> > setup along when adding the gpio_chip.
> >
> > For chained irqchips this is a pretty straight-forward
> > conversion.
> >
> > The siox GPIO driver passes a IRQ_TYPE_EDGE_RISING as
> > default IRQ trigger type which seems wrong, as consumers
> > should explicitly set this up, so set IRQ_TYPE_NONE instead.
> >
> > Also gpiochip_remove() was called on the errorpath if
> > gpiochip_add() failed: this is wrong, if the chip failed
> > to add it is not there so it should not be removed.
>
> So we have a bugfix (gpiochip_remove() in error path), a change of
> default behaviour (IRQ_TYPE_EDGE_RISING -> IRQ_TYPE_NONE) and a cleanup
> for an API change (I'm guessing here) in a single patch. :-|
>
> @Thorsten: I'm not entirely sure if there is code relying on the default
> IRQ_TYPE_EDGE_RISING. Do you know off-hand?
Didn't know off the top of my head. So I dug through some application
code. As far as I can tell, nothing relies on edge rising. But I would
not bet on it. And I don't know about code in the other departments.
>
> Best regards
> Uwe
Best regards
Thorsten
>
> > diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
> > index fb4e318ab028..e5c85dc932e8 100644
> > --- a/drivers/gpio/gpio-siox.c
> > +++ b/drivers/gpio/gpio-siox.c
> > @@ -211,6 +211,7 @@ static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
> > static int gpio_siox_probe(struct siox_device *sdevice)
> > {
> > struct gpio_siox_ddata *ddata;
> > + struct gpio_irq_chip *girq;
> > int ret;
> >
> > ddata = devm_kzalloc(&sdevice->dev, sizeof(*ddata), GFP_KERNEL);
> > @@ -239,20 +240,16 @@ static int gpio_siox_probe(struct siox_device *sdevice)
> > ddata->ichip.irq_unmask = gpio_siox_irq_unmask;
> > ddata->ichip.irq_set_type = gpio_siox_irq_set_type;
> >
> > + girq = &ddata->gchip.irq;
> > + girq->chip = &ddata->ichip;
> > + girq->default_type = IRQ_TYPE_NONE;
> > + girq->handler = handle_level_irq;
> > +
> > ret = gpiochip_add(&ddata->gchip);
> > if (ret) {
> > dev_err(&sdevice->dev,
> > "Failed to register gpio chip (%d)\n", ret);
> > - goto err_gpiochip;
> > - }
> > -
> > - ret = gpiochip_irqchip_add(&ddata->gchip, &ddata->ichip,
> > - 0, handle_level_irq, IRQ_TYPE_EDGE_RISING);
> > - if (ret) {
> > - dev_err(&sdevice->dev,
> > - "Failed to register irq chip (%d)\n", ret);
> > -err_gpiochip:
> > - gpiochip_remove(&ddata->gchip);
> > + return ret;
> > }
> >
> > return ret;
>
> --
> Pengutronix e.K. | Uwe Kleine-König |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
--
Thorsten Scherer - Eckelmann AG
https://www.eckelmann.de
prev parent reply other threads:[~2019-06-26 19:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 10:53 [PATCH] gpio: siox: Pass irqchip when adding gpiochip Linus Walleij
2019-06-25 19:33 ` Uwe Kleine-König
2019-06-26 8:05 ` Linus Walleij
2019-06-26 8:10 ` Uwe Kleine-König
2019-06-26 19:36 ` Thorsten Scherer [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=20190626193607.GA9834@NB041 \
--to=thorsten.scherer@eckelmann.de \
--cc=bgolaszewski@baylibre.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=treding@nvidia.com \
--cc=u.kleine-koenig@pengutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).