xref: /linux/rust/helpers/io.c (revision 493fc33ec25294cb2e444dfa77c105aa774c83f2)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/io.h>
4 #include <linux/ioport.h>
5 
6 void __iomem *rust_helper_ioremap(phys_addr_t offset, size_t size)
7 {
8 	return ioremap(offset, size);
9 }
10 
11 void rust_helper_iounmap(void __iomem *addr)
12 {
13 	iounmap(addr);
14 }
15 
16 u8 rust_helper_readb(const void __iomem *addr)
17 {
18 	return readb(addr);
19 }
20 
21 u16 rust_helper_readw(const void __iomem *addr)
22 {
23 	return readw(addr);
24 }
25 
26 u32 rust_helper_readl(const void __iomem *addr)
27 {
28 	return readl(addr);
29 }
30 
31 #ifdef CONFIG_64BIT
32 u64 rust_helper_readq(const void __iomem *addr)
33 {
34 	return readq(addr);
35 }
36 #endif
37 
38 void rust_helper_writeb(u8 value, void __iomem *addr)
39 {
40 	writeb(value, addr);
41 }
42 
43 void rust_helper_writew(u16 value, void __iomem *addr)
44 {
45 	writew(value, addr);
46 }
47 
48 void rust_helper_writel(u32 value, void __iomem *addr)
49 {
50 	writel(value, addr);
51 }
52 
53 #ifdef CONFIG_64BIT
54 void rust_helper_writeq(u64 value, void __iomem *addr)
55 {
56 	writeq(value, addr);
57 }
58 #endif
59 
60 u8 rust_helper_readb_relaxed(const void __iomem *addr)
61 {
62 	return readb_relaxed(addr);
63 }
64 
65 u16 rust_helper_readw_relaxed(const void __iomem *addr)
66 {
67 	return readw_relaxed(addr);
68 }
69 
70 u32 rust_helper_readl_relaxed(const void __iomem *addr)
71 {
72 	return readl_relaxed(addr);
73 }
74 
75 #ifdef CONFIG_64BIT
76 u64 rust_helper_readq_relaxed(const void __iomem *addr)
77 {
78 	return readq_relaxed(addr);
79 }
80 #endif
81 
82 void rust_helper_writeb_relaxed(u8 value, void __iomem *addr)
83 {
84 	writeb_relaxed(value, addr);
85 }
86 
87 void rust_helper_writew_relaxed(u16 value, void __iomem *addr)
88 {
89 	writew_relaxed(value, addr);
90 }
91 
92 void rust_helper_writel_relaxed(u32 value, void __iomem *addr)
93 {
94 	writel_relaxed(value, addr);
95 }
96 
97 #ifdef CONFIG_64BIT
98 void rust_helper_writeq_relaxed(u64 value, void __iomem *addr)
99 {
100 	writeq_relaxed(value, addr);
101 }
102 #endif
103 
104 resource_size_t rust_helper_resource_size(struct resource *res)
105 {
106 	return resource_size(res);
107 }
108 
109 struct resource *rust_helper_request_mem_region(resource_size_t start,
110 						resource_size_t n,
111 						const char *name)
112 {
113 	return request_mem_region(start, n, name);
114 }
115 
116 void rust_helper_release_mem_region(resource_size_t start, resource_size_t n)
117 {
118 	release_mem_region(start, n);
119 }
120 
121 struct resource *rust_helper_request_region(resource_size_t start,
122 					    resource_size_t n, const char *name)
123 {
124 	return request_region(start, n, name);
125 }
126 
127 struct resource *rust_helper_request_muxed_region(resource_size_t start,
128 						  resource_size_t n,
129 						  const char *name)
130 {
131 	return request_muxed_region(start, n, name);
132 }
133 
134 void rust_helper_release_region(resource_size_t start, resource_size_t n)
135 {
136 	release_region(start, n);
137 }
138