]> www.infradead.org Git - users/hch/block.git/commitdiff
dma-mapping: initialize IOVA state struct
authorLeon Romanovsky <leonro@nvidia.com>
Tue, 16 Jul 2024 11:32:34 +0000 (14:32 +0300)
committerLeon Romanovsky <leon@kernel.org>
Thu, 3 Oct 2024 16:05:52 +0000 (19:05 +0300)
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@nvidia.com>
include/linux/dma-mapping.h

index 1524da363734af676054d68698c7bb10373c8f4f..d83e02f5f68a456674c33b546bbbe21158a8f63f 100644 (file)
 
 #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,