Skip to contentSkip to conversation

xen/iommu: smmu: Silence clang in arm_smmu_device_dt_probe()

PATCH In review Julien Grall 2 participants 3 messages Apr 2, 2021 – Apr 13, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen/iommu: smmu: Silence clang in arm_smmu_device_dt_probe()

From: Julien Grall <[email protected]>

Clang 11 will throw the following error:

smmu.c:2284:18: error: cast to smaller integer type 'enum arm_smmu_arch_version' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]

        smmu->version = (enum arm_smmu_arch_version)of_id->data;
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The error can be prevented by initially casting to (uintptr_t) and then enum.

---

Changes in v2:
- Cast to (uintptr_t) rather than introduce separate pointer (requested by Andrew).

Only build tested

---
 xen/drivers/passthrough/arm/smmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/arm/smmu.c +1 -1
index 20ac672e91b6..fab7be8b48bb 100644
@@ -2382,7 +2382,7 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
 	smmu->dev = dev;
 
 	of_id = of_match_node(arm_smmu_of_match, dev->of_node);
-	smmu->version = (enum arm_smmu_arch_version)of_id->data;
+	smmu->version = (enum arm_smmu_arch_version)(uintptr_t)of_id->data;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	smmu->base = devm_ioremap_resource(dev, res);
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#1 lore raw
Quoted 4 lines · Julien Grall

From: Julien Grall <[email protected]>

Clang 11 will throw the following error:

Quoted 8 lines

smmu.c:2284:18: error: cast to smaller integer type 'enum arm_smmu_arch_version' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]

        smmu->version = (enum arm_smmu_arch_version)of_id->data;
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The error can be prevented by initially casting to (uintptr_t) and then enum.

Quoted 27 lines

---

Changes in v2:
- Cast to (uintptr_t) rather than introduce separate pointer (requested by Andrew).

Only build tested

---
 xen/drivers/passthrough/arm/smmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/arm/smmu.c +1 -1
index 20ac672e91b6..fab7be8b48bb 100644
@@ -2382,7 +2382,7 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
 	smmu->dev = dev;
 
 	of_id = of_match_node(arm_smmu_of_match, dev->of_node);
-	smmu->version = (enum arm_smmu_arch_version)of_id->data;
+	smmu->version = (enum arm_smmu_arch_version)(uintptr_t)of_id->data;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	smmu->base = devm_ioremap_resource(dev, res);
Signature · 1 line
2.17.1
#2 lore raw

Hi Stefano,

Quoted 9 lines · Stefano Stabellini
Quoted 8 lines · Julien Grall

From: Julien Grall <[email protected]>

Clang 11 will throw the following error:

smmu.c:2284:18: error: cast to smaller integer type 'enum arm_smmu_arch_version' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]

         smmu->version = (enum arm_smmu_arch_version)of_id->data;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
Quoted 4 lines

The error can be prevented by initially casting to (uintptr_t) and then enum.

Thanks! I have committed the patch.

Cheers,

Signature · 1 line
Julien Grall