Skip to content

Commit a50c7de

Browse files
nxpfranklibjorn-helgaas
authored andcommitted
misc: pci_endpoint_test: Refactor dma_set_mask_and_coherent() logic
dma_set_mask_and_coherent() should never fail when the mask is >= 32bit, unless the architecture has no DMA support. So no need to check for the error and also no need to set dma_set_mask_and_coherent(32) as a fallback. Even if dma_set_mask_and_coherent(48) fails due to the lack of DMA support (theoretically), then dma_set_mask_and_coherent(32) will also fail for the same reason. So the fallback doesn't make sense. Simplify the code by setting the streaming and coherent DMA mask to 48 bits. Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Frank Li <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Niklas Cassel <[email protected]>
1 parent 2a35703 commit a50c7de

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

drivers/misc/pci_endpoint_test.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,11 +857,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
857857
init_completion(&test->irq_raised);
858858
mutex_init(&test->mutex);
859859

860-
if ((dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48)) != 0) &&
861-
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) {
862-
dev_err(dev, "Cannot set DMA mask\n");
863-
return -EINVAL;
864-
}
860+
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48));
865861

866862
err = pci_enable_device(pdev);
867863
if (err) {

0 commit comments

Comments
 (0)