linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	linux-gpio@vger.kernel.org, Hans de Goede <hdegoede@redhat.com>,
	Jamie McClymont <jamie@kwiius.com>
Subject: Re: [PATCH v1 1/3] gpiolib: acpi: Respect bias settings for GpioInt() resource
Date: Thu, 22 Oct 2020 09:51:41 +0300	[thread overview]
Message-ID: <20201022065141.GH2495@lahna.fi.intel.com> (raw)
In-Reply-To: <20201021163844.GX4077@smile.fi.intel.com>

On Wed, Oct 21, 2020 at 07:38:44PM +0300, Andy Shevchenko wrote:
> On Wed, Oct 21, 2020 at 12:58:54PM +0300, Mika Westerberg wrote:
> > On Wed, Oct 14, 2020 at 04:31:52PM +0300, Andy Shevchenko wrote:
> > > 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.
> 
> ...
> 
> > > -			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;
> > 
> > Should the above be undone if the conversion here fails?
> 
> But wouldn't it be not good if we changed direction, for example, and then
> change it back? (IRQ requires input, which is safer, right?)
> 
> This makes me think what gpiod_to_irq() may do for physical state of the pin.
> On the brief search it seems there is no side effect on the pin with that
> function, so, perhaps the original order has that in mind to not shuffle with
> line if mapping can't be established. But if setting flags fail, we may got
> into the state which is not equal to the initial one, right?
> 
> So, in either case I see no good way to roll back the physical pin state
> changes. But I can return ordering of the calls in next version.
> 
> What do you think?

If there is no good way rolling back to the previous state then I think
this ordering is as good as the original, so up to you :-)

  reply	other threads:[~2020-10-22  6:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-10-22  9:05     ` Hans de Goede
2020-10-22 10:43       ` 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=20201022065141.GH2495@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=hdegoede@redhat.com \
    --cc=jamie@kwiius.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@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).