4
4
//!
5
5
//! C header: [`include/asm-generic/io.h`](../../../../include/asm-generic/io.h)
6
6
7
- use crate :: { bindings, c_types , Error , Result } ;
7
+ use crate :: { bindings, Error , Result } ;
8
8
use core:: convert:: TryInto ;
9
9
10
- extern "C" {
11
- fn rust_helper_ioremap (
12
- offset : bindings:: resource_size_t ,
13
- size : c_types:: c_ulong ,
14
- ) -> * mut c_types:: c_void ;
15
-
16
- fn rust_helper_readb ( addr : * const c_types:: c_void ) -> u8 ;
17
- fn rust_helper_readw ( addr : * const c_types:: c_void ) -> u16 ;
18
- fn rust_helper_readl ( addr : * const c_types:: c_void ) -> u32 ;
19
- fn rust_helper_readq ( addr : * const c_types:: c_void ) -> u64 ;
20
-
21
- fn rust_helper_writeb ( value : u8 , addr : * mut c_types:: c_void ) ;
22
- fn rust_helper_writew ( value : u16 , addr : * mut c_types:: c_void ) ;
23
- fn rust_helper_writel ( value : u32 , addr : * mut c_types:: c_void ) ;
24
- fn rust_helper_writeq ( value : u64 , addr : * mut c_types:: c_void ) ;
25
- }
26
-
27
10
/// Represents a memory resource.
28
11
pub struct Resource {
29
12
offset : bindings:: resource_size_t ,
@@ -88,7 +71,7 @@ macro_rules! define_read {
88
71
// SAFETY: The type invariants guarantee that `ptr` is a valid pointer. The check above
89
72
// guarantees that the code won't build if `offset` makes the read go out of bounds
90
73
// (including the type size).
91
- unsafe { concat_idents! ( rust_helper_ , $name) ( ptr as _) }
74
+ unsafe { bindings :: $name( ptr as _) }
92
75
}
93
76
94
77
/// Reads IO data from the given offset.
@@ -102,7 +85,7 @@ macro_rules! define_read {
102
85
// SAFETY: The type invariants guarantee that `ptr` is a valid pointer. The check above
103
86
// returns an error if `offset` would make the read go out of bounds (including the
104
87
// type size).
105
- Ok ( unsafe { concat_idents! ( rust_helper_ , $name) ( ptr as _) } )
88
+ Ok ( unsafe { bindings :: $name( ptr as _) } )
106
89
}
107
90
} ;
108
91
}
@@ -118,7 +101,7 @@ macro_rules! define_write {
118
101
// SAFETY: The type invariants guarantee that `ptr` is a valid pointer. The check above
119
102
// guarantees that the code won't link if `offset` makes the write go out of bounds
120
103
// (including the type size).
121
- unsafe { concat_idents! ( rust_helper_ , $name) ( value, ptr as _) }
104
+ unsafe { bindings :: $name( value, ptr as _) }
122
105
}
123
106
124
107
/// Writes IO data to the given offset.
@@ -132,7 +115,7 @@ macro_rules! define_write {
132
115
// SAFETY: The type invariants guarantee that `ptr` is a valid pointer. The check above
133
116
// returns an error if `offset` would make the write go out of bounds (including the
134
117
// type size).
135
- unsafe { concat_idents! ( rust_helper_ , $name) ( value, ptr as _) } ;
118
+ unsafe { bindings :: $name( value, ptr as _) } ;
136
119
Ok ( ( ) )
137
120
}
138
121
} ;
@@ -165,9 +148,7 @@ impl<const SIZE: usize> IoMem<SIZE> {
165
148
166
149
// Try to map the resource.
167
150
// SAFETY: Just mapping the memory range.
168
- // TODO: Remove `into` call below (and disabling of clippy warning) once #465 is fixed.
169
- #[ allow( clippy:: complexity) ]
170
- let addr = unsafe { rust_helper_ioremap ( res. offset , res. size . into ( ) ) } ;
151
+ let addr = unsafe { bindings:: ioremap ( res. offset , res. size as _ ) } ;
171
152
if addr. is_null ( ) {
172
153
Err ( Error :: ENOMEM )
173
154
} else {
0 commit comments