dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: owl-dma: fix clang -Wvoid-pointer-to-enum-cast warning
@ 2023-08-16 20:12 Justin Stitt
  2023-08-17  6:56 ` Manivannan Sadhasivam
  2023-08-21 13:51 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Justin Stitt @ 2023-08-16 20:12 UTC (permalink / raw)
  To: Vinod Koul, Andreas Färber, Manivannan Sadhasivam,
	Nathan Chancellor, Nick Desaulniers, Tom Rix
  Cc: dmaengine, linux-arm-kernel, linux-actions, linux-kernel, llvm,
	Justin Stitt

When building with clang 18 I see the following warning:
|       drivers/dma/owl-dma.c:1119:14: warning: cast to smaller integer type
|       'enum owl_dma_id' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|        1119 | od->devid = (enum owl_dma_id)of_device_get_match_data(&pdev->dev);

This is due to the fact that `of_device_get_match_data()` returns a
void* while `enum owl_dma_id` has the size of an int.

Cast result of `of_device_get_match_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@kernel.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
---
 drivers/dma/owl-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/owl-dma.c b/drivers/dma/owl-dma.c
index b6e0ac8314e5..f340a04579f4 100644
--- a/drivers/dma/owl-dma.c
+++ b/drivers/dma/owl-dma.c
@@ -1116,7 +1116,7 @@ static int owl_dma_probe(struct platform_device *pdev)
 	dev_info(&pdev->dev, "dma-channels %d, dma-requests %d\n",
 		 nr_channels, nr_requests);
 
-	od->devid = (enum owl_dma_id)of_device_get_match_data(&pdev->dev);
+	od->devid = (uintptr_t)of_device_get_match_data(&pdev->dev);
 
 	od->nr_pchans = nr_channels;
 	od->nr_vchans = nr_requests;

---
base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230816-void-drivers-dma-owl-dma-41b95a098275

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


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

* Re: [PATCH] dmaengine: owl-dma: fix clang -Wvoid-pointer-to-enum-cast warning
  2023-08-16 20:12 [PATCH] dmaengine: owl-dma: fix clang -Wvoid-pointer-to-enum-cast warning Justin Stitt
@ 2023-08-17  6:56 ` Manivannan Sadhasivam
  2023-08-21 13:51 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2023-08-17  6:56 UTC (permalink / raw)
  To: Justin Stitt
  Cc: Vinod Koul, Andreas Färber, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, dmaengine, linux-arm-kernel,
	linux-actions, linux-kernel, llvm

On Wed, Aug 16, 2023 at 08:12:50PM +0000, Justin Stitt wrote:
> When building with clang 18 I see the following warning:
> |       drivers/dma/owl-dma.c:1119:14: warning: cast to smaller integer type
> |       'enum owl_dma_id' from 'const void *' [-Wvoid-pointer-to-enum-cast]
> |        1119 | od->devid = (enum owl_dma_id)of_device_get_match_data(&pdev->dev);
> 
> This is due to the fact that `of_device_get_match_data()` returns a
> void* while `enum owl_dma_id` has the size of an int.
> 
> Cast result of `of_device_get_match_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@kernel.org>
> Signed-off-by: Justin Stitt <justinstitt@google.com>

Acked-by: Manivannan Sadhasivam <mani@kernel.org>

- Mani

> ---
>  drivers/dma/owl-dma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/owl-dma.c b/drivers/dma/owl-dma.c
> index b6e0ac8314e5..f340a04579f4 100644
> --- a/drivers/dma/owl-dma.c
> +++ b/drivers/dma/owl-dma.c
> @@ -1116,7 +1116,7 @@ static int owl_dma_probe(struct platform_device *pdev)
>  	dev_info(&pdev->dev, "dma-channels %d, dma-requests %d\n",
>  		 nr_channels, nr_requests);
>  
> -	od->devid = (enum owl_dma_id)of_device_get_match_data(&pdev->dev);
> +	od->devid = (uintptr_t)of_device_get_match_data(&pdev->dev);
>  
>  	od->nr_pchans = nr_channels;
>  	od->nr_vchans = nr_requests;
> 
> ---
> base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
> change-id: 20230816-void-drivers-dma-owl-dma-41b95a098275
> 
> Best regards,
> --
> Justin Stitt <justinstitt@google.com>
> 

-- 
மணிவண்ணன் சதாசிவம்

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

* Re: [PATCH] dmaengine: owl-dma: fix clang -Wvoid-pointer-to-enum-cast warning
  2023-08-16 20:12 [PATCH] dmaengine: owl-dma: fix clang -Wvoid-pointer-to-enum-cast warning Justin Stitt
  2023-08-17  6:56 ` Manivannan Sadhasivam
@ 2023-08-21 13:51 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2023-08-21 13:51 UTC (permalink / raw)
  To: Andreas Färber, Manivannan Sadhasivam, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Justin Stitt
  Cc: dmaengine, linux-arm-kernel, linux-actions, linux-kernel, llvm


On Wed, 16 Aug 2023 20:12:50 +0000, Justin Stitt wrote:
> When building with clang 18 I see the following warning:
> |       drivers/dma/owl-dma.c:1119:14: warning: cast to smaller integer type
> |       'enum owl_dma_id' from 'const void *' [-Wvoid-pointer-to-enum-cast]
> |        1119 | od->devid = (enum owl_dma_id)of_device_get_match_data(&pdev->dev);
> 
> This is due to the fact that `of_device_get_match_data()` returns a
> void* while `enum owl_dma_id` has the size of an int.
> 
> [...]

Applied, thanks!

[1/1] dmaengine: owl-dma: fix clang -Wvoid-pointer-to-enum-cast warning
      commit: 1fbda5f4c7c1c8bd51cd3bc3d2ff19176c696b74

Best regards,
-- 
~Vinod



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

end of thread, other threads:[~2023-08-21 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-16 20:12 [PATCH] dmaengine: owl-dma: fix clang -Wvoid-pointer-to-enum-cast warning Justin Stitt
2023-08-17  6:56 ` Manivannan Sadhasivam
2023-08-21 13:51 ` Vinod Koul

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