Re: [PATCH] gpio: Allow user to customise maximum number of GPIOs

Linus Walleij
2022-08-28T11:36:15Z

On Sun, Aug 28, 2022 at 11:06 AM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:

> And I guess there might be other drivers like that (I found that one
> because of its comment mentionning ARCH_NR_GPIOS.

Yes there are a bunch of GPIO controllers with fixed base.

These only exist because there is boardfile code that uses
these fixed GPIO numbers.

> Another solution could be to leave first GPIOs for static allocation,
> and allocate dynamic ones from 256 or from 512 ?
>
> Maybe in two steps:
> - First step: Allocate dynamic from 256 upwards and add a pr_warn() for
> all static allocations.

OK that is reasonable.

I thought that maybe we could assume the fixed bases to probe first
and thus reserve the GPIO bases they want before we get to the
dynamically allocated drivers.

This could be a good first step.

> - Second step later: Allocate dynamic from 0 and forbid static allocation.

What needs to happen for doing that 100% safe is to get rid of all
board files, mostly in arch/arm/mach* but also elsewhere, or to
augment all boardfiles to use descriptor tables instead.

But you're right, try the two step approach first.

Yours,
Linus Walleij