diff options
author | Christoph Hellwig <hch@lst.de> | 2024-09-12 10:21:18 +0300 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2024-09-12 17:28:00 +0300 |
commit | a5fb217f13f74b2af2ab366ffad522bae717f93c (patch) | |
tree | 87ceb715cd0478b452c5f95db4f3dcd2969c470c /kernel/dma/mapping.c | |
parent | f45cfab28fcd5ac67a38750b6c68316b26d35ac8 (diff) | |
download | linux-a5fb217f13f74b2af2ab366ffad522bae717f93c.tar.xz |
dma-mapping: reflow dma_supported
dma_supported has become too much spaghetti for my taste. Reflow it to
remove the duplicate use_dma_iommu condition and make the main path more
obvious.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'kernel/dma/mapping.c')
-rw-r--r-- | kernel/dma/mapping.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c index 022d670f8cad..b839683da0ba 100644 --- a/kernel/dma/mapping.c +++ b/kernel/dma/mapping.c @@ -841,20 +841,23 @@ static int dma_supported(struct device *dev, u64 mask) { const struct dma_map_ops *ops = get_dma_ops(dev); - if (WARN_ON(ops && use_dma_iommu(dev))) - return false; - - if (use_dma_iommu(dev)) + if (use_dma_iommu(dev)) { + if (WARN_ON(ops)) + return false; return true; + } + /* - * ->dma_supported sets the bypass flag, so we must always call - * into the method here unless the device is truly direct mapped. + * ->dma_supported sets and clears the bypass flag, so ignore it here + * and always call into the method if there is one. */ - if (!ops) - return dma_direct_supported(dev, mask); - if (!ops->dma_supported) - return 1; - return ops->dma_supported(dev, mask); + if (ops) { + if (!ops->dma_supported) + return true; + return ops->dma_supported(dev, mask); + } + + return dma_direct_supported(dev, mask); } bool dma_pci_p2pdma_supported(struct device *dev) |