All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpiolib: Avoid side effects in gpio_is_visible()
@ 2023-05-12  4:28 Chris Packham
  2023-05-12  7:24 ` Johan Hovold
  2023-05-12  7:56 ` Linus Walleij
  0 siblings, 2 replies; 31+ messages in thread
From: Chris Packham @ 2023-05-12  4:28 UTC (permalink / raw)
  To: linus.walleij, brgl, johan, andy.shevchenko, maz, Ben Brown
  Cc: linux-gpio, linux-kernel, Chris Packham

Calling gpiod_to_irq() creates an irq_desc for the GPIO. This is not
something that should happen when just exporting the GPIO via sysfs. The
effect of this was observed as triggering a warning in
gpiochip_disable_irq() when kexec()ing after exporting a GPIO.

Remove the call to gpiod_to_irq() from gpio_is_visible(). The actual
intended creation of the irq_desc comes via edge_store() when requested
by the user.

Fixes: ebbeba120ab2 ("gpio: sysfs: fix gpio attribute-creation race")
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---

Notes:
    This is technically a v2 of
    https://lore.kernel.org/lkml/20230510001151.3946931-1-chris.packham@alliedtelesis.co.nz/
    but the solution is so different it's probably best to treat it as a new
    patch.

 drivers/gpio/gpiolib-sysfs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 530dfd19d7b5..f859dcd1cbf3 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -362,8 +362,6 @@ static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr,
 		if (!show_direction)
 			mode = 0;
 	} else if (attr == &dev_attr_edge.attr) {
-		if (gpiod_to_irq(desc) < 0)
-			mode = 0;
 		if (!show_direction && test_bit(FLAG_IS_OUT, &desc->flags))
 			mode = 0;
 	}
-- 
2.40.1


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

end of thread, other threads:[~2023-05-29 22:00 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-12  4:28 [PATCH] gpiolib: Avoid side effects in gpio_is_visible() Chris Packham
2023-05-12  7:24 ` Johan Hovold
2023-05-14 21:57   ` Chris Packham
2023-05-15  6:43     ` andy.shevchenko
2023-05-15 21:01       ` Chris Packham
2023-05-12  7:56 ` Linus Walleij
2023-05-14 22:27   ` Chris Packham
2023-05-16 13:57     ` Linus Walleij
2023-05-16 22:19       ` Chris Packham
2023-05-16 22:47         ` Kent Gibson
2023-05-16 23:50           ` Chris Packham
2023-05-17  0:47             ` Kent Gibson
2023-05-17  1:05               ` Kent Gibson
2023-05-17  1:07               ` Chris Packham
2023-05-17  1:21                 ` Kent Gibson
2023-05-17  8:54             ` Andy Shevchenko
2023-05-17  9:10               ` Kent Gibson
2023-05-17 21:30               ` Chris Packham
2023-05-23 16:38                 ` andy.shevchenko
2023-05-23 21:17                   ` Chris Packham
2023-05-24  5:41                     ` Kent Gibson
2023-05-24 23:53                       ` using libgpiod to replace sysfs ABI (was Re: [PATCH] gpiolib: Avoid side effects in gpio_is_visible()) Chris Packham
2023-05-25  1:19                         ` Kent Gibson
2023-05-25  9:13                         ` Andy Shevchenko
2023-05-25 14:35                           ` Bartosz Golaszewski
2023-05-26 12:46                       ` [PATCH] gpiolib: Avoid side effects in gpio_is_visible() Bartosz Golaszewski
2023-05-28 21:04                         ` Chris Packham
2023-05-29  9:19                 ` Linus Walleij
2023-05-29 15:07                   ` Andrew Lunn
2023-05-29  9:07         ` Linus Walleij
2023-05-29 22:00           ` Chris Packham

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.