Skip to contentSkip to conversation

iommu/dma: 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 iommu/dma: 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/iommu/dma-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dma-iommu.c +1 -1
index 5141d49a046b..2dcbc8f1d0c0 100644
@@ -1153,7 +1153,7 @@ void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size)
 	if (domain->type == IOMMU_DOMAIN_DMA) {
 		if (iommu_dma_init_domain(domain, dma_base, size, dev))
 			goto out_err;
-		dev->dma_ops = &iommu_dma_ops;
+		set_dma_ops(dev, &iommu_dma_ops);
 	}
 
 	return;
Signature · 6 lines
2.28.0

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
#1 lore raw
Quoted 3 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.

I as actually planning on killing off set_dma_ops (and get_dma_ops) for the 5.10 merge window. The rationale is that code that sets or gets DMA ops per definition is deeply dependent on not just DMA support, but also on DMA ops which have their own options as of 5.9. Additional that WIP series removes the dma_map_ops definition from dma-mapping.h into a private header only used in the few places that do have a business messing with DMA ops.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu