diff mbox series

[1/5] coresight: Include required headers in C files

Message ID 20200426185805.14923-2-swboyd@chromium.org (mailing list archive)
State New, archived
Headers show
Series coresight: Minor sparse and style fixes | expand

Commit Message

Stephen Boyd April 26, 2020, 6:58 p.m. UTC
We should include headers that C files use in the C files that use them
and avoid relying on implicit includes as much as possible. This helps
avoid compiler errors in the future about missing declarations when
header files change includes in the future.

Cc: Douglas Anderson <dianders@chromium.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 drivers/hwtracing/coresight/coresight-cti-platform.c |  8 +++++++-
 drivers/hwtracing/coresight/coresight-cti-sysfs.c    |  7 +++++++
 drivers/hwtracing/coresight/coresight-cti.h          | 10 +++++++++-
 3 files changed, 23 insertions(+), 2 deletions(-)

Comments

Mathieu Poirier April 27, 2020, 4:34 p.m. UTC | #1
On Sun, Apr 26, 2020 at 11:58:01AM -0700, Stephen Boyd wrote:
> We should include headers that C files use in the C files that use them
> and avoid relying on implicit includes as much as possible. This helps
> avoid compiler errors in the future about missing declarations when
> header files change includes in the future.
> 
> Cc: Douglas Anderson <dianders@chromium.org>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Mike Leach <mike.leach@linaro.org>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> ---
>  drivers/hwtracing/coresight/coresight-cti-platform.c |  8 +++++++-
>  drivers/hwtracing/coresight/coresight-cti-sysfs.c    |  7 +++++++
>  drivers/hwtracing/coresight/coresight-cti.h          | 10 +++++++++-
>  3 files changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-cti-platform.c b/drivers/hwtracing/coresight/coresight-cti-platform.c
> index b44d83142b62..245f16c61af8 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-platform.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-platform.c
> @@ -2,11 +2,17 @@
>  /*
>   * Copyright (c) 2019, The Linaro Limited. All rights reserved.
>   */
> +#include <linux/coresight.h>
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/of.h>
> +#include <linux/property.h>
> +#include <linux/slab.h>
>  
>  #include <dt-bindings/arm/coresight-cti-dt.h>
> -#include <linux/of.h>
>  
>  #include "coresight-cti.h"
> +#include "coresight-priv.h"
>  
>  /* Number of CTI signals in the v8 architecturally defined connection */
>  #define NR_V8PE_IN_SIGS		2
> diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> index 1f8fb7c15e80..bed460541f15 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> @@ -4,7 +4,14 @@
>   * Author: Mike Leach <mike.leach@linaro.org>
>   */
>  
> +#include <linux/atomic.h>
>  #include <linux/coresight.h>
> +#include <linux/device.h>
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/slab.h>
> +#include <linux/spinlock.h>
> +#include <linux/sysfs.h>
>  
>  #include "coresight-cti.h"
>  
> diff --git a/drivers/hwtracing/coresight/coresight-cti.h b/drivers/hwtracing/coresight/coresight-cti.h
> index 004df3ab9dd0..d80123b905a8 100644
> --- a/drivers/hwtracing/coresight/coresight-cti.h
> +++ b/drivers/hwtracing/coresight/coresight-cti.h
> @@ -7,8 +7,10 @@
>  #ifndef _CORESIGHT_CORESIGHT_CTI_H
>  #define _CORESIGHT_CORESIGHT_CTI_H
>  
> -#include <asm/local.h>
> +#include <linux/list.h>
>  #include <linux/spinlock.h>
> +#include <linux/types.h>
> +
>  #include "coresight-priv.h"
>  
>  /*
> @@ -52,6 +54,12 @@
>   */
>  #define CTIINOUTEN_MAX		32
>  
> +struct attribute;
> +struct attribute_group;
> +struct coresight_device;
> +struct device;
> +struct fwnode_handle;
> +

I would prefer adding the headers rather than forward declarations, it scales
better.

Thanks,
Mathieu

>  /**
>   * Group of related trigger signals
>   *
> -- 
> Sent by a computer, using git, on the internet
>
Stephen Boyd April 28, 2020, 5:34 p.m. UTC | #2
Quoting Mathieu Poirier (2020-04-27 09:34:46)
> On Sun, Apr 26, 2020 at 11:58:01AM -0700, Stephen Boyd wrote:
> > diff --git a/drivers/hwtracing/coresight/coresight-cti.h b/drivers/hwtracing/coresight/coresight-cti.h
> > index 004df3ab9dd0..d80123b905a8 100644
> > --- a/drivers/hwtracing/coresight/coresight-cti.h
> > +++ b/drivers/hwtracing/coresight/coresight-cti.h
> > @@ -7,8 +7,10 @@
> >  #ifndef _CORESIGHT_CORESIGHT_CTI_H
> >  #define _CORESIGHT_CORESIGHT_CTI_H
> >  
> > -#include <asm/local.h>
> > +#include <linux/list.h>
> >  #include <linux/spinlock.h>
> > +#include <linux/types.h>
> > +
> >  #include "coresight-priv.h"
> >  
> >  /*
> > @@ -52,6 +54,12 @@
> >   */
> >  #define CTIINOUTEN_MAX               32
> >  
> > +struct attribute;
> > +struct attribute_group;
> > +struct coresight_device;
> > +struct device;
> > +struct fwnode_handle;
> > +
> 
> I would prefer adding the headers rather than forward declarations, it scales
> better.
> 

Ok. I'm worried that including too many headers when they're not
necessary means it's easier to get into the problem that I'm trying to
solve here where kcalloc() isn't defined. Anyway, I'll update the
patch and resend!
diff mbox series

Patch

diff --git a/drivers/hwtracing/coresight/coresight-cti-platform.c b/drivers/hwtracing/coresight/coresight-cti-platform.c
index b44d83142b62..245f16c61af8 100644
--- a/drivers/hwtracing/coresight/coresight-cti-platform.c
+++ b/drivers/hwtracing/coresight/coresight-cti-platform.c
@@ -2,11 +2,17 @@ 
 /*
  * Copyright (c) 2019, The Linaro Limited. All rights reserved.
  */
+#include <linux/coresight.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/of.h>
+#include <linux/property.h>
+#include <linux/slab.h>
 
 #include <dt-bindings/arm/coresight-cti-dt.h>
-#include <linux/of.h>
 
 #include "coresight-cti.h"
+#include "coresight-priv.h"
 
 /* Number of CTI signals in the v8 architecturally defined connection */
 #define NR_V8PE_IN_SIGS		2
diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
index 1f8fb7c15e80..bed460541f15 100644
--- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
@@ -4,7 +4,14 @@ 
  * Author: Mike Leach <mike.leach@linaro.org>
  */
 
+#include <linux/atomic.h>
 #include <linux/coresight.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/sysfs.h>
 
 #include "coresight-cti.h"
 
diff --git a/drivers/hwtracing/coresight/coresight-cti.h b/drivers/hwtracing/coresight/coresight-cti.h
index 004df3ab9dd0..d80123b905a8 100644
--- a/drivers/hwtracing/coresight/coresight-cti.h
+++ b/drivers/hwtracing/coresight/coresight-cti.h
@@ -7,8 +7,10 @@ 
 #ifndef _CORESIGHT_CORESIGHT_CTI_H
 #define _CORESIGHT_CORESIGHT_CTI_H
 
-#include <asm/local.h>
+#include <linux/list.h>
 #include <linux/spinlock.h>
+#include <linux/types.h>
+
 #include "coresight-priv.h"
 
 /*
@@ -52,6 +54,12 @@ 
  */
 #define CTIINOUTEN_MAX		32
 
+struct attribute;
+struct attribute_group;
+struct coresight_device;
+struct device;
+struct fwnode_handle;
+
 /**
  * Group of related trigger signals
  *