• Christophe Leroy's avatar
    gpiolib: Get rid of ARCH_NR_GPIOS · 7b61212f
    Christophe Leroy authored
    Since commit 14e85c0e ("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: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
    Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
    Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
    7b61212f
gpiolib.c 123 KB