xref: /linux/rust/helpers/dma.c (revision 5d7f3375cd574fc83f0cd30839b21455c0e79ae2)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/dma-mapping.h>
4 
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 
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 
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 
26 __rust_helper int rust_helper_dma_set_mask(struct device *dev, u64 mask)
27 {
28 	return dma_set_mask(dev, mask);
29 }
30 
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 
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 
42 __rust_helper size_t rust_helper_dma_max_mapping_size(struct device *dev)
43 {
44 	return dma_max_mapping_size(dev);
45 }
46 
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 
53 __rust_helper unsigned int rust_helper_dma_get_max_seg_size(struct device *dev)
54 {
55 	return dma_get_max_seg_size(dev);
56 }
57