[v4,6/7] plist: Replace kernel.h with the necessary inclusions

Message ID 20211007154407.29746-7-andriy.shevchenko@linux.intel.com (mailing list archive)
State Not Applicable, archived
Headers
Series kernel.h further split |

Commit Message

Andy Shevchenko Oct. 7, 2021, 3:44 p.m. UTC
  When kernel.h is used in the headers it adds a lot into dependency hell,
especially when there are circular dependencies are involved.

Replace kernel.h inclusion with the list of what is really being used.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/plist.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Joe Perches Oct. 7, 2021, 5:12 p.m. UTC | #1
On Thu, 2021-10-07 at 18:44 +0300, Andy Shevchenko wrote:
> When kernel.h is used in the headers it adds a lot into dependency hell,
> especially when there are circular dependencies are involved.
> 
> Replace kernel.h inclusion with the list of what is really being used.
[]
> diff --git a/include/linux/plist.h b/include/linux/plist.h
[]
> @@ -73,8 +73,11 @@
[]
> +#include <asm/bug.h>

why asm/bug.h and not linux/bug.h ?
  
Andy Shevchenko Oct. 7, 2021, 5:19 p.m. UTC | #2
On Thu, Oct 07, 2021 at 10:12:56AM -0700, Joe Perches wrote:
> On Thu, 2021-10-07 at 18:44 +0300, Andy Shevchenko wrote:
> > When kernel.h is used in the headers it adds a lot into dependency hell,
> > especially when there are circular dependencies are involved.
> > 
> > Replace kernel.h inclusion with the list of what is really being used.
> []
> > diff --git a/include/linux/plist.h b/include/linux/plist.h
> []
> > @@ -73,8 +73,11 @@
> []
> > +#include <asm/bug.h>
> 
> why asm/bug.h and not linux/bug.h ?

The direct inclusion is from that one. Why linux/bug? What are we going
to use from it?
  
Joe Perches Oct. 7, 2021, 5:26 p.m. UTC | #3
On Thu, 2021-10-07 at 20:19 +0300, Andy Shevchenko wrote:
> On Thu, Oct 07, 2021 at 10:12:56AM -0700, Joe Perches wrote:
> > On Thu, 2021-10-07 at 18:44 +0300, Andy Shevchenko wrote:
> > > When kernel.h is used in the headers it adds a lot into dependency hell,
> > > especially when there are circular dependencies are involved.
> > > 
> > > Replace kernel.h inclusion with the list of what is really being used.
> > []
> > > diff --git a/include/linux/plist.h b/include/linux/plist.h
> > []
> > > @@ -73,8 +73,11 @@
> > []
> > > +#include <asm/bug.h>
> > 
> > why asm/bug.h and not linux/bug.h ?
> 
> The direct inclusion is from that one. Why linux/bug?

A general guideline is to avoid asm includes.
  
Andy Shevchenko Oct. 7, 2021, 5:32 p.m. UTC | #4
On Thu, Oct 07, 2021 at 10:26:05AM -0700, Joe Perches wrote:
> On Thu, 2021-10-07 at 20:19 +0300, Andy Shevchenko wrote:
> > On Thu, Oct 07, 2021 at 10:12:56AM -0700, Joe Perches wrote:
> > > On Thu, 2021-10-07 at 18:44 +0300, Andy Shevchenko wrote:
> > > > When kernel.h is used in the headers it adds a lot into dependency hell,
> > > > especially when there are circular dependencies are involved.
> > > > 
> > > > Replace kernel.h inclusion with the list of what is really being used.
> > > []
> > > > diff --git a/include/linux/plist.h b/include/linux/plist.h
> > > []
> > > > @@ -73,8 +73,11 @@
> > > []
> > > > +#include <asm/bug.h>
> > > 
> > > why asm/bug.h and not linux/bug.h ?
> > 
> > The direct inclusion is from that one. Why linux/bug?
> 
> A general guideline is to avoid asm includes.

It's fine when it has any useful background. Doing cargo cult is not always
a good idea. I plead for common sense.
  
Joe Perches Oct. 7, 2021, 5:46 p.m. UTC | #5
On Thu, 2021-10-07 at 20:32 +0300, Andy Shevchenko wrote:
> On Thu, Oct 07, 2021 at 10:26:05AM -0700, Joe Perches wrote:
> > On Thu, 2021-10-07 at 20:19 +0300, Andy Shevchenko wrote:
> > > On Thu, Oct 07, 2021 at 10:12:56AM -0700, Joe Perches wrote:
> > > > On Thu, 2021-10-07 at 18:44 +0300, Andy Shevchenko wrote:
> > > > > When kernel.h is used in the headers it adds a lot into dependency hell,
> > > > > especially when there are circular dependencies are involved.
> > > > > 
> > > > > Replace kernel.h inclusion with the list of what is really being used.
> > > > []
> > > > > diff --git a/include/linux/plist.h b/include/linux/plist.h
> > > > []
> > > > > @@ -73,8 +73,11 @@
> > > > []
> > > > > +#include <asm/bug.h>
> > > > 
> > > > why asm/bug.h and not linux/bug.h ?
> > > 
> > > The direct inclusion is from that one. Why linux/bug?
> > 
> > A general guideline is to avoid asm includes.
> 
> It's fine when it has any useful background. Doing cargo cult is not always
> a good idea. I plead for common sense.

Common sense isn't particularly common.
Someone is going to run checkpatch on it and submit a patch one day.
Maybe add a comment for the less common.

cheers, Joe
  

Patch

diff --git a/include/linux/plist.h b/include/linux/plist.h
index 66bab1bca35c..0f352c1d3c80 100644
--- a/include/linux/plist.h
+++ b/include/linux/plist.h
@@ -73,8 +73,11 @@ 
 #ifndef _LINUX_PLIST_H_
 #define _LINUX_PLIST_H_
 
-#include <linux/kernel.h>
+#include <linux/container_of.h>
 #include <linux/list.h>
+#include <linux/types.h>
+
+#include <asm/bug.h>
 
 struct plist_head {
 	struct list_head node_list;