linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	linux-gpio@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: Re: regression from commit b0ce9ce408b6 ("gpiolib: Do not unexport GPIO on freeing")
Date: Mon, 14 Aug 2023 09:39:34 +0200	[thread overview]
Message-ID: <20230814093934.1793961e@dellmb> (raw)
In-Reply-To: <ZNYKjnPjIRWIYVot@smile.fi.intel.com>

On Fri, 11 Aug 2023 13:16:46 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

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

tested, works.

Please add Fixes tag when sending the patch

  reply	other threads:[~2023-08-14  7:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08  8:28 regression from commit b0ce9ce408b6 ("gpiolib: Do not unexport GPIO on freeing") Marek Behún
2023-08-08 14:01 ` Andy Shevchenko
2023-08-11 10:16 ` Andy Shevchenko
2023-08-14  7:39   ` Marek Behún [this message]
2023-08-14 11:18     ` Andy Shevchenko
2023-08-14 11:55       ` Marek Behún
2023-08-14 12:26         ` Andy Shevchenko

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=20230814093934.1793961e@dellmb \
    --to=kabel@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).