linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/3] gpiolib: acpi: Respect bias settings for GpioInt() resource
@ 2020-10-14 13:31 Andy Shevchenko
  2020-10-14 13:31 ` [PATCH v1 2/3] gpiolib: acpi: Use named item for enum gpiod_flags variable Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Andy Shevchenko @ 2020-10-14 13:31 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio, Mika Westerberg,
	Hans de Goede
  Cc: Andy Shevchenko, Jamie McClymont

In some cases the GpioInt() resource is coming with bias settings
which may affect system functioning. Respect bias settings for
GpioInt() resource by calling acpi_gpio_update_gpiod_*flags() API
in acpi_dev_gpio_irq_get().

While at it, refactor to configure flags first and, only when succeeded,
map the IRQ descriptor.

Reported-by: Jamie McClymont <jamie@kwiius.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---

This one highly depends on Intel pin control driver changes (for now [1], but
might be more), so it's probably not supposed to be backported (at least right
now).

[1]: https://lore.kernel.org/linux-gpio/20201014104638.84043-1-andriy.shevchenko@linux.intel.com/T/

 drivers/gpio/gpiolib-acpi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 834a12f3219e..52b961673f16 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -942,21 +942,25 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
 
 		if (info.gpioint && idx++ == index) {
 			unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT;
+			enum gpiod_flags dflags = info.flags;
 			char label[32];
 			int irq;
 
 			if (IS_ERR(desc))
 				return PTR_ERR(desc);
 
-			irq = gpiod_to_irq(desc);
-			if (irq < 0)
-				return irq;
+			acpi_gpio_update_gpiod_flags(&dflags, &info);
+			acpi_gpio_update_gpiod_lookup_flags(&lflags, &info);
 
 			snprintf(label, sizeof(label), "GpioInt() %d", index);
-			ret = gpiod_configure_flags(desc, label, lflags, info.flags);
+			ret = gpiod_configure_flags(desc, label, lflags, dflags);
 			if (ret < 0)
 				return ret;
 
+			irq = gpiod_to_irq(desc);
+			if (irq < 0)
+				return irq;
+
 			irq_flags = acpi_dev_get_irq_type(info.triggering,
 							  info.polarity);
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-10-22 10:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-14 13:31 [PATCH v1 1/3] gpiolib: acpi: Respect bias settings for GpioInt() resource Andy Shevchenko
2020-10-14 13:31 ` [PATCH v1 2/3] gpiolib: acpi: Use named item for enum gpiod_flags variable Andy Shevchenko
2020-10-21  9:59   ` Mika Westerberg
2020-10-14 13:31 ` [PATCH v1 3/3] gpiolib: of: " Andy Shevchenko
2020-10-21  9:58 ` [PATCH v1 1/3] gpiolib: acpi: Respect bias settings for GpioInt() resource Mika Westerberg
2020-10-21 16:38   ` Andy Shevchenko
2020-10-22  6:51     ` Mika Westerberg
2020-10-22  9:05     ` Hans de Goede
2020-10-22 10:43       ` Andy Shevchenko

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