xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] xen/iommu: smmu: Silence clang in arm_smmu_device_dt_probe()
@ 2021-04-02 15:51 Julien Grall
  2021-04-06 22:02 ` Stefano Stabellini
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Grall @ 2021-04-02 15:51 UTC (permalink / raw)
  To: xen-devel
  Cc: bertrand.marquis, Julien Grall, Stefano Stabellini, Julien Grall,
	Volodymyr Babchuk

From: Julien Grall <jgrall@amazon.com>

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.

Signed-off-by: Julien Grall <jgrall@amazon.com>

---

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(-)

diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c
index 20ac672e91b6..fab7be8b48bb 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -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);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] xen/iommu: smmu: Silence clang in arm_smmu_device_dt_probe()
  2021-04-02 15:51 [PATCH v2] xen/iommu: smmu: Silence clang in arm_smmu_device_dt_probe() Julien Grall
@ 2021-04-06 22:02 ` Stefano Stabellini
  2021-04-13 17:58   ` Julien Grall
  0 siblings, 1 reply; 3+ messages in thread
From: Stefano Stabellini @ 2021-04-06 22:02 UTC (permalink / raw)
  To: Julien Grall
  Cc: xen-devel, bertrand.marquis, Julien Grall, Stefano Stabellini,
	Volodymyr Babchuk

On Fri, 2 Apr 2021, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
> 
> 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.
> 
> Signed-off-by: Julien Grall <jgrall@amazon.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> 
> 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(-)
> 
> diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c
> index 20ac672e91b6..fab7be8b48bb 100644
> --- a/xen/drivers/passthrough/arm/smmu.c
> +++ b/xen/drivers/passthrough/arm/smmu.c
> @@ -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);
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] xen/iommu: smmu: Silence clang in arm_smmu_device_dt_probe()
  2021-04-06 22:02 ` Stefano Stabellini
@ 2021-04-13 17:58   ` Julien Grall
  0 siblings, 0 replies; 3+ messages in thread
From: Julien Grall @ 2021-04-13 17:58 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: xen-devel, bertrand.marquis, Julien Grall, Volodymyr Babchuk

Hi Stefano,

On 06/04/2021 23:02, Stefano Stabellini wrote:
> On Fri, 2 Apr 2021, Julien Grall wrote:
>> From: Julien Grall <jgrall@amazon.com>
>>
>> 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.
>>
>> Signed-off-by: Julien Grall <jgrall@amazon.com>
> 
> Acked-by: Stefano Stabellini <sstabellini@kernel.org>

Thanks! I have committed the patch.

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-13 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-02 15:51 [PATCH v2] xen/iommu: smmu: Silence clang in arm_smmu_device_dt_probe() Julien Grall
2021-04-06 22:02 ` Stefano Stabellini
2021-04-13 17:58   ` Julien Grall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).