In [1], Christoph Hellwig has proposed to remove the wrappers in
include/linux/pci-dma-compat.h.
Some reasons why this API should be removed have been given by Julia
Lawall in [2].
A coccinelle script has been used to perform the needed transformation.
It can be found in [3].
It has been hand modified to use 'dma_set_mask_and_coherent()' instead of
'pci_set_dma_mask()/pci_set_consistent_dma_mask()' when applicable.
This is less verbose.
The explicit 'ret = -EIO;' has been removed because
'dma_set_mask_and_coherent()' returns 0 or -EIO, so its return code can be
used directly.
[1]: https://lore.kernel.org/kernel-janitors/
20200421081257.GA131897@infradead.org/
[2]: https://lore.kernel.org/kernel-janitors/alpine.DEB.2.22.394.
2007120902170.2424@hadrien/
[3]: https://lore.kernel.org/kernel-janitors/
20200716192821.321233-1-christophe.jaillet@wanadoo.fr/
Reviewed-by: Xu Yilun <yilun.xu@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
*/
#include <linux/pci.h>
+#include <linux/dma-mapping.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/module.h>
pci_set_master(pcidev);
- if (!pci_set_dma_mask(pcidev, DMA_BIT_MASK(64))) {
- ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(64));
- if (ret)
- goto disable_error_report_exit;
- } else if (!pci_set_dma_mask(pcidev, DMA_BIT_MASK(32))) {
- ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(32));
- if (ret)
- goto disable_error_report_exit;
- } else {
- ret = -EIO;
+ ret = dma_set_mask_and_coherent(&pcidev->dev, DMA_BIT_MASK(64));
+ if (ret)
+ ret = dma_set_mask_and_coherent(&pcidev->dev, DMA_BIT_MASK(32));
+ if (ret) {
dev_err(&pcidev->dev, "No suitable DMA support available.\n");
goto disable_error_report_exit;
}