All of lore.kernel.org
 help / color / mirror / Atom feed
* gpiolib: why does gpio_set_bias() suppress ENOTSUPP?
@ 2022-03-31  2:52 Kent Gibson
  2022-03-31 13:53 ` Andy Shevchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Kent Gibson @ 2022-03-31  2:52 UTC (permalink / raw)
  To: linux-gpio, brgl, andriy.shevchenko, thomas.petazzoni; +Cc: linus.walleij

Hi all,

It has recently come to my attention that the setting of bias by the
cdev uAPI is a best effort operation that quietly succeeds if bias is
not supported by the hardware. That strikes me as being a bug.
It seems I was aware of this when adding bias to the uAPI and intended
to fix it, as shown in the comments of v4 of the corrsponding patch
series[1]:

> > The setting of bias is performed by gpio_set_bias, which is hooked into
> > gpiod_direction_input and gpiod_direction_output.  It extends the setting
> > of bias that was already present in gpiod_direction_input.
> > In keeping with the existing behaviour, the bias is set on a best-effort
> > basis - no error is returned to the user if an error is returned by the
> > pinctrl driver.  Returning an error makes sense to me, particularly for
> > the uAPI, but that conflicts with the existing gpiod_direction_input
> > behaviour. So leave as best-effort, change gpiod_direction_input
> > behaviour, or restructure to support both behaviours?

> Thomas: is there any reason not to check the return value of these
> calls for errors other than -EOPNOTSUPP?

that being my comment, and Bart's followup question to Thomas.

That went unanswered AFAICT and the issue subsequently fell through the
cracks.

I would like to fix the uAPI such that if the hardware does not support
the requested configuration, or if it can't be emulated in the kernel,
that fact is returned to userspace - bias being the sole counter example
as far as I am aware.

The simplest fix involves changing gpio_set_bias() to call gpio_set_config()
rather than gpio_set_config_with_argument_optional(), but as mentioned in
my comment above, that would impact any existing users of
gpiod_direction_input() that assume the best-effort behaviour.
I haven't been able to find any such usage, but that could just be proof
that I'm not looking in the right place.
Any input on that front would be greatly appreciated.

Also, fixing this as mentioned could be considered an uAPI ABI change.
Is this a bug, so that is ok, or do I need to consider adding a strict
mode flag or somesuch to the API?

Bart, I'm also hoping to extend the gpiosim to optionally not support
bias in gc->set_config() to test this case.
Any suggstions on a configfs interface extension to do that?

My apologies for the verbage rather than proffering a patch, but the
different paths have vastly different costs, and the simplest solution
has the potential to introduce breakage.

Cheers,
Kent.

[1] https://www.spinics.net/lists/linux-gpio/msg43579.html

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

end of thread, other threads:[~2022-04-04 10:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31  2:52 gpiolib: why does gpio_set_bias() suppress ENOTSUPP? Kent Gibson
2022-03-31 13:53 ` Andy Shevchenko
2022-03-31 14:15   ` Kent Gibson
2022-03-31 17:19     ` Andy Shevchenko
2022-04-01  0:08       ` Kent Gibson
2022-04-01 10:42         ` Andy Shevchenko
2022-04-02  1:45           ` Kent Gibson
2022-04-01 10:36     ` Hans de Goede
2022-04-02  1:45       ` Kent Gibson
2022-04-02  9:11         ` Hans de Goede
2022-04-04  9:23           ` Andy Shevchenko
2022-04-04 10:06             ` Kent Gibson
2022-04-04 10:16               ` Andy Shevchenko

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.