Skip to content

Commit b84b79a

Browse files
committed
Unify argument names to generated ioctl functions
1 parent d430db4 commit b84b79a

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/sys/ioctl/mod.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
//! More examples on using `ioctl!` can be found in the [rust-spidev crate](https://github.com/rust-embedded/rust-spidev).
9494
//!
9595
//! ```text
96-
//! pub unsafe fn $NAME(fd: c_int, val: *mut u8, len: usize) -> Result<c_int>;
96+
//! pub unsafe fn $NAME(fd: c_int, data: *mut u8, len: usize) -> Result<c_int>;
9797
//! ```
9898
//!
9999
//! As mentioned earlier, there are many old `ioctl`s that do not use the newer method of
@@ -116,7 +116,7 @@
116116
//! The generated function has the same form as that generated by `read`:
117117
//!
118118
//! ```text
119-
//! pub unsafe fn tcgets(fd: c_int, val: *mut u8) -> Result<c_int>;
119+
//! pub unsafe fn tcgets(fd: c_int, data: *mut u8) -> Result<c_int>;
120120
//! ```
121121
//!
122122
//! There is also a `bad none` form for use with hard-coded `ioctl`s that do not transfer data.
@@ -190,46 +190,47 @@ macro_rules! ioctl {
190190
);
191191
(read $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
192192
pub unsafe fn $name(fd: $crate::libc::c_int,
193-
val: *mut $ty)
193+
data: *mut $ty)
194194
-> $crate::Result<$crate::libc::c_int> {
195-
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
195+
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
196196
}
197197
);
198198
(write $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
199199
pub unsafe fn $name(fd: $crate::libc::c_int,
200-
val: *const $ty)
200+
data: *const $ty)
201201
-> $crate::Result<$crate::libc::c_int> {
202-
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
202+
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
203203
}
204204
);
205205
(readwrite $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
206206
pub unsafe fn $name(fd: $crate::libc::c_int,
207-
val: *mut $ty)
207+
data: *mut $ty)
208208
-> $crate::Result<$crate::libc::c_int> {
209-
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
209+
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
210210
}
211211
);
212212
(read buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
213213
pub unsafe fn $name(fd: $crate::libc::c_int,
214-
val: *mut $ty,
214+
data: *mut $ty,
215215
len: usize)
216216
-> $crate::Result<$crate::libc::c_int> {
217-
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
217+
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
218218
}
219219
);
220220
(write buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
221221
pub unsafe fn $name(fd: $crate::libc::c_int,
222-
val: *const $ty,
223-
len: usize) -> $crate::Result<$crate::libc::c_int> {
224-
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
222+
data: *const $ty,
223+
len: usize)
224+
-> $crate::Result<$crate::libc::c_int> {
225+
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
225226
}
226227
);
227228
(readwrite buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
228229
pub unsafe fn $name(fd: $crate::libc::c_int,
229-
val: *mut $ty,
230+
data: *mut $ty,
230231
len: usize)
231232
-> $crate::Result<$crate::libc::c_int> {
232-
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
233+
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
233234
}
234235
);
235236
}

0 commit comments

Comments
 (0)