xref: /linux/rust/helpers/dma.c (revision ba23adb6533149df33b9a247f31a87227b3c86d5)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/dma-mapping.h>
4 
rust_helper_dma_alloc_attrs(struct device * dev,size_t size,dma_addr_t * dma_handle,gfp_t flag,unsigned long attrs)5 __rust_helper void *rust_helper_dma_alloc_attrs(struct device *dev, size_t size,
6 						dma_addr_t *dma_handle,
7 						gfp_t flag, unsigned long attrs)
8 {
9 	return dma_alloc_attrs(dev, size, dma_handle, flag, attrs);
10 }
11 
rust_helper_dma_free_attrs(struct device * dev,size_t size,void * cpu_addr,dma_addr_t dma_handle,unsigned long attrs)12 __rust_helper void rust_helper_dma_free_attrs(struct device *dev, size_t size,
13 					      void *cpu_addr,
14 					      dma_addr_t dma_handle,
15 					      unsigned long attrs)
16 {
17 	dma_free_attrs(dev, size, cpu_addr, dma_handle, attrs);
18 }
19 
rust_helper_dma_set_mask_and_coherent(struct device * dev,u64 mask)20 __rust_helper int rust_helper_dma_set_mask_and_coherent(struct device *dev,
21 							u64 mask)
22 {
23 	return dma_set_mask_and_coherent(dev, mask);
24 }
25 
rust_helper_dma_set_mask(struct device * dev,u64 mask)26 __rust_helper int rust_helper_dma_set_mask(struct device *dev, u64 mask)
27 {
28 	return dma_set_mask(dev, mask);
29 }
30 
rust_helper_dma_set_coherent_mask(struct device * dev,u64 mask)31 __rust_helper int rust_helper_dma_set_coherent_mask(struct device *dev, u64 mask)
32 {
33 	return dma_set_coherent_mask(dev, mask);
34 }
35 
rust_helper_dma_map_sgtable(struct device * dev,struct sg_table * sgt,enum dma_data_direction dir,unsigned long attrs)36 __rust_helper int rust_helper_dma_map_sgtable(struct device *dev, struct sg_table *sgt,
37 					      enum dma_data_direction dir, unsigned long attrs)
38 {
39 	return dma_map_sgtable(dev, sgt, dir, attrs);
40 }
41 
rust_helper_dma_max_mapping_size(struct device * dev)42 __rust_helper size_t rust_helper_dma_max_mapping_size(struct device *dev)
43 {
44 	return dma_max_mapping_size(dev);
45 }
46 
rust_helper_dma_set_max_seg_size(struct device * dev,unsigned int size)47 __rust_helper void rust_helper_dma_set_max_seg_size(struct device *dev,
48 						    unsigned int size)
49 {
50 	dma_set_max_seg_size(dev, size);
51 }
52