media: pt3: Use dma_set_mask_and_coherent() and simplify code
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 1 Jan 2022 21:28:51 +0000 (22:28 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 7 Dec 2022 16:58:46 +0000 (17:58 +0100)
Use dma_set_mask_and_coherent() instead of unrolling it with some
dma_set_mask()+dma_set_coherent_mask().

Moreover, as stated in [1], dma_set_mask() with a 64-bit mask will never
fail if dev->dma_mask is non-NULL.
So, if it fails, the 32 bits case will also fail for the same reason.

Simplify code and remove some dead code accordingly.

[1]: https://lkml.org/lkml/2021/6/7/398

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Akihiro Tsukada <tskd08@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/pci/pt3/pt3.c

index f6deac85962e4add5b4a3990314dc6ef3e2b59d9..246f73b8a9e794eab4dfd62b275ebf794e0a34d9 100644 (file)
@@ -707,18 +707,10 @@ static int pt3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (ret < 0)
                return ret;
 
-       ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
-       if (ret == 0)
-               dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
-       else {
-               ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
-               if (ret == 0)
-                       dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
-               else {
-                       dev_err(&pdev->dev, "Failed to set DMA mask\n");
-                       return ret;
-               }
-               dev_info(&pdev->dev, "Use 32bit DMA\n");
+       ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+       if (ret) {
+               dev_err(&pdev->dev, "Failed to set DMA mask\n");
+               return ret;
        }
 
        pt3 = devm_kzalloc(&pdev->dev, sizeof(*pt3), GFP_KERNEL);