Minor sparse and style fixes
v2 cover Minor sparse and style fixes
I got a report that kcalloc() didn't exist in coresight-cti-platform.c on arm builds and that looked like we didn't include very many headers to get prototypes of functions like kcalloc(), etc. The first patch fixes this problem by including the headers and then the rest of these patches fix minor sparse and style issues that I saw while looking through the coresight directory.
Pathes based on linux-next.
Changes from v1:
* Dropped patches that were applied
* Added more includes to cti.c and priv.h
Stephen Boyd (2):
coresight: Include required headers in C files
coresight: Avoid casting void pointers
.../hwtracing/coresight/coresight-cti-platform.c | 8 +++++++- drivers/hwtracing/coresight/coresight-cti-sysfs.c | 7 +++++++ drivers/hwtracing/coresight/coresight-cti.c | 13 +++++++++++++ drivers/hwtracing/coresight/coresight-cti.h | 8 +++++++- drivers/hwtracing/coresight/coresight-priv.h | 9 ++++++--- 5 files changed, 40 insertions(+), 5 deletions(-)
base-commit: 62eb0c79662ccb3c09c3724d0d4df2501cb8277c
Signature · 1 line
Sent by a computer, using git, on the internet
PATCH v2 1/2 coresight: Include required headers in C files
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.
--- .../hwtracing/coresight/coresight-cti-platform.c | 8 +++++++- drivers/hwtracing/coresight/coresight-cti-sysfs.c | 7 +++++++ drivers/hwtracing/coresight/coresight-cti.c | 13 +++++++++++++ drivers/hwtracing/coresight/coresight-cti.h | 8 +++++++- 4 files changed, 34 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-cti-platform.c +7 -1
@@ -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
drivers/hwtracing/coresight/coresight-cti-sysfs.c +7 -0
@@ -4,7 +4,14 @@* Author: Mike Leach <[email protected]> */ +#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"
drivers/hwtracing/coresight/coresight-cti.c +13 -0
@@ -4,7 +4,20 @@* Author: Mike Leach <[email protected]> */ +#include <linux/amba/bus.h> +#include <linux/atomic.h> +#include <linux/bits.h> +#include <linux/coresight.h> +#include <linux/device.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/list.h> +#include <linux/mutex.h> +#include <linux/pm_runtime.h> #include <linux/property.h> +#include <linux/spinlock.h> + +#include "coresight-priv.h" #include "coresight-cti.h" /**
drivers/hwtracing/coresight/coresight-cti.h +7 -1
@@ -7,8 +7,14 @@#ifndef _CORESIGHT_CORESIGHT_CTI_H#define _CORESIGHT_CORESIGHT_CTI_H -#include <asm/local.h> +#include <linux/coresight.h> +#include <linux/device.h> +#include <linux/fwnode.h> +#include <linux/list.h> #include <linux/spinlock.h> +#include <linux/sysfs.h> +#include <linux/types.h> +#include "coresight-priv.h" /*
Signature · 1 line
Sent by a computer, using git, on the internet
Re: [PATCH v2 1/2] coresight: Include required headers in C files
Hi Stephen,
Quoted 45 lines · Stephen Boyd
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 <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Signed-off-by Stephen Boyd <[email protected]>--- .../hwtracing/coresight/coresight-cti-platform.c | 8 +++++++- drivers/hwtracing/coresight/coresight-cti-sysfs.c | 7 +++++++ drivers/hwtracing/coresight/coresight-cti.c | 13 +++++++++++++ drivers/hwtracing/coresight/coresight-cti.h | 8 +++++++- 4 files changed, 34 insertions(+), 2 deletions(-)drivers/hwtracing/coresight/coresight-cti-platform.c +7
-1@@ -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 2drivers/hwtracing/coresight/coresight-cti-sysfs.c +0
-0@@ -4,7 +4,14 @@* Author: Mike Leach <[email protected]>
drivers/hwtracing/coresight/coresight-cti-sysfs.c line 14
Quoted 10 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c +7
-0*/ +#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>
What is io.h and slab.h used for in coresight-cti-sysfs.c ?
Quoted 8 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c +0
-0#include "coresight-cti.h" drivers/hwtracing/coresight/coresight-cti.c +0
-0
drivers/hwtracing/coresight/coresight-cti.c line 12
Quoted 9 lines
drivers/hwtracing/coresight/coresight-cti.c +6
-0@@ -4,7 +4,20 @@* Author: Mike Leach <[email protected]> */ +#include <linux/amba/bus.h> +#include <linux/atomic.h> +#include <linux/bits.h> +#include <linux/coresight.h> +#include <linux/device.h> +#include <linux/io.h>
Same comment as above.
No need to send another version if these are mistakes - just let me know and I'll do the adjustment.
Thanks,
Mathieu
Quoted 34 lines
drivers/hwtracing/coresight/coresight-cti.c +7
-0+#include <linux/kernel.h> +#include <linux/list.h> +#include <linux/mutex.h> +#include <linux/pm_runtime.h> #include <linux/property.h> +#include <linux/spinlock.h> + +#include "coresight-priv.h" #include "coresight-cti.h" /** drivers/hwtracing/coresight/coresight-cti.h +7
-1@@ -7,8 +7,14 @@#ifndef _CORESIGHT_CORESIGHT_CTI_H#define _CORESIGHT_CORESIGHT_CTI_H -#include <asm/local.h> +#include <linux/coresight.h> +#include <linux/device.h> +#include <linux/fwnode.h> +#include <linux/list.h> #include <linux/spinlock.h> +#include <linux/sysfs.h> +#include <linux/types.h> +#include "coresight-priv.h" /* Signature · 1 line
Sent by a computer, using git, on the internet
Re: [PATCH v2 1/2] coresight: Include required headers in C files
Quoting Mathieu Poirier (2020-04-29 11:08:18)
Quoted 11 lines
Hi Stephen,
Quoted 8 lines · Stephen Boyd
drivers/hwtracing/coresight/coresight-cti-sysfs.c +0
-0@@ -4,7 +4,14 @@* Author: Mike Leach <[email protected]> */
Quoted 10 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c line 14
Quoted 8 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c +7
-0+#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> What is
io.handslab.hused for incoresight-cti-sysfs.c?
io.h is for readl_relaxed() usage in this file. I added slab for the devm_kcalloc() but it doesn't look necessary given that device.h is where that is defined, not slab.h. Thanks for catching that!
Quoted 21 lines
Quoted 9 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c +0
-0#include "coresight-cti.h" drivers/hwtracing/coresight/coresight-cti.c +0
-0drivers/hwtracing/coresight/coresight-cti.c line 12
Quoted 9 lines
drivers/hwtracing/coresight/coresight-cti.c +6
-0@@ -4,7 +4,20 @@* Author: Mike Leach <[email protected]> */ +#include <linux/amba/bus.h> +#include <linux/atomic.h> +#include <linux/bits.h> +#include <linux/coresight.h> +#include <linux/device.h> +#include <linux/io.h> Same comment as above.
Quoted 3 lines
No need to send another version if these are mistakes - just let me know and I'll do the adjustment.
Same here, io.h is for the readl_relaxed() and writel_relaxed() calls.
So please remove slab.h from the two files (but not the other one) when applying. Thanks.
Re: [PATCH v2 1/2] coresight: Include required headers in C files
Quoted 49 lines · Stephen Boyd
Quoting Mathieu Poirier (2020-04-29 11:08:18)
Quoted 11 lines
Hi Stephen,
Quoted 8 lines · Stephen Boyd
drivers/hwtracing/coresight/coresight-cti-sysfs.c +0
-0@@ -4,7 +4,14 @@* Author: Mike Leach <[email protected]> */ Quoted 10 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c line 14
Quoted 8 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c +7
-0+#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> What is
io.handslab.hused for incoresight-cti-sysfs.c?
io.his forreadl_relaxed()usage in this file. I added slab for thedevm_kcalloc()but it doesn't look necessary given thatdevice.his where that is defined, notslab.h. Thanks for catching that!Quoted 21 lines
Quoted 9 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c +0
-0#include "coresight-cti.h" drivers/hwtracing/coresight/coresight-cti.c +0
-0drivers/hwtracing/coresight/coresight-cti.c line 12
Quoted 9 lines
drivers/hwtracing/coresight/coresight-cti.c +6
-0@@ -4,7 +4,20 @@* Author: Mike Leach <[email protected]> */ +#include <linux/amba/bus.h> +#include <linux/atomic.h> +#include <linux/bits.h> +#include <linux/coresight.h> +#include <linux/device.h> +#include <linux/io.h> Same comment as above.
Quoted 5 lines
Quoted 3 lines
No need to send another version if these are mistakes - just let me know and I'll do the adjustment.
Same here,
io.his for thereadl_relaxed()andwritel_relaxed()calls.
I just noticed the "asm/io.h" at the top of linux/io.h - ok for that one.
Quoted 3 lines
So please remove
slab.hfrom the two files (but not the other one) when applying. Thanks.
You got it.
Re: [PATCH v2 1/2] coresight: Include required headers in C files
Quoting Mathieu Poirier (2020-04-29 12:24:42)
Quoted 6 lines
Quoted 4 lines
So please remove
slab.hfrom the two files (but not the other one) when applying. Thanks.You got it.
I looked in next but coresight-cti-platform.c is missing slab.h even though I included it in my patch. There's a bare kcalloc() call in that file, so slab.h is required.
Re: [PATCH v2 1/2] coresight: Include required headers in C files
Quoted 11 lines · Stephen Boyd
Quoting Mathieu Poirier (2020-04-29 12:24:42)
Quoted 6 lines
Quoted 4 lines
So please remove
slab.hfrom the two files (but not the other one) when applying. Thanks.You got it.
I looked in next but
coresight-cti-platform.cis missingslab.heven though I included it in my patch. There's a barekcalloc()call in that file, soslab.his required.
I know what happened. The above comment mentions removing slab.h in two and leaving the "other" one in place. But looking at the original file only coresight-cti-platform.c and coresight-cti-sysfs.c had an slab.h.
I have made the correction.
PATCH v2 2/2 coresight: Avoid casting void pointers
In reply to Stephen BoydWe don't need to cast void pointers, such as the amba_id data. Assign to a local variable to make the code prettier and also return NULL instead of 0 to make sparse happy.
---
Thanks Joe for finding my thinko!
drivers/hwtracing/coresight/coresight-priv.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-priv.h +6 -3
@@ -215,9 +215,12 @@ cti_remove_assoc_from_csdev(struct coresight_device *csdev) {}/* extract the data value from a UCI structure given amba_id pointer. */ static inline void *coresight_get_uci_data (const struct amba_id *id) { -if (id->data) -return ((struct amba_cs_uci_id *)(id->data))->data; -return 0 ; +struct amba_cs_uci_id *uci_id = id->data; + +if (!uci_id) +return NULL ; + +return uci_id->data; } void coresight_release_platform_data(struct coresight_device *csdev,
Signature · 1 line
Sent by a computer, using git, on the internet
Re: [PATCH v2 2/2] coresight: Avoid casting void pointers
Reviewed-by [email protected]
Quoted 39 lines · Stephen Boyd
We don't need to cast void pointers, such as the
amba_iddata. Assign to a local variable to make the code prettier and also return NULL instead of 0 to make sparse happy.Cc Suzuki K Poulose <[email protected]>Cc Mike Leach <[email protected]>Reviewed-by Joe Perches <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
Thanks Joe for finding my thinko!
drivers/hwtracing/coresight/coresight-priv.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/hwtracing/coresight/coresight-priv.h +6
-4@@ -215,9 +215,12 @@ cti_remove_assoc_from_csdev(struct coresight_device *csdev) {}/* extract the data value from a UCI structure given amba_id pointer. */ static inline void *coresight_get_uci_data (const struct amba_id *id) { -if (id->data) -return ((struct amba_cs_uci_id *)(id->data))->data; -return 0 ; +struct amba_cs_uci_id *uci_id = id->data; + +if (!uci_id) +return NULL ; + +return uci_id->data; } void coresight_release_platform_data(struct coresight_device *csdev, --Sent by a computer, using git, on the internet
Signature · 3 lines
Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK