[RFC v2 04/21] dma-mapping: initialize IOVA state struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Leon Romanovsky <leonro@xxxxxxxxxx>

Allow callers to properly initialize the IOVA state struct by providing
a new function to do so. This will make sure that even users who doesn't
zero their allocated memory will have a valid IOVA state struct.

Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
---
 include/linux/dma-mapping.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index f693aafe221f..285075873077 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -76,6 +76,20 @@
 
 #define DMA_BIT_MASK(n)	(((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
 
+struct dma_iova_state {
+	struct device *dev;
+	enum dma_data_direction dir;
+};
+
+static inline void dma_init_iova_state(struct dma_iova_state *state,
+				       struct device *dev,
+				       enum dma_data_direction dir)
+{
+	memset(state, 0, sizeof(*state));
+	state->dev = dev;
+	state->dir = dir;
+}
+
 #ifdef CONFIG_DMA_API_DEBUG
 void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
 void debug_dma_map_single(struct device *dev, const void *addr,
-- 
2.46.0





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux