gpiolib: Get rid of ARCH_NR_GPIOS
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Fri, 2 Sep 2022 12:42:05 +0000 (14:42 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 17 Oct 2022 09:03:09 +0000 (11:03 +0200)
commit7b61212f2a07a5afd213c8876e52b5c9946441e2
tree2fb24fbe8b68a735a39f1cc856539a6495abf2c6
parent502df79b860563d79143be7a1453c2b3224cd836
gpiolib: Get rid of ARCH_NR_GPIOS

Since commit 14e85c0e69d5 ("gpio: remove gpio_descs global array")
there is no limitation on the number of GPIOs that can be allocated
in the system since the allocation is fully dynamic.

ARCH_NR_GPIOS is today only used in order to provide downwards
gpiobase allocation from that value, while static allocation is
performed upwards from 0. However that has the disadvantage of
limiting the number of GPIOs that can be registered in the system.

To overcome this limitation without requiring each and every
platform to provide its 'best-guess' maximum number, rework the
allocation to allocate upwards, allowing approx 2 millions of
GPIOs.

In order to still allow static allocation for legacy drivers, define
GPIO_DYNAMIC_BASE with the value 512 as the start for dynamic
allocation. The 512 value is chosen because it is the end of
the current default range so all current static allocations are
expected to be below that value. Of course that's just a rough
estimate based on the default value, but assuming static
allocations come first, even if there are more static allocations
it should fit under the 512 value.

In the future, it is expected that all static allocations go away
and then dynamic allocation will be patched to start at 0.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
arch/arm/include/asm/gpio.h
drivers/gpio/gpiolib.c
include/asm-generic/gpio.h