[PATCH] drm: pl111: fix clang -Wvoid-pointer-to-enum-cast warning
From: Justin Stitt
Date: Wed Aug 16 2023 - 16:06:34 EST
When building with clang 18 I see the following warnings:
|1. drivers/gpu/drm/pl111/pl111_versatile.c:487:24: warning: cast to smaller
| integer type 'enum versatile_clcd' from 'const void *' [-Wvoid-pointer-to-enum-cast]
| 487 | versatile_clcd_type = (enum versatile_clcd)clcd_id->data;
-
|2. drivers/gpu/drm/pl111/pl111_versatile.c:507:26: warning: cast to smaller
| integer type 'enum versatile_clcd' from 'const void *' [-Wvoid-pointer-to-enum-cast]
| 507 | versatile_clcd_type = (enum versatile_clcd)clcd_id->data;
This is due to the fact that `clcd_id->data` is a void* while `enum versatile_clcd`
has the size of an int.
Cast `clcd_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@xxxxxxxxxx>
Signed-off-by: Justin Stitt <justinstitt@xxxxxxxxxx>
---
drivers/gpu/drm/pl111/pl111_versatile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/pl111/pl111_versatile.c b/drivers/gpu/drm/pl111/pl111_versatile.c
index 00c3ebd32359..d6fd9e51377e 100644
--- a/drivers/gpu/drm/pl111/pl111_versatile.c
+++ b/drivers/gpu/drm/pl111/pl111_versatile.c
@@ -484,7 +484,7 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv)
return 0;
}
- versatile_clcd_type = (enum versatile_clcd)clcd_id->data;
+ versatile_clcd_type = (enum versatile_clcd)(uintptr_t)clcd_id->data;
/* Versatile Express special handling */
if (versatile_clcd_type == VEXPRESS_CLCD_V2M) {
@@ -504,7 +504,7 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv)
np = of_find_matching_node_and_match(NULL, impd1_clcd_of_match,
&clcd_id);
if (np)
- versatile_clcd_type = (enum versatile_clcd)clcd_id->data;
+ versatile_clcd_type = (enum versatile_clcd)(uintptr_t)clcd_id->data;
}
map = syscon_node_to_regmap(np);
---
base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230816-void-drivers-gpu-drm-pl111-pl111_versatile-43b109cfa7ad
Best regards,
--
Justin Stitt <justinstitt@xxxxxxxxxx>