[PATCH] PM / devfreq: exynos-ppmu: fix clang -Wvoid-pointer-to-enum-cast warning

Justin Stitt justinstitt at google.com
Wed Aug 16 13:19:06 PDT 2023


When building with clang 18 I see the following warning:
|       drivers/devfreq/event/exynos-ppmu.c:530:21: warning: cast to smaller
|       integer type 'enum exynos_ppmu_type' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|         530 |       info->ppmu_type = (enum exynos_ppmu_type)of_id->data;

This is due to the fact that `of_id->data` is a void* while
`enum exynos_ppmu_type` has the size of an int.

Cast `of_id->data` to a uintptr_t to silence the above warning for clang
builds using W=1

Link: https://github.com/ClangBuiltLinux/linux/issues/1910
Reported-by: Nathan Chancellor <nathan at kernel.org>
Signed-off-by: Justin Stitt <justinstitt at google.com>
---
 drivers/devfreq/event/exynos-ppmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/devfreq/event/exynos-ppmu.c b/drivers/devfreq/event/exynos-ppmu.c
index 896a6cc93b00..f798e1d6994d 100644
--- a/drivers/devfreq/event/exynos-ppmu.c
+++ b/drivers/devfreq/event/exynos-ppmu.c
@@ -527,7 +527,7 @@ static int of_get_devfreq_events(struct device_node *np,
 
 	of_id = of_match_device(exynos_ppmu_id_match, dev);
 	if (of_id)
-		info->ppmu_type = (enum exynos_ppmu_type)of_id->data;
+		info->ppmu_type = (uintptr_t)of_id->data;
 	else {
 		of_node_put(events_np);
 		return -EINVAL;

---
base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230816-void-drivers-devfreq-event-exynos-ppmu-64ad102497f2

Best regards,
--
Justin Stitt <justinstitt at google.com>




More information about the linux-arm-kernel mailing list