|
71 | 71 | //! # use std::mem;
|
72 | 72 | //! # use nix::{Errno, libc, Result};
|
73 | 73 | //! # const SPI_IOC_MAGIC: u8 = 'k' as u8;
|
74 |
| -//! pub unsafe fn spi_read_mode(fd: c_int, val: *mut u8) -> Result<c_int> { |
75 |
| -//! let res = libc::ioctl(fd, ior!(SPI_IOC_MAGIC, 1, mem::size_of::<u8>()), val); |
| 74 | +//! pub unsafe fn spi_read_mode(fd: c_int, data: *mut u8) -> Result<c_int> { |
| 75 | +//! let res = libc::ioctl(fd, ior!(SPI_IOC_MAGIC, 1, mem::size_of::<u8>()), data); |
76 | 76 | //! Errno::result(res)
|
77 | 77 | //! }
|
78 | 78 | //! # fn main() {}
|
|
92 | 92 | //! More examples on using `ioctl!` can be found in the [rust-spidev crate](https://github.com/rust-embedded/rust-spidev).
|
93 | 93 | //!
|
94 | 94 | //! ```text
|
95 |
| -//! pub unsafe fn $NAME(fd: c_int, val: *mut u8, len: usize) -> Result<c_int>; |
| 95 | +//! pub unsafe fn $NAME(fd: c_int, data: *mut u8, len: usize) -> Result<c_int>; |
96 | 96 | //! ```
|
97 | 97 | //!
|
98 | 98 | //! As mentioned earlier, there are many old `ioctl`s that do not use the newer method of
|
|
115 | 115 | //! The generated function has the same form as that generated by `read`:
|
116 | 116 | //!
|
117 | 117 | //! ```text
|
118 |
| -//! pub unsafe fn tcgets(fd: c_int, val: *mut u8) -> Result<c_int>; |
| 118 | +//! pub unsafe fn tcgets(fd: c_int, data: *mut u8) -> Result<c_int>; |
119 | 119 | //! ```
|
120 | 120 | //!
|
121 | 121 | //! There is also a `bad none` form for use with hard-coded `ioctl`s that do not transfer data.
|
@@ -189,46 +189,47 @@ macro_rules! ioctl {
|
189 | 189 | );
|
190 | 190 | (read $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
|
191 | 191 | pub unsafe fn $name(fd: $crate::libc::c_int,
|
192 |
| - val: *mut $ty) |
| 192 | + data: *mut $ty) |
193 | 193 | -> $crate::Result<$crate::libc::c_int> {
|
194 |
| - convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val)) |
| 194 | + convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data)) |
195 | 195 | }
|
196 | 196 | );
|
197 | 197 | (write $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
|
198 | 198 | pub unsafe fn $name(fd: $crate::libc::c_int,
|
199 |
| - val: *const $ty) |
| 199 | + data: *const $ty) |
200 | 200 | -> $crate::Result<$crate::libc::c_int> {
|
201 |
| - convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val)) |
| 201 | + convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data)) |
202 | 202 | }
|
203 | 203 | );
|
204 | 204 | (readwrite $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
|
205 | 205 | pub unsafe fn $name(fd: $crate::libc::c_int,
|
206 |
| - val: *mut $ty) |
| 206 | + data: *mut $ty) |
207 | 207 | -> $crate::Result<$crate::libc::c_int> {
|
208 |
| - convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, val)) |
| 208 | + convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, ::std::mem::size_of::<$ty>()) as $crate::sys::ioctl::ioctl_num_type, data)) |
209 | 209 | }
|
210 | 210 | );
|
211 | 211 | (read buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
|
212 | 212 | pub unsafe fn $name(fd: $crate::libc::c_int,
|
213 |
| - val: *mut $ty, |
| 213 | + data: *mut $ty, |
214 | 214 | len: usize)
|
215 | 215 | -> $crate::Result<$crate::libc::c_int> {
|
216 |
| - convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val)) |
| 216 | + convert_ioctl_res!($crate::libc::ioctl(fd, ior!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data)) |
217 | 217 | }
|
218 | 218 | );
|
219 | 219 | (write buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
|
220 | 220 | pub unsafe fn $name(fd: $crate::libc::c_int,
|
221 |
| - val: *const $ty, |
222 |
| - len: usize) -> $crate::Result<$crate::libc::c_int> { |
223 |
| - convert_ioctl_res!($crate::libc::ioctl(fd, iow!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val)) |
| 221 | + data: *const $ty, |
| 222 | + len: usize) |
| 223 | + -> $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, data)) |
224 | 225 | }
|
225 | 226 | );
|
226 | 227 | (readwrite buf $name:ident with $ioty:expr, $nr:expr; $ty:ty) => (
|
227 | 228 | pub unsafe fn $name(fd: $crate::libc::c_int,
|
228 |
| - val: *mut $ty, |
| 229 | + data: *mut $ty, |
229 | 230 | len: usize)
|
230 | 231 | -> $crate::Result<$crate::libc::c_int> {
|
231 |
| - convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, val)) |
| 232 | + convert_ioctl_res!($crate::libc::ioctl(fd, iorw!($ioty, $nr, len) as $crate::sys::ioctl::ioctl_num_type, data)) |
232 | 233 | }
|
233 | 234 | );
|
234 | 235 | }
|
0 commit comments