Skip to content

Commit 16ae3e8

Browse files
committed
Unify argument names to generated ioctl functions
1 parent a921981 commit 16ae3e8

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
@@ -94,7 +94,7 @@
9494
//! More examples on using `ioctl!` can be found in the [rust-spidev crate](https://github.com/rust-embedded/rust-spidev).
9595
//!
9696
//! ```text
97-
//! pub unsafe fn $NAME(fd: c_int, val: *mut u8, len: usize) -> Result<c_int>;
97+
//! pub unsafe fn $NAME(fd: c_int, data: *mut u8, len: usize) -> Result<c_int>;
9898
//! ```
9999
//!
100100
//! As mentioned earlier, there are many old `ioctl`s that do not use the newer method of
@@ -117,7 +117,7 @@
117117
//! The generated function has the same form as that generated by `read`:
118118
//!
119119
//! ```text
120-
//! pub unsafe fn tcgets(fd: c_int, val: *mut u8) -> Result<c_int>;
120+
//! pub unsafe fn tcgets(fd: c_int, data: *mut u8) -> Result<c_int>;
121121
//! ```
122122
//!
123123
//! There is also a `bad none` form for use with hard-coded `ioctl`s that do not transfer data.
@@ -191,46 +191,47 @@ macro_rules! ioctl {
191191
);
192192
(read $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
193193
pub unsafe fn $name(fd: $crate::libc::c_int,
194-
val: *mut $ty)
194+
data: *mut $ty)
195195
-> $crate::Result<$crate::libc::c_int> {
196-
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
196+
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
197197
}
198198
);
199199
(write $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
200200
pub unsafe fn $name(fd: $crate::libc::c_int,
201-
val: $ty)
201+
data: $ty)
202202
-> $crate::Result<$crate::libc::c_int> {
203-
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
203+
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
204204
}
205205
);
206206
(readwrite $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
207207
pub unsafe fn $name(fd: $crate::libc::c_int,
208-
val: *mut $ty)
208+
data: *mut $ty)
209209
-> $crate::Result<$crate::libc::c_int> {
210-
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val))
210+
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data))
211211
}
212212
);
213213
(read buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
214214
pub unsafe fn $name(fd: $crate::libc::c_int,
215-
val: *mut $ty,
215+
data: *mut $ty,
216216
len: usize)
217217
-> $crate::Result<$crate::libc::c_int> {
218-
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
218+
convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
219219
}
220220
);
221221
(write buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
222222
pub unsafe fn $name(fd: $crate::libc::c_int,
223-
val: *const $ty,
224-
len: usize) -> $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, val))
223+
data: *const $ty,
224+
len: usize)
225+
-> $crate::Result<$crate::libc::c_int> {
226+
convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
226227
}
227228
);
228229
(readwrite buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
229230
pub unsafe fn $name(fd: $crate::libc::c_int,
230-
val: *mut $ty,
231+
data: *mut $ty,
231232
len: usize)
232233
-> $crate::Result<$crate::libc::c_int> {
233-
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val))
234+
convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data))
234235
}
235236
);
236237
}

0 commit comments

Comments
 (0)