summaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorFrank Li <Frank.Li@nxp.com>2024-05-02 21:59:03 +0200
committerBjorn Helgaas <bhelgaas@google.com>2024-07-10 00:57:59 +0200
commita50c7de0607c65af588900b1236d88faf561374e (patch)
treed5b61cd449706f3d39917febee5e95fc401c2464 /drivers/misc
parentmisc: pci_endpoint_test: Use memcpy_toio()/memcpy_fromio() for BAR tests (diff)
downloadlinux-a50c7de0607c65af588900b1236d88faf561374e.tar.xz
linux-a50c7de0607c65af588900b1236d88faf561374e.zip
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/20240502195903.3191049-1-Frank.Li@nxp.com Signed-off-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Krzysztof WilczyƄski <kwilczynski@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Reviewed-by: Niklas Cassel <cassel@kernel.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/pci_endpoint_test.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 2e0a66e88094..0ffc8e02b863 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -857,11 +857,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
init_completion(&test->irq_raised);
mutex_init(&test->mutex);
- if ((dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48)) != 0) &&
- dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) {
- dev_err(dev, "Cannot set DMA mask\n");
- return -EINVAL;
- }
+ dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48));
err = pci_enable_device(pdev);
if (err) {