Re: gpio_is_valid()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 29, 2021 at 12:50 PM Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:

> Anybody to shed a light why we have two stubs of gpio_is_valid() and
> one actual declaration?
> % git grep -n -w gpio_is_valid -- include/
> include/asm-generic/gpio.h:44:static inline bool gpio_is_valid(int number)
> include/asm-generic/gpio.h:143:static inline bool gpio_is_valid(int number)
> include/linux/gpio.h:109:static inline bool gpio_is_valid(int number)

Remnants from "generic GPIO" where some custom platform would have
a custom implementation (and semantic!) while using the same
API.

include/linux/gpio.h:109 - this is just a stub !CONFIG_GPIOLIB

include/asm-generic/gpio.h:44 - this one is used if CONFIG_GPIOLIB

This is for all "normal" GPIO providers and consumers, end of
story.

include/asm-generic/gpio.h:143 - this one is used of !CONFIG_GPIOLIB
but only <asm/gpio.h> is included, meaning the system has a
private implementation of the symbols, not those from GPIOLIB.

It makes sense if you realize there are GPIO drivers that only include
<asm/gpio.h> and does not include <linux/gpio.h>. But I wonder if
there still are? (Unfortunately I think so, used to be some weird archs
and some minor ARM systems.)

Generic GPIO was probably not a very good idea, I think at the time
it was a compromise for making custom implementations migrate
to the generic implementation over time.

I think it is actually gone now! We can probably delete:
arch/arm/include/asm/gpio.h
include/asm-generic/gpio.h

And just move the remaining stubs into <linux/gpio.h>.

Interested in the job or should I take a stab at it? :D

Yours,
Linus Walleij



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux