lkml.org 
[lkml]   [2023]   [Aug]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: regression from commit b0ce9ce408b6 ("gpiolib: Do not unexport GPIO on freeing")
On Tue, Aug 08, 2023 at 10:28:28AM +0200, Marek Behún wrote:
> Hi,
>
> the commit b0ce9ce408b6 ("gpiolib: Do not unexport GPIO on freeing")
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b0ce9ce408b6
>
> causes a regression on my mvebu arm board (haven't tested on other
> systems), wherein if I export a GPIO to sysfs and then unexport it, it
> does not disasppear from the /sys/class/gpio directory, and subsequent
> writes to the export and unexport files for the gpio fail.
>
> $ cd /sys/class/gpio
> $ ls
> export gpiochip0 gpiochip32 gpiochip512 unexport
> $ echo 43 >export
> $ ls
> export gpio43 gpiochip0 gpiochip32 gpiochip512
> unexport
> $ cat gpio43/value
> 1
> $ echo 43 >unexport
> $ ls
> export gpio43 gpiochip0 gpiochip32 gpiochip512
> unexport
> $ echo 43 >unexport
> ash: write error: Invalid argument
> $ echo 43 >export
> ash: write error: Operation not permitted

Can you test the following change (I'll submit a formal patch if it works)?

diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 530dfd19d7b5..b10a9b5598b2 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -515,8 +515,9 @@ static ssize_t unexport_store(const struct class *class,
* they may be undone on its behalf too.
*/
if (test_and_clear_bit(FLAG_SYSFS, &desc->flags)) {
+ gpiod_unexport(desc);
+ gpiod_free(desc);
status = 0;
- gpiod_free(desc);
}
done:
if (status)
--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2023-08-11 12:20    [W:3.339 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site