Skip to content

Commit e05335a

Browse files
committed
1 parent e1113dc commit e05335a

File tree

5 files changed

+395
-0
lines changed

5 files changed

+395
-0
lines changed

rust/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ RUST_HELPERS := \
1212
build_bug \
1313
device \
1414
err \
15+
io \
1516
kunit \
1617
mutex \
1718
pci \

rust/bindings/bindings_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/device.h>
1111
#include <linux/errname.h>
1212
#include <linux/ethtool.h>
13+
#include <linux/io.h>
1314
#include <linux/jiffies.h>
1415
#include <linux/mdio.h>
1516
#include <linux/pci.h>

rust/helpers/io.c

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/io.h>
4+
5+
u8 rust_helper_readb(const volatile void __iomem *addr)
6+
{
7+
return readb(addr);
8+
}
9+
EXPORT_SYMBOL_GPL(rust_helper_readb);
10+
11+
u16 rust_helper_readw(const volatile void __iomem *addr)
12+
{
13+
return readw(addr);
14+
}
15+
EXPORT_SYMBOL_GPL(rust_helper_readw);
16+
17+
u32 rust_helper_readl(const volatile void __iomem *addr)
18+
{
19+
return readl(addr);
20+
}
21+
EXPORT_SYMBOL_GPL(rust_helper_readl);
22+
23+
#ifdef CONFIG_64BIT
24+
u64 rust_helper_readq(const volatile void __iomem *addr)
25+
{
26+
return readq(addr);
27+
}
28+
EXPORT_SYMBOL_GPL(rust_helper_readq);
29+
#endif
30+
31+
void rust_helper_writeb(u8 value, volatile void __iomem *addr)
32+
{
33+
writeb(value, addr);
34+
}
35+
EXPORT_SYMBOL_GPL(rust_helper_writeb);
36+
37+
void rust_helper_writew(u16 value, volatile void __iomem *addr)
38+
{
39+
writew(value, addr);
40+
}
41+
EXPORT_SYMBOL_GPL(rust_helper_writew);
42+
43+
void rust_helper_writel(u32 value, volatile void __iomem *addr)
44+
{
45+
writel(value, addr);
46+
}
47+
EXPORT_SYMBOL_GPL(rust_helper_writel);
48+
49+
#ifdef CONFIG_64BIT
50+
void rust_helper_writeq(u64 value, volatile void __iomem *addr)
51+
{
52+
writeq(value, addr);
53+
}
54+
EXPORT_SYMBOL_GPL(rust_helper_writeq);
55+
#endif
56+
57+
u8 rust_helper_readb_relaxed(const volatile void __iomem *addr)
58+
{
59+
return readb_relaxed(addr);
60+
}
61+
EXPORT_SYMBOL_GPL(rust_helper_readb_relaxed);
62+
63+
u16 rust_helper_readw_relaxed(const volatile void __iomem *addr)
64+
{
65+
return readw_relaxed(addr);
66+
}
67+
EXPORT_SYMBOL_GPL(rust_helper_readw_relaxed);
68+
69+
u32 rust_helper_readl_relaxed(const volatile void __iomem *addr)
70+
{
71+
return readl_relaxed(addr);
72+
}
73+
EXPORT_SYMBOL_GPL(rust_helper_readl_relaxed);
74+
75+
#ifdef CONFIG_64BIT
76+
u64 rust_helper_readq_relaxed(const volatile void __iomem *addr)
77+
{
78+
return readq_relaxed(addr);
79+
}
80+
EXPORT_SYMBOL_GPL(rust_helper_readq_relaxed);
81+
#endif
82+
83+
void rust_helper_writeb_relaxed(u8 value, volatile void __iomem *addr)
84+
{
85+
writeb_relaxed(value, addr);
86+
}
87+
EXPORT_SYMBOL_GPL(rust_helper_writeb_relaxed);
88+
89+
void rust_helper_writew_relaxed(u16 value, volatile void __iomem *addr)
90+
{
91+
writew_relaxed(value, addr);
92+
}
93+
EXPORT_SYMBOL_GPL(rust_helper_writew_relaxed);
94+
95+
void rust_helper_writel_relaxed(u32 value, volatile void __iomem *addr)
96+
{
97+
writel_relaxed(value, addr);
98+
}
99+
EXPORT_SYMBOL_GPL(rust_helper_writel_relaxed);
100+
101+
#ifdef CONFIG_64BIT
102+
void rust_helper_writeq_relaxed(u64 value, volatile void __iomem *addr)
103+
{
104+
writeq_relaxed(value, addr);
105+
}
106+
EXPORT_SYMBOL_GPL(rust_helper_writeq_relaxed);
107+
#endif
108+
109+
void rust_helper_memcpy_fromio(void *to, const volatile void __iomem *from, long count)
110+
{
111+
memcpy_fromio(to, from, count);
112+
}
113+
EXPORT_SYMBOL_GPL(rust_helper_memcpy_fromio);

0 commit comments

Comments
 (0)