LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Phil Edworthy <phil.edworthy@renesas.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Hoan Tran <hotran@apm.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Lee Jones <lee.jones@linaro.org>,
	Michel Pollet <michel.pollet@bp.renesas.com>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v5] gpio: dwapb: Add support for 1 interrupt per port A GPIO
Date: Wed, 9 May 2018 12:11:27 +0000	[thread overview]
Message-ID: <TY1PR01MB1769D461E888BA9F9537678EF5990@TY1PR01MB1769.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CAHp75Vc3qBOYjUAgxZCkpXAdg=ueM2KApPynPdpkEmOoMR7sQQ@mail.gmail.com>

Hi Andy,

On 05 May 2018 11:49 Andy Shevchenko wrote:
> On Thu, Apr 26, 2018 at 7:19 PM, Phil Edworthy wrote:
> 
> Sotty fo a late response. Consider follow up fixes for below.
> 
> >         if (!pp->irq_shared) {
> > +               int i;
> > +
> > +               for (i = 0; i < pp->ngpio; i++) {
> > +                       if (pp->irq[i])
> > +                               irq_set_chained_handler_and_data(pp->irq[i],
> > +                                               dwapb_irq_handler, gpio);
> > +               }
> >         } else {
> >                 /*
> >                  * Request a shared IRQ since where MFD would have devices
> >                  * using the same irq pin
> >                  */
> > +               err = devm_request_irq(gpio->dev, pp->irq[0],
> >                                        dwapb_irq_handler_mfd,
> >                                        IRQF_SHARED, "gpio-dwapb-mfd",
> > gpio);
> 
> > +       if (pp->has_irq)
> >                 dwapb_configure_irqs(gpio, port, pp);
> 
> I would rather make irq array a type of signed int and move conditional into
> the function to test per IRQ based.
Ok, though since the driver can be used without interrupts, it has to check
if any are used before the driver does all the other interrupt related things.
 
> >         /* Add GPIO-signaled ACPI event support */
> > +       if (pp->has_irq)
> >                 acpi_gpiochip_request_interrupts(&port->gc);
> 
> Perhaps something similar.
> 
> >                 if (dev->of_node && pp->idx == 0 &&
> >                         fwnode_property_read_bool(fwnode,
> >
> > "interrupt-controller")) {
> 
> > +                       struct device_node *np = to_of_node(fwnode);
> > +                       unsigned int j;
> > +
> > +                       /*
> > +                        * The IP has configuration options to allow a single
> > +                        * combined interrupt or one per gpio. If one per gpio,
> > +                        * some might not be used.
> > +                        */
> > +                       for (j = 0; j < pp->ngpio; j++) {
> > +                               int irq = of_irq_get(np, j);
> > +                               if (irq < 0)
> > +                                       continue;
> > +
> > +                               pp->irq[j] = irq;
> > +                               pp->has_irq = true;
> > +                       }
> 
> for (...)
>  pp->irq = of_irq_get();
> 
> >                 }
> 
> > +               if (has_acpi_companion(dev) && pp->idx == 0) {
> > +                       unsigned int j;
> > +
> > +                       for (j = 0; j < pp->ngpio; j++) {
> > +                               pp->irq[j] = platform_get_irq(to_platform_device(dev), j);
> > +                               if (pp->irq[j])
> > +                                       pp->has_irq = true;
> > +                       }
> 
> Ditto.
> Moreover you have a bug here. See my proposal at the top of this message.
I guess you mean that it doesn’t check for errors returned?

> And now even better to ask, why platform_get_irq() wouldn't work for DT
> case?
The problem is that the interrupts are defined in the port sub-node in DT,
not in the gpio controller node, causing platform_get_irq() to fail. The
port sub-node doesn’t have an associated platform device. I don’t think
there is a way around this...

> > +
> > +                       if (!pp->has_irq)
> >                                 dev_warn(dev, "no irq for port%d\n",
> > pp->idx);
> 
> This could be issued in the actual function which will try to allocate IRQs
> (perhaps on debug level)
> 
> 
> P.S. Just think about it, perhaps you find even better solutions.
There's certainly some duplication between DT and ACPI that can be removed.

Thanks
Phil

      reply	other threads:[~2018-05-09 12:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-26 16:19 Phil Edworthy
2018-04-26 16:33 ` Hoan Tran
2018-05-02 10:12 ` Linus Walleij
2018-05-05 10:48 ` Andy Shevchenko
2018-05-09 12:11   ` Phil Edworthy [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=TY1PR01MB1769D461E888BA9F9537678EF5990@TY1PR01MB1769.jpnprd01.prod.outlook.com \
    --to=phil.edworthy@renesas.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hotran@apm.com \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=michel.pollet@bp.renesas.com \
    --cc=robh+dt@kernel.org \
    --subject='RE: [PATCH v5] gpio: dwapb: Add support for 1 interrupt per port A GPIO' \
    /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

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).