2024-04-11 18:17:57

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 0/4] gpiolib: acpi: Use con_id in acpi_dev_gpio_irq_get_by()

Use con_id instead of property in the acpi_dev_gpio_irq_get_by().
It will be aligned with other GPIO library functions.

Assumed to go via my GPIO ACPI library tree follwoed by GPIO subsystem.

Andy Shevchenko (4):
gpiolib: acpi: Extract __acpi_find_gpio() helper
gpiolib: acpi: Simplify error handling in __acpi_find_gpio()
gpiolib: acpi: Move acpi_can_fallback_to_crs() out of
__acpi_find_gpio()
gpiolib: acpi: Pass con_id instead of property into
acpi_dev_gpio_irq_get_by()

drivers/gpio/gpio-pca953x.c | 2 +-
drivers/gpio/gpiolib-acpi.c | 52 +++++++++++--------
.../mellanox/mlxbf_gige/mlxbf_gige_main.c | 2 +-
drivers/pinctrl/pinctrl-cy8c95x0.c | 2 +-
include/linux/acpi.h | 8 +--
5 files changed, 37 insertions(+), 29 deletions(-)

--
2.43.0.rc1.1336.g36b5255a03ac



2024-04-11 20:36:55

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 3/4] gpiolib: acpi: Move acpi_can_fallback_to_crs() out of __acpi_find_gpio()

New coming user may need to check for _CRS fallback slightly differently.
Move the current check out of the helper function to allow that user to
use it.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/gpio/gpiolib-acpi.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index fb2e14670b7a..2b3fd43b13fc 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -947,7 +947,7 @@ static bool acpi_can_fallback_to_crs(struct acpi_device *adev,

static struct gpio_desc *
__acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int idx,
- struct acpi_gpio_info *info)
+ bool can_fallback, struct acpi_gpio_info *info)
{
struct acpi_device *adev = to_acpi_device_node(fwnode);
struct gpio_desc *desc;
@@ -978,7 +978,7 @@ __acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int
}

/* Then from plain _CRS GPIOs */
- if (!adev || !acpi_can_fallback_to_crs(adev, con_id))
+ if (!adev || !can_fallback)
return ERR_PTR(-ENOENT);

return acpi_get_gpiod_by_index(adev, NULL, idx, info);
@@ -991,10 +991,11 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
unsigned long *lookupflags)
{
struct acpi_device *adev = to_acpi_device_node(fwnode);
+ bool can_fallback = acpi_can_fallback_to_crs(adev, con_id);
struct acpi_gpio_info info;
struct gpio_desc *desc;

- desc = __acpi_find_gpio(fwnode, con_id, idx, &info);
+ desc = __acpi_find_gpio(fwnode, con_id, idx, can_fallback, &info);
if (IS_ERR(desc))
return desc;

--
2.43.0.rc1.1336.g36b5255a03ac


2024-04-11 20:46:20

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/4] gpiolib: acpi: Extract __acpi_find_gpio() helper

We want to reuse it later on in the code. In particular, it helps
to clean up the users of acpi_dev_gpio_irq_wake_get_by().

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/gpio/gpiolib-acpi.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index c2a33beeec50..d47b22ac3ecb 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -945,14 +945,11 @@ static bool acpi_can_fallback_to_crs(struct acpi_device *adev,
return con_id == NULL;
}

-struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
- const char *con_id,
- unsigned int idx,
- enum gpiod_flags *dflags,
- unsigned long *lookupflags)
+static struct gpio_desc *
+__acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int idx,
+ struct acpi_gpio_info *info)
{
struct acpi_device *adev = to_acpi_device_node(fwnode);
- struct acpi_gpio_info info;
struct gpio_desc *desc;
char propname[32];
int i;
@@ -969,10 +966,10 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,

if (adev)
desc = acpi_get_gpiod_by_index(adev,
- propname, idx, &info);
+ propname, idx, info);
else
desc = acpi_get_gpiod_from_data(fwnode,
- propname, idx, &info);
+ propname, idx, info);
if (PTR_ERR(desc) == -EPROBE_DEFER)
return ERR_CAST(desc);

@@ -985,11 +982,28 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
if (!adev || !acpi_can_fallback_to_crs(adev, con_id))
return ERR_PTR(-ENOENT);

- desc = acpi_get_gpiod_by_index(adev, NULL, idx, &info);
+ desc = acpi_get_gpiod_by_index(adev, NULL, idx, info);
if (IS_ERR(desc))
return desc;
}

+ return desc;
+}
+
+struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
+ const char *con_id,
+ unsigned int idx,
+ enum gpiod_flags *dflags,
+ unsigned long *lookupflags)
+{
+ struct acpi_device *adev = to_acpi_device_node(fwnode);
+ struct acpi_gpio_info info;
+ struct gpio_desc *desc;
+
+ desc = __acpi_find_gpio(fwnode, con_id, idx, &info);
+ if (IS_ERR(desc))
+ return desc;
+
if (info.gpioint &&
(*dflags == GPIOD_OUT_LOW || *dflags == GPIOD_OUT_HIGH)) {
dev_dbg(&adev->dev, "refusing GpioInt() entry when doing GPIOD_OUT_* lookup\n");
--
2.43.0.rc1.1336.g36b5255a03ac


2024-04-12 14:53:03

by Mika Westerberg

[permalink] [raw]
Subject: Re: [PATCH v1 0/4] gpiolib: acpi: Use con_id in acpi_dev_gpio_irq_get_by()

On Thu, Apr 11, 2024 at 08:22:28PM +0300, Andy Shevchenko wrote:
> Use con_id instead of property in the acpi_dev_gpio_irq_get_by().
> It will be aligned with other GPIO library functions.
>
> Assumed to go via my GPIO ACPI library tree follwoed by GPIO subsystem.
>
> Andy Shevchenko (4):
> gpiolib: acpi: Extract __acpi_find_gpio() helper
> gpiolib: acpi: Simplify error handling in __acpi_find_gpio()
> gpiolib: acpi: Move acpi_can_fallback_to_crs() out of
> __acpi_find_gpio()
> gpiolib: acpi: Pass con_id instead of property into
> acpi_dev_gpio_irq_get_by()
>
> drivers/gpio/gpio-pca953x.c | 2 +-
> drivers/gpio/gpiolib-acpi.c | 52 +++++++++++--------

For the gpiolib-acpi.c parts,

Acked-by: Mika Westerberg <[email protected]>

2024-04-12 16:05:42

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 0/4] gpiolib: acpi: Use con_id in acpi_dev_gpio_irq_get_by()

On Fri, Apr 12, 2024 at 01:19:44PM +0300, Mika Westerberg wrote:
> On Thu, Apr 11, 2024 at 08:22:28PM +0300, Andy Shevchenko wrote:
> > Use con_id instead of property in the acpi_dev_gpio_irq_get_by().
> > It will be aligned with other GPIO library functions.
> >
> > Assumed to go via my GPIO ACPI library tree follwoed by GPIO subsystem.
> >
> > Andy Shevchenko (4):
> > gpiolib: acpi: Extract __acpi_find_gpio() helper
> > gpiolib: acpi: Simplify error handling in __acpi_find_gpio()
> > gpiolib: acpi: Move acpi_can_fallback_to_crs() out of
> > __acpi_find_gpio()
> > gpiolib: acpi: Pass con_id instead of property into
> > acpi_dev_gpio_irq_get_by()
> >
> > drivers/gpio/gpio-pca953x.c | 2 +-
> > drivers/gpio/gpiolib-acpi.c | 52 +++++++++++--------
>
> For the gpiolib-acpi.c parts,
>
> Acked-by: Mika Westerberg <[email protected]>

Pushed to my review and testing queue, thanks!

Note, I'll will wait for Acks for Mellanox and ACPI code
for a while, the series will appear in Linux Next for the
testing purposes, but if anybody objects, please let me
know.

--
With Best Regards,
Andy Shevchenko