All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] gpio: Avoid kernel.h inclusion where it's possible
@ 2020-02-05 13:43 Andy Shevchenko
  2020-02-06 21:47 ` Rob Herring
  2020-02-10 11:59 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2020-02-05 13:43 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, linux-gpio, Rob Herring,
	Frank Rowand, devicetree, Arnd Bergmann
  Cc: Andy Shevchenko

Inclusion of kernel.h increases the mess with the header dependencies.
Avoid kernel.h inclusion where it's possible.

Besides that, clean up a bit other inclusions inside GPIO subsystem headers.
It includes:
 - removal pin control bits (forward declaration and header) from linux/gpio.h
 - removal of.h from asm-generic/gpio.h
 - use of explicit headers in gpio/consumer.h
 - add FIXME note with regard to gpio.h inclusion in of_gpio,h

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: Elaborate changes in the commit message (Bartosz)
 include/asm-generic/gpio.h    | 4 ++--
 include/linux/gpio.h          | 2 --
 include/linux/gpio/consumer.h | 5 ++++-
 include/linux/of_gpio.h       | 9 ++++++---
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 19eadac415c4..aea9aee1f3e9 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -2,10 +2,8 @@
 #ifndef _ASM_GENERIC_GPIO_H
 #define _ASM_GENERIC_GPIO_H
 
-#include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/errno.h>
-#include <linux/of.h>
 
 #ifdef CONFIG_GPIOLIB
 
@@ -140,6 +138,8 @@ static inline void gpio_unexport(unsigned gpio)
 
 #else	/* !CONFIG_GPIOLIB */
 
+#include <linux/kernel.h>
+
 static inline bool gpio_is_valid(int number)
 {
 	/* only non-negative numbers are valid */
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 2157717c2136..008ad3ee56b7 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -102,11 +102,9 @@ void devm_gpio_free(struct device *dev, unsigned int gpio);
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/bug.h>
-#include <linux/pinctrl/pinctrl.h>
 
 struct device;
 struct gpio_chip;
-struct pinctrl_dev;
 
 static inline bool gpio_is_valid(int number)
 {
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index bf2d017dd7b7..0a72fccf60ff 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -2,9 +2,10 @@
 #ifndef __LINUX_GPIO_CONSUMER_H
 #define __LINUX_GPIO_CONSUMER_H
 
+#include <linux/bits.h>
 #include <linux/bug.h>
+#include <linux/compiler_types.h>
 #include <linux/err.h>
-#include <linux/kernel.h>
 
 struct device;
 
@@ -189,6 +190,8 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
 
 #else /* CONFIG_GPIOLIB */
 
+#include <linux/kernel.h>
+
 static inline int gpiod_count(struct device *dev, const char *con_id)
 {
 	return 0;
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index 16967390a3fe..f821095218b0 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -11,9 +11,8 @@
 #define __LINUX_OF_GPIO_H
 
 #include <linux/compiler.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/gpio.h>
+#include <linux/gpio/driver.h>
+#include <linux/gpio.h>		/* FIXME: Shouldn't be here */
 #include <linux/of.h>
 
 struct device_node;
@@ -34,6 +33,8 @@ enum of_gpio_flags {
 
 #ifdef CONFIG_OF_GPIO
 
+#include <linux/kernel.h>
+
 /*
  * OF GPIO chip for memory mapped banks
  */
@@ -63,6 +64,8 @@ extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
 
 #else /* CONFIG_OF_GPIO */
 
+#include <linux/errno.h>
+
 /* Drivers may not strictly depend on the GPIO support, so let them link. */
 static inline int of_get_named_gpio_flags(struct device_node *np,
 		const char *list_name, int index, enum of_gpio_flags *flags)
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gpio: Avoid kernel.h inclusion where it's possible
  2020-02-05 13:43 [PATCH v2] gpio: Avoid kernel.h inclusion where it's possible Andy Shevchenko
@ 2020-02-06 21:47 ` Rob Herring
  2020-02-06 22:07   ` Andy Shevchenko
  2020-02-10 11:59 ` Linus Walleij
  1 sibling, 1 reply; 4+ messages in thread
From: Rob Herring @ 2020-02-06 21:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Bartosz Golaszewski, Linus Walleij, linux-gpio, Frank Rowand,
	devicetree, Arnd Bergmann

On Wed, Feb 05, 2020 at 03:43:36PM +0200, Andy Shevchenko wrote:
> Inclusion of kernel.h increases the mess with the header dependencies.
> Avoid kernel.h inclusion where it's possible.
> 
> Besides that, clean up a bit other inclusions inside GPIO subsystem headers.
> It includes:
>  - removal pin control bits (forward declaration and header) from linux/gpio.h
>  - removal of.h from asm-generic/gpio.h
>  - use of explicit headers in gpio/consumer.h
>  - add FIXME note with regard to gpio.h inclusion in of_gpio,h
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2: Elaborate changes in the commit message (Bartosz)
>  include/asm-generic/gpio.h    | 4 ++--
>  include/linux/gpio.h          | 2 --
>  include/linux/gpio/consumer.h | 5 ++++-
>  include/linux/of_gpio.h       | 9 ++++++---
>  4 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
> index 19eadac415c4..aea9aee1f3e9 100644
> --- a/include/asm-generic/gpio.h
> +++ b/include/asm-generic/gpio.h
> @@ -2,10 +2,8 @@
>  #ifndef _ASM_GENERIC_GPIO_H
>  #define _ASM_GENERIC_GPIO_H
>  
> -#include <linux/kernel.h>
>  #include <linux/types.h>
>  #include <linux/errno.h>
> -#include <linux/of.h>
>  
>  #ifdef CONFIG_GPIOLIB
>  
> @@ -140,6 +138,8 @@ static inline void gpio_unexport(unsigned gpio)
>  
>  #else	/* !CONFIG_GPIOLIB */
>  
> +#include <linux/kernel.h>
> +

I don't really think moving the includes inside #ifdef's is an 
improvment.

But I'll leave it to Linus.

Rob

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gpio: Avoid kernel.h inclusion where it's possible
  2020-02-06 21:47 ` Rob Herring
@ 2020-02-06 22:07   ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2020-02-06 22:07 UTC (permalink / raw)
  To: Rob Herring
  Cc: Bartosz Golaszewski, Linus Walleij, linux-gpio, Frank Rowand,
	devicetree, Arnd Bergmann

On Thu, Feb 06, 2020 at 02:47:29PM -0700, Rob Herring wrote:
> On Wed, Feb 05, 2020 at 03:43:36PM +0200, Andy Shevchenko wrote:
> > Inclusion of kernel.h increases the mess with the header dependencies.
> > Avoid kernel.h inclusion where it's possible.

> > Besides that, clean up a bit other inclusions inside GPIO subsystem headers.
> > It includes:
> >  - removal pin control bits (forward declaration and header) from linux/gpio.h
> >  - removal of.h from asm-generic/gpio.h
> >  - use of explicit headers in gpio/consumer.h
> >  - add FIXME note with regard to gpio.h inclusion in of_gpio,h

...

> >  #else	/* !CONFIG_GPIOLIB */
> >  
> > +#include <linux/kernel.h>
> > +
> 
> I don't really think moving the includes inside #ifdef's is an 
> improvment.

I also not a big fun, but for now it removes in most cases when
CONFIG_GPIOLIB=y. And this is already an improvement. Next step is to replace
it with newly created (when it will be created) header might_sleep.h.

> But I'll leave it to Linus.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gpio: Avoid kernel.h inclusion where it's possible
  2020-02-05 13:43 [PATCH v2] gpio: Avoid kernel.h inclusion where it's possible Andy Shevchenko
  2020-02-06 21:47 ` Rob Herring
@ 2020-02-10 11:59 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2020-02-10 11:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM, Rob Herring,
	Frank Rowand,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Arnd Bergmann

On Wed, Feb 5, 2020 at 2:43 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Inclusion of kernel.h increases the mess with the header dependencies.
> Avoid kernel.h inclusion where it's possible.
>
> Besides that, clean up a bit other inclusions inside GPIO subsystem headers.
> It includes:
>  - removal pin control bits (forward declaration and header) from linux/gpio.h
>  - removal of.h from asm-generic/gpio.h
>  - use of explicit headers in gpio/consumer.h
>  - add FIXME note with regard to gpio.h inclusion in of_gpio,h
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2: Elaborate changes in the commit message (Bartosz)

Patch applied as clearly the kernel looks better after this patch
than before this patch.

Thanks!
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-10 11:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05 13:43 [PATCH v2] gpio: Avoid kernel.h inclusion where it's possible Andy Shevchenko
2020-02-06 21:47 ` Rob Herring
2020-02-06 22:07   ` Andy Shevchenko
2020-02-10 11:59 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.