dmaengine: owl-dma: fix clang -Wvoid-pointer-to-enum-cast warning
authorJustin Stitt <justinstitt@google.com>
Wed, 16 Aug 2023 20:12:50 +0000 (20:12 +0000)
committerVinod Koul <vkoul@kernel.org>
Mon, 21 Aug 2023 05:36:08 +0000 (11:06 +0530)
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>
Link: https://lore.kernel.org/r/20230816-void-drivers-dma-owl-dma-v1-1-a0a5e085e937@google.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/owl-dma.c

index e745f0c..3b7ceee 100644 (file)
@@ -1117,7 +1117,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;