Skip to contentSkip to conversation

PCI/P2PDMA: Use DMA ops setter instead of direct assignment

PATCH In review Andy Shevchenko 2 participants 2 messages Aug 28, 2020 – Aug 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/P2PDMA: Use DMA ops setter instead of direct assignment

Use DMA ops setter instead of direct assignment. Even we know that this module doesn't perform access to the dma_ops member of struct device, it's better to use setter to avoid potential problems in the future.

---
 drivers/pci/p2pdma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/p2pdma.c +2 -2
index 9d53c16b7329..2176223f972e 100644
@@ -557,7 +557,7 @@ int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients,
 
 	for (i = 0; i < num_clients; i++) {
 #ifdef CONFIG_DMA_VIRT_OPS
-		if (clients[i]->dma_ops == &dma_virt_ops) {
+		if (get_dma_ops(clients[i]) == &dma_virt_ops) {
 			if (verbose)
 				dev_warn(clients[i],
 					 "cannot be used for peer-to-peer DMA because the driver makes use of dma_virt_ops\n");
@@ -844,7 +844,7 @@ static int __pci_p2pdma_map_sg(struct pci_p2pdma_pagemap *p2p_pgmap,
 	 * by the check in pci_p2pdma_distance_many()
 	 */
 #ifdef CONFIG_DMA_VIRT_OPS
-	if (WARN_ON_ONCE(dev->dma_ops == &dma_virt_ops))
+	if (WARN_ON_ONCE(get_dma_ops(dev) == &dma_virt_ops))
 		return 0;
 #endif
 
Signature · 1 line
2.28.0
#1 lore raw
Quoted 5 lines · Andy Shevchenko

Use DMA ops setter instead of direct assignment. Even we know that this module doesn't perform access to the dma_ops member of struct device, it's better to use setter to avoid potential problems in the future.

As mentioned in reply to the intel-iommu patch: I plan to remove these accessors soon.