Skip to contentSkip to conversation

Avoid kernel.h inclusion

DISCUSSION Andy Shevchenko 2 participants 2 messages Feb 4, 2020 – Feb 10, 2020 GPIO

lore
Share & tools
lore
#0 lore raw

Hi!

I started cleaning up kernel.h mess and noticed that GPIO subsystem headers are highly utilize kernel.h. Can we get rid of kernel.h inclusion in this cycle?

$ git grep -n -w '#include <linux/kernel.h>' -- include/ | grep gpio
include/asm-generic/gpio.h:5:#include <linux/kernel.h>
include/linux/gpio.h:102:#include <linux/kernel.h>
include/linux/gpio/consumer.h:7:#include <linux/kernel.h>
include/linux/of_gpio.h:14:#include <linux/kernel.h>

Currently, for example, I commented out log2.h and bitops.h in kernel.h (for testing purposes) and immediately got

include/linux/gpio/consumer.h:38:34: error: implicit declaration of function ‘BIT’ [-Werror=implicit-function-declaration]

   38 | #define GPIOD_FLAGS_BIT_DIR_SET  BIT(0)
      |                                  ^~~
...
include/linux/gpio/consumer.h:55:2: error: enumerator value for ‘GPIOD_OUT_HIGH_OPEN_DRAIN’ is not an integer constant
   55 |  GPIOD_OUT_HIGH_OPEN_DRAIN = GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_OPEN_DRAIN,
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~

Obviously consumer.h is user of bits.h.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#1 lore raw
Quoted 2 lines · Andy Shevchenko

I started cleaning up kernel.h mess and noticed that GPIO subsystem headers are highly utilize kernel.h. Can we get rid of kernel.h inclusion in this cycle?

Yeah patches welcome :) I might not have the time to fix it myself.

Yours,
Linus Walleij