From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Christophe Ricard <christophe.ricard@gmail.com>
Cc: rjw@rjwysocki.net, lenb@kernel.org, linus.walleij@linaro.org,
gnurou@gmail.com, andriy.shevchenko@linux.intel.com,
broonie@kernel.org, linux-spi@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org,
Christophe Ricard <christophe-h.ricard@st.com>
Subject: Re: [PATCH v4 2/3] ACPI / gpio: Add irq_type when a gpio is used as an interrupt
Date: Tue, 8 Dec 2015 13:33:11 +0200 [thread overview]
Message-ID: <20151208113311.GJ1766@lahna.fi.intel.com> (raw)
In-Reply-To: <1449527952-8399-3-git-send-email-christophe-h.ricard@st.com>
On Mon, Dec 07, 2015 at 11:39:11PM +0100, Christophe Ricard wrote:
> When a gpio is used as an interrupt in acpi, the irq_type was not
> available for device driver.
>
> Make it available in acpi_find_gpio with a new acpi_gpio_info field
> (irq_type) and setthe irq_type if necessary in acpi_dev_gpio_irq_get.
>
> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
> ---
> drivers/gpio/gpiolib-acpi.c | 22 ++++++++++++++++++----
> drivers/gpio/gpiolib.h | 1 +
> 2 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index bbcac3a..4b893c8 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -416,9 +416,12 @@ static int acpi_find_gpio(struct acpi_resource *ares, void *data)
> * GpioIo is used then the only way to set the flag is
> * to use _DSD "gpios" property.
> */
> - if (lookup->info.gpioint)
> + if (lookup->info.gpioint) {
> lookup->info.active_low =
> agpio->polarity == ACPI_ACTIVE_LOW;
Since we have irq_type (I prefer irq_flags) we can get rid of active_low
above. That information is already in the irq_type field.
> + lookup->info.irq_type = acpi_get_irq_type(agpio->triggering,
> + agpio->polarity);
> + }
> }
>
> return 1;
> @@ -529,7 +532,7 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
> */
> int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
> {
> - int idx, i;
> + int idx, i, irq;
>
> for (i = 0, idx = 0; idx <= index; i++) {
> struct acpi_gpio_info info;
> @@ -538,8 +541,19 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
> desc = acpi_get_gpiod_by_index(adev, NULL, i, &info);
> if (IS_ERR(desc))
> break;
> - if (info.gpioint && idx++ == index)
> - return gpiod_to_irq(desc);
> + if (info.gpioint && idx++ == index) {
Why not declare irq here?
int irq = gpiod_to_irq(desc);
> + irq = gpiod_to_irq(desc);
> + if (irq < 0) {
> + dev_err(&adev->dev,
> + "Failed to translate GPIO to IRQ\n");
Is it really necessary to print this error?
> + return irq;
> + }
> + /* Set type if specified and different than the current one */
> + if (info.irq_type != IRQ_TYPE_NONE &&
> + info.irq_type != irq_get_trigger_type(irq))
> + irq_set_irq_type(irq, info.irq_type);
> + return irq;
> + }
> }
> return -ENOENT;
> }
> diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
> index 78e634d..624fbc4 100644
> --- a/drivers/gpio/gpiolib.h
> +++ b/drivers/gpio/gpiolib.h
> @@ -27,6 +27,7 @@ struct acpi_device;
> struct acpi_gpio_info {
> bool gpioint;
> bool active_low;
> + int irq_type;
Use unsigned long here.
> };
>
> /* gpio suffixes used for ACPI and device tree lookup */
> --
> 2.1.4
next prev parent reply other threads:[~2015-12-08 11:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-07 22:39 [PATCH v4 0/3] ACPI: Add irq_type to gpio interrupt Christophe Ricard
2015-12-07 22:39 ` [PATCH v4 1/3] acpi: Rename acpi_gsi_get_irq_type to acpi_get_irq_type and export symbol Christophe Ricard
2015-12-08 11:28 ` Mika Westerberg
[not found] ` <20151208112855.GI1766-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2015-12-08 21:57 ` Christophe Ricard
2015-12-09 13:36 ` Mika Westerberg
2015-12-09 14:19 ` Andy Shevchenko
[not found] ` <1449527952-8399-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2015-12-07 22:39 ` [PATCH v4 2/3] ACPI / gpio: Add irq_type when a gpio is used as an interrupt Christophe Ricard
2015-12-08 11:33 ` Mika Westerberg [this message]
2015-12-07 22:39 ` [PATCH v4 3/3] ACPI / spi: attach gpio irq from acpi description to spi device Christophe Ricard
2015-12-08 11:35 ` Mika Westerberg
2015-12-08 11:59 ` Mika Westerberg
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=20151208113311.GJ1766@lahna.fi.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=broonie@kernel.org \
--cc=christophe-h.ricard@st.com \
--cc=christophe.ricard@gmail.com \
--cc=gnurou@gmail.com \
--cc=lenb@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/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