Commit a5fb217f authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarLeon Romanovsky <leon@kernel.org>
parent f45cfab2
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -841,22 +841,25 @@ 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)))
	if (use_dma_iommu(dev)) {
		if (WARN_ON(ops))
			return false;

	if (use_dma_iommu(dev))
		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) {
		if (!ops->dma_supported)
		return 1;
			return true;
		return ops->dma_supported(dev, mask);
	}

	return dma_direct_supported(dev, mask);
}

bool dma_pci_p2pdma_supported(struct device *dev)
{
	const struct dma_map_ops *ops = get_dma_ops(dev);