From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Raul E Rangel <rrangel@chromium.org>
Cc: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org,
jingle.wu@emc.com.tw, rafael@kernel.org,
mario.limonciello@amd.com, hdegoede@redhat.com,
linus.walleij@linaro.org, timvp@google.com,
dmitry.torokhov@gmail.com, Bartosz Golaszewski <brgl@bgdev.pl>,
Len Brown <lenb@kernel.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 05/13] gpiolib: acpi: Add wake_capable variants of acpi_dev_gpio_irq_get
Date: Mon, 19 Sep 2022 12:54:13 +0300 [thread overview]
Message-ID: <Yyg8RU2k6ZCRuqri@smile.fi.intel.com> (raw)
In-Reply-To: <20220914155914.v3.5.I4ff95ba7e884a486d7814ee888bf864be2ebdef4@changeid>
On Wed, Sep 14, 2022 at 05:57:53PM -0600, Raul E Rangel wrote:
> The ACPI spec defines the SharedAndWake and ExclusiveAndWake share type
> keywords. This is an indication that the GPIO IRQ can also be used as a
> wake source. This change exposes the wake_capable bit so drivers can
> correctly enable wake functionality instead of making an assumption.
With two nit-picks below
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Raul E Rangel <rrangel@chromium.org>
> ---
>
> Changes in v3:
> - Kept `acpi_dev_gpio_irq_get_by` unchanged to avoid having to touch
> unrelated drivers.
> - Converted wake_capable parameter to bool.
>
> Changes in v2:
> - Fixed call site in mlxbf_gige_probe
>
> drivers/gpio/gpiolib-acpi.c | 17 ++++++++++++++---
> drivers/gpio/gpiolib-acpi.h | 2 ++
> include/linux/acpi.h | 22 ++++++++++++++++++----
> 3 files changed, 34 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index 9be1376f9a627f..c703f095993a2c 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -741,6 +741,8 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
> lookup->info.pin_config = agpio->pin_config;
> lookup->info.debounce = agpio->debounce_timeout;
> lookup->info.gpioint = gpioint;
> + lookup->info.wake_capable = agpio->wake_capable ==
> + ACPI_WAKE_CAPABLE;
Can be still on one line.
> /*
> * Polarity and triggering are only specified for GpioInt
> @@ -987,10 +989,12 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
> }
>
> /**
> - * acpi_dev_gpio_irq_get_by() - Find GpioInt and translate it to Linux IRQ number
> + * acpi_dev_gpio_irq_wake_get_by() - Find GpioInt and translate it to Linux IRQ
> + * number
> * @adev: pointer to a ACPI device to get IRQ from
> * @name: optional name of GpioInt resource
> * @index: index of GpioInt resource (starting from %0)
> + * @wake_capable: Set to true if the IRQ is wake capable
> *
> * If the device has one or more GpioInt resources, this function can be
> * used to translate from the GPIO offset in the resource to the Linux IRQ
> @@ -1002,9 +1006,13 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
> * The function takes optional @name parameter. If the resource has a property
> * name, then only those will be taken into account.
> *
> + * The GPIO is considered wake capable if the GpioInt resource specifies
> + * SharedAndWake or ExclusiveAndWake.
> + *
> * Return: Linux IRQ number (> %0) on success, negative errno on failure.
> */
> -int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index)
> +int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name,
> + int index, bool *wake_capable)
> {
> int idx, i;
> unsigned int irq_flags;
> @@ -1061,13 +1069,16 @@ int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int ind
> dev_dbg(&adev->dev, "IRQ %d already in use\n", irq);
> }
>
> + if (wake_capable)
> + *wake_capable = info.wake_capable;
> +
> return irq;
> }
>
> }
> return -ENOENT;
> }
> -EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get_by);
> +EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_wake_get_by);
>
> static acpi_status
> acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
> diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h
> index e476558d947136..1ac6816839dbce 100644
> --- a/drivers/gpio/gpiolib-acpi.h
> +++ b/drivers/gpio/gpiolib-acpi.h
> @@ -18,6 +18,7 @@ struct acpi_device;
> * @pin_config: pin bias as provided by ACPI
> * @polarity: interrupt polarity as provided by ACPI
> * @triggering: triggering type as provided by ACPI
> + * @wake_capable: wake capability as provided by ACPI
> * @debounce: debounce timeout as provided by ACPI
> * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
> */
> @@ -28,6 +29,7 @@ struct acpi_gpio_info {
> int pin_config;
> int polarity;
> int triggering;
> + bool wake_capable;
> unsigned int debounce;
> unsigned int quirks;
> };
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 6f64b2f3dc5479..d3121cef6cc3bc 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -1202,7 +1202,8 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
> struct acpi_resource_gpio **agpio);
> bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
> struct acpi_resource_gpio **agpio);
> -int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index);
> +int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name,
> + int index, bool *wake_capable);
> #else
> static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
> struct acpi_resource_gpio **agpio)
> @@ -1214,16 +1215,29 @@ static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
> {
> return false;
> }
> -static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev,
> - const char *name, int index)
> +static inline int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev,
> + const char *name, int index,
> + bool *wake_capable)
> {
> return -ENXIO;
> }
> #endif
>
> +static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev,
> + const char *name, int index)
> +{
> + return acpi_dev_gpio_irq_wake_get_by(adev, name, index, NULL);
> +}
> +
> static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
> {
> - return acpi_dev_gpio_irq_get_by(adev, NULL, index);
> + return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, NULL);
> +}
> +static inline int acpi_dev_gpio_irq_wake_get(struct acpi_device *adev,
> + int index, bool *wake_capable)
> +{
> + return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, wake_capable);
> }
I would put this first in the group of these three helpers, so irq_get_by and
irq_get will be the last (from more parameters to less parameters).
> /* Device properties */
> --
> 2.37.3.968.ga6b4b080e4-goog
>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-09-19 9:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 23:57 [PATCH v3 00/13] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq Raul E Rangel
2022-09-14 23:57 ` [PATCH v3 01/13] HID: i2c-hid: Use PM subsystem to manage " Raul E Rangel
2022-09-14 23:57 ` [PATCH v3 02/13] Input: elan_i2c - " Raul E Rangel
2022-09-14 23:57 ` [PATCH v3 03/13] Input: elants_i2c " Raul E Rangel
2022-09-14 23:57 ` [PATCH v3 04/13] Input: raydium_ts_i2c " Raul E Rangel
2022-09-14 23:57 ` [PATCH v3 05/13] gpiolib: acpi: Add wake_capable variants of acpi_dev_gpio_irq_get Raul E Rangel
2022-09-15 10:43 ` Mika Westerberg
2022-09-19 9:54 ` Andy Shevchenko [this message]
2022-09-19 15:20 ` Raul Rangel
2022-09-14 23:57 ` [PATCH v3 06/13] ACPI: resources: Add wake_capable parameter to acpi_dev_irq_flags Raul E Rangel
2022-09-19 9:54 ` Andy Shevchenko
2022-09-19 15:30 ` Raul Rangel
2022-09-14 23:57 ` [PATCH v3 07/13] i2c: acpi: Use ACPI wake capability bit to set wake_irq Raul E Rangel
2022-09-15 10:46 ` Mika Westerberg
2022-09-15 15:48 ` Raul Rangel
2022-09-19 9:54 ` Andy Shevchenko
2022-09-19 15:38 ` Raul Rangel
2022-09-14 23:57 ` [PATCH v3 08/13] ACPI: PM: Take wake IRQ into consideration when entering suspend-to-idle Raul E Rangel
2022-09-14 23:57 ` [PATCH v3 09/13] HID: i2c-hid: acpi: Stop setting wakeup_capable Raul E Rangel
2022-09-14 23:57 ` [PATCH v3 10/13] HID: i2c-hid: Don't set wake_capable and wake_irq Raul E Rangel
2022-09-14 23:57 ` [PATCH v3 11/13] Input: elan_i2c - " Raul E Rangel
2022-09-14 23:58 ` [PATCH v3 12/13] Input: elants_i2c " Raul E Rangel
2022-09-14 23:58 ` [PATCH v3 13/13] Input: raydium_ts_i2c " Raul E Rangel
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=Yyg8RU2k6ZCRuqri@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=dmitry.torokhov@gmail.com \
--cc=hdegoede@redhat.com \
--cc=jingle.wu@emc.com.tw \
--cc=lenb@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mika.westerberg@linux.intel.com \
--cc=rafael@kernel.org \
--cc=rrangel@chromium.org \
--cc=timvp@google.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
all inboxes | Powered by JetHome®