2022-11-27 23:05:36

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] gpio: Do not include <linux/kernel.h> when not really needed.

<linux/kernel.h> is included only for using container_of().
Include <linux/container_of.h> instead, it is much lighter.

Signed-off-by: Christophe JAILLET <[email protected]>
---
Not sure if the prefix should be gpio or gpiolib.

Let see if build-bots spot something which is inherit via kernel.h
---
include/linux/of_gpio.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index a5166eb93437..6db627257a7b 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -34,7 +34,7 @@ enum of_gpio_flags {

#ifdef CONFIG_OF_GPIO

-#include <linux/kernel.h>
+#include <linux/container_of.h>

/*
* OF GPIO chip for memory mapped banks
--
2.34.1


2022-11-28 10:49:40

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] gpio: Do not include <linux/kernel.h> when not really needed.

On Sun, Nov 27, 2022 at 10:52:10PM +0100, Christophe JAILLET wrote:
> <linux/kernel.h> is included only for using container_of().
> Include <linux/container_of.h> instead, it is much lighter.

Reviewed-by: Andy Shevchenko <[email protected]>

Thanks for doing this! We really don't want to see kernel.h to be included by
other headers in the include/linux, include/asm, etc.

> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> Not sure if the prefix should be gpio or gpiolib.

I'm not sure either because this more for the consumers, I would leave gpio.

> Let see if build-bots spot something which is inherit via kernel.h
> ---
> include/linux/of_gpio.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
> index a5166eb93437..6db627257a7b 100644
> --- a/include/linux/of_gpio.h
> +++ b/include/linux/of_gpio.h
> @@ -34,7 +34,7 @@ enum of_gpio_flags {
>
> #ifdef CONFIG_OF_GPIO
>
> -#include <linux/kernel.h>
> +#include <linux/container_of.h>
>
> /*
> * OF GPIO chip for memory mapped banks
> --
> 2.34.1
>
>

--
With Best Regards,
Andy Shevchenko


2022-11-28 18:21:23

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH] gpio: Do not include <linux/kernel.h> when not really needed.

On Sun, Nov 27, 2022 at 10:52 PM Christophe JAILLET
<[email protected]> wrote:
>
> <linux/kernel.h> is included only for using container_of().
> Include <linux/container_of.h> instead, it is much lighter.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> Not sure if the prefix should be gpio or gpiolib.
>
> Let see if build-bots spot something which is inherit via kernel.h
> ---
> include/linux/of_gpio.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
> index a5166eb93437..6db627257a7b 100644
> --- a/include/linux/of_gpio.h
> +++ b/include/linux/of_gpio.h
> @@ -34,7 +34,7 @@ enum of_gpio_flags {
>
> #ifdef CONFIG_OF_GPIO
>
> -#include <linux/kernel.h>
> +#include <linux/container_of.h>
>
> /*
> * OF GPIO chip for memory mapped banks
> --
> 2.34.1
>

Applied, thanks!

Bartosz