linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] libnvdimm: Don't use "proxy" headers
@ 2025-06-26 15:35 Andy Shevchenko
  2025-06-26 21:39 ` Ira Weiny
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2025-06-26 15:35 UTC (permalink / raw)
  To: Andy Shevchenko, nvdimm, linux-kernel
  Cc: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny

Update header inclusions to follow IWYU (Include What You Use)
principle.

Note that kernel.h is discouraged to be included as it's written
at the top of that file.

While doing that, sort headers alphabetically.

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

diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
index e772aae71843..dce8787fba53 100644
--- a/include/linux/libnvdimm.h
+++ b/include/linux/libnvdimm.h
@@ -6,12 +6,12 @@
  */
 #ifndef __LIBNVDIMM_H__
 #define __LIBNVDIMM_H__
-#include <linux/kernel.h>
+
+#include <linux/ioport.h>
 #include <linux/sizes.h>
+#include <linux/spinlock.h>
 #include <linux/types.h>
 #include <linux/uuid.h>
-#include <linux/spinlock.h>
-#include <linux/bio.h>
 
 struct badrange_entry {
 	u64 start;
@@ -80,7 +80,9 @@ typedef int (*ndctl_fn)(struct nvdimm_bus_descriptor *nd_desc,
 		struct nvdimm *nvdimm, unsigned int cmd, void *buf,
 		unsigned int buf_len, int *cmd_rc);
 
+struct attribute_group;
 struct device_node;
+struct module;
 struct nvdimm_bus_descriptor {
 	const struct attribute_group **attr_groups;
 	unsigned long cmd_mask;
@@ -121,6 +123,7 @@ struct nd_mapping_desc {
 	int position;
 };
 
+struct bio;
 struct nd_region;
 struct nd_region_desc {
 	struct resource *res;
@@ -147,8 +150,6 @@ static inline void __iomem *devm_nvdimm_ioremap(struct device *dev,
 	return (void __iomem *) devm_nvdimm_memremap(dev, offset, size, 0);
 }
 
-struct nvdimm_bus;
-
 /*
  * Note that separate bits for locked + unlocked are defined so that
  * 'flags == 0' corresponds to an error / not-supported state.
@@ -238,6 +239,8 @@ struct nvdimm_fw_ops {
 	int (*arm)(struct nvdimm *nvdimm, enum nvdimm_fwa_trigger arg);
 };
 
+struct nvdimm_bus;
+
 void badrange_init(struct badrange *badrange);
 int badrange_add(struct badrange *badrange, u64 addr, u64 length);
 void badrange_forget(struct badrange *badrange, phys_addr_t start,
-- 
2.47.2


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

* Re: [PATCH v1 1/1] libnvdimm: Don't use "proxy" headers
  2025-06-26 15:35 [PATCH v1 1/1] libnvdimm: Don't use "proxy" headers Andy Shevchenko
@ 2025-06-26 21:39 ` Ira Weiny
  2025-06-26 21:56   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Ira Weiny @ 2025-06-26 21:39 UTC (permalink / raw)
  To: Andy Shevchenko, nvdimm, linux-kernel
  Cc: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny

Andy Shevchenko wrote:
> Update header inclusions to follow IWYU (Include What You Use)
> principle.
> 
> Note that kernel.h is discouraged to be included as it's written
> at the top of that file.
> 
> While doing that, sort headers alphabetically.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/libnvdimm.h | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
> index e772aae71843..dce8787fba53 100644
> --- a/include/linux/libnvdimm.h
> +++ b/include/linux/libnvdimm.h
> @@ -6,12 +6,12 @@
>   */
>  #ifndef __LIBNVDIMM_H__
>  #define __LIBNVDIMM_H__
> -#include <linux/kernel.h>
> +
> +#include <linux/ioport.h>

If we are going in this direction why include ioport vs forward declaring
struct resource?

>  #include <linux/sizes.h>
> +#include <linux/spinlock.h>
>  #include <linux/types.h>
>  #include <linux/uuid.h>
> -#include <linux/spinlock.h>
> -#include <linux/bio.h>

I'm leaning toward including bio, module, and sysfs rather than do the
forward declarations.

Are forward declarations preferred these days?

Ira

>  
>  struct badrange_entry {
>  	u64 start;
> @@ -80,7 +80,9 @@ typedef int (*ndctl_fn)(struct nvdimm_bus_descriptor *nd_desc,
>  		struct nvdimm *nvdimm, unsigned int cmd, void *buf,
>  		unsigned int buf_len, int *cmd_rc);
>  
> +struct attribute_group;
>  struct device_node;
> +struct module;
>  struct nvdimm_bus_descriptor {
>  	const struct attribute_group **attr_groups;
>  	unsigned long cmd_mask;
> @@ -121,6 +123,7 @@ struct nd_mapping_desc {
>  	int position;
>  };
>  
> +struct bio;
>  struct nd_region;
>  struct nd_region_desc {
>  	struct resource *res;
> @@ -147,8 +150,6 @@ static inline void __iomem *devm_nvdimm_ioremap(struct device *dev,
>  	return (void __iomem *) devm_nvdimm_memremap(dev, offset, size, 0);
>  }
>  
> -struct nvdimm_bus;
> -
>  /*
>   * Note that separate bits for locked + unlocked are defined so that
>   * 'flags == 0' corresponds to an error / not-supported state.
> @@ -238,6 +239,8 @@ struct nvdimm_fw_ops {
>  	int (*arm)(struct nvdimm *nvdimm, enum nvdimm_fwa_trigger arg);
>  };
>  
> +struct nvdimm_bus;
> +
>  void badrange_init(struct badrange *badrange);
>  int badrange_add(struct badrange *badrange, u64 addr, u64 length);
>  void badrange_forget(struct badrange *badrange, phys_addr_t start,
> -- 
> 2.47.2
> 



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

* Re: [PATCH v1 1/1] libnvdimm: Don't use "proxy" headers
  2025-06-26 21:39 ` Ira Weiny
@ 2025-06-26 21:56   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2025-06-26 21:56 UTC (permalink / raw)
  To: Ira Weiny
  Cc: Andy Shevchenko, nvdimm, linux-kernel, Dan Williams, Vishal Verma,
	Dave Jiang

Thu, Jun 26, 2025 at 04:39:07PM -0500, Ira Weiny kirjoitti:
> Andy Shevchenko wrote:

...


> > +#include <linux/ioport.h>
> 
> If we are going in this direction why include ioport vs forward declaring
> struct resource?


I don't know where I looked when added this. This should be io.h.
And yes, we need forward declarations for struct resource and struct kobject.

...


> > -#include <linux/spinlock.h>
> > -#include <linux/bio.h>
> 
> I'm leaning toward including bio, module, and sysfs rather than do the
> forward declarations.

Header already uses forward declarations.

> Are forward declarations preferred these days?

Always with the dependency hell we have. For example, if we go your way we
would need to include of.h which is yet another monsteur. I prefer to use
this patch as provided.


-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2025-06-26 21:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26 15:35 [PATCH v1 1/1] libnvdimm: Don't use "proxy" headers Andy Shevchenko
2025-06-26 21:39 ` Ira Weiny
2025-06-26 21:56   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).