On Mon, Dec 07, 2020 at 02:41:03PM +0000, Marc Zyngier wrote:
On 2020-12-07 14:01, Johan Hovold wrote:
> On Fri, Dec 04, 2020 at 04:47:35PM +0000, Marc Zyngier wrote:
>> Having recently tried to use the CBUS GPIOs that come thanks to the
>> ftdio_sio driver, it occurred to me that the driver has a couple of
>> usability issues:
>>
>> - it advertises potential GPIOs that are reserved to other uses (LED
>> control, or something else)
>
> Consider the alternative, that the gpio offsets (for CBUS0, CBUS1,
> CBUS2
> or CBUS4) varies depending on how the pins have been muxed. Hardly very
> user friendly.
That's not what I suggest. If you want fixed GPIO offsets, fine by me.
But telling the user "these are GPIOs you can use", and then
"on second though, you can't" is not exactly consistent.
It's really no different from any other gpio chip which registers all
its lines, including those which may have been muxed for other purposes.
>> - it returns an odd error (-ENODEV), instead of the expected -EINVAL
>> when a line is unavailable, leading to a difficult diagnostic
>
> Hmm, maybe. Several gpio driver return -ENODEV when trying to request
> reserved pins. Even gpiolib returns -ENODEV when a pins is not yet
> available due to probe deferal.
-ENODEV really means "no GPIOchip" in this context. The fact that
other drivers return -ENODEV for reserved pins looks like a bug to me.
No, the chip is there. The -ENODEV is what you get when requesting the
line, because the line isn't available.
> -EBUSY could also be an alternative, but that's used to indicate that a
> line is already in use as a gpio.
Or something else. Which is exactly the case, as it's been allocated
to another function.
Right, there are invalid requests (e.g. requesting line five of a four
line chip), lines that are already in use, and lines not available due
to muxing.
And then there's the question of whether to use the same or distinct
errnos for these. I believe using distinct errnos provides more
feedback, but we can certainly pick another errno for this if it's
really that confusing.