On Mon, Mar 29, 2021 at 5:36 PM Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote: > > On Mon, Mar 29, 2021 at 4:31 PM Linus Walleij <linus.walleij@xxxxxxxxxx> wrote: > > > > 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. > > Aha, thanks for elaboration! > > > 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.) > > The files so far that include asm/gpio.h > > Documentation/translations/zh_CN/gpio.txt > drivers/gpio/Kconfig > include/asm-generic/gpio.h > include/linux/gpio.h Another list (asm-generic/gpio.h) Documentation/translations/zh_CN/gpio.txt:477:<asm/gpio.h> 包含 <asm-generic/gpio.h>,同时定义三个方法: MAINTAINERS:7631:F: include/asm-generic/gpio.h arch/arm/include/asm/gpio.h:10:#include <asm-generic/gpio.h> arch/m68k/include/asm/mcfgpio.h:12:#include <asm-generic/gpio.h> arch/sh/include/asm/gpio.h:19:#include <asm-generic/gpio.h> drivers/gpio/gpio-davinci.c:26:#include <asm-generic/gpio.h> drivers/pinctrl/core.c:31:#include <asm-generic/gpio.h> include/linux/gpio.h:62:#include <asm-generic/gpio.h> > > 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 > > I think it's you who understands the area better. > I missed (I hope *fortunately*) the legacy GPIO APIs. > > -- > With Best Regards, > Andy Shevchenko -- With Best Regards, Andy Shevchenko