In Rust 1.63.0, Clippy introduced the `as_underscore` lint [1]: > The conversion might include lossy conversion or a dangerous cast that > might go undetected due to the type being inferred. > > The lint is allowed by default as using `_` is less wordy than always > specifying the type. Always specifying the type is especially helpful in function call contexts where the inferred type may change at a distance. Specifying the type also allows Clippy to spot more cases of `useless_conversion`. The primary downside is the need to specify the type in trivial getters. There are 4 such functions: 3 have become slightly less ergonomic, 1 was revealed to be a `useless_conversion`. While this doesn't eliminate unchecked `as` conversions, it makes such conversions easier to scrutinize. It also has the slight benefit of removing a degree of freedom on which to bikeshed. Thus apply the changes and enable the lint -- no functional change intended.
Unified · Split
| @@ -480,6 +480,7 @@ export rust_common_flags := --edition=2021 \ · 479 unmodified lines | ||
| 480 | 480 | -Wunreachable_pub \ |
| 481 | 481 | -Wclippy::all \ |
| 482 | 482 | -Wclippy::as_ptr_cast_mut \ |
| 483 | + -Wclippy::as_underscore \ | |
| 483 | 484 | -Wclippy::ignored_unit_patterns \ |
| 484 | 485 | -Wclippy::mut_mut \ |
| 485 | 486 | -Wclippy::needless_bitwise_bool \ |
| @@ -19,7 +19,7 @@ kernel::pci_device_table!( · 18 unmodified lines | ||
| 19 | 19 | MODULE_PCI_TABLE, |
| 20 | 20 | <NovaCore as pci::Driver>::IdInfo, |
| 21 | 21 | [( |
| 22 | − pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_NVIDIA, bindings::PCI_ANY_ID as _), | |
| 22 | + pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_NVIDIA, bindings::PCI_ANY_ID as u32), | |
| 23 | 23 | () |
| 24 | 24 | )] |
| 25 | 25 | ); |
| @@ -101,7 +101,7 @@ impl<T: Operations> OperationsVTable<T> { · 100 unmodified lines | ||
| 101 | 101 | if let Err(e) = ret { |
| 102 | 102 | e.to_blk_status() |
| 103 | 103 | } else { |
| 104 | − bindings::BLK_STS_OK as _ | |
| 104 | + bindings::BLK_STS_OK as bindings::blk_status_t | |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| @@ -125,7 +125,12 @@ impl<T: Operations> Request<T> { · 124 unmodified lines | ||
| 125 | 125 | // success of the call to `try_set_end` guarantees that there are no |
| 126 | 126 | // `ARef`s pointing to this request. Therefore it is safe to hand it |
| 127 | 127 | // back to the block layer. |
| 128 | − unsafe { bindings::blk_mq_end_request(request_ptr, bindings::BLK_STS_OK as _) }; | |
| 128 | + unsafe { | |
| 129 | + bindings::blk_mq_end_request( | |
| 130 | + request_ptr, | |
| 131 | + bindings::BLK_STS_OK as bindings::blk_status_t, | |
| 132 | + ) | |
| 133 | + }; | |
| 129 | 134 | |
| 130 | 135 | Ok(()) |
| 131 | 136 | } |
| @@ -82,7 +82,7 @@ impl<T: RawDeviceId, U, const N: usize> IdArray<T, U, N> { · 81 unmodified lines | ||
| 82 | 82 | unsafe { |
| 83 | 83 | raw_ids[i] |
| 84 | 84 | .as_mut_ptr() |
| 85 | − .byte_offset(T::DRIVER_DATA_OFFSET as _) | |
| 85 | + .byte_add(T::DRIVER_DATA_OFFSET) | |
| 86 | 86 | .cast::<usize>() |
| 87 | 87 | .write(i); |
| 88 | 88 | } |
| @@ -61,19 +61,19 @@ struct DevresInner<T> { · 60 unmodified lines | ||
| 61 | 61 | /// unsafe fn new(paddr: usize) -> Result<Self>{ |
| 62 | 62 | /// // SAFETY: By the safety requirements of this function [`paddr`, `paddr` + `SIZE`) is |
| 63 | 63 | /// // valid for `ioremap`. |
| 64 | −/// let addr = unsafe { bindings::ioremap(paddr as _, SIZE as _) }; | |
| 64 | +/// let addr = unsafe { bindings::ioremap(paddr as bindings::phys_addr_t, SIZE) }; | |
| 65 | 65 | /// if addr.is_null() { |
| 66 | 66 | /// return Err(ENOMEM); |
| 67 | 67 | /// } |
| 68 | 68 | /// |
| 69 | −/// Ok(IoMem(IoRaw::new(addr as _, SIZE)?)) | |
| 69 | +/// Ok(IoMem(IoRaw::new(addr as usize, SIZE)?)) | |
| 70 | 70 | /// } |
| 71 | 71 | /// } |
| 72 | 72 | /// |
| 73 | 73 | /// impl<const SIZE: usize> Drop for IoMem<SIZE> { |
| 74 | 74 | /// fn drop(&mut self) { |
| 75 | 75 | /// // SAFETY: `self.0.addr()` is guaranteed to be properly mapped by `Self::new`. |
| 76 | −/// unsafe { bindings::iounmap(self.0.addr() as _); }; | |
| 76 | +/// unsafe { bindings::iounmap(self.0.addr() as *mut c_void); }; | |
| 77 | 77 | /// } |
| 78 | 78 | /// } |
| 79 | 79 | /// |
| @@ -115,8 +115,9 @@ impl<T> DevresInner<T> { · 35 unmodified lines | ||
| 115 | 115 | |
| 116 | 116 | // SAFETY: `devm_add_action` guarantees to call `Self::devres_callback` once `dev` is |
| 117 | 117 | // detached. |
| 118 | − let ret = | |
| 119 | − unsafe { bindings::devm_add_action(dev.as_raw(), Some(inner.callback), data as _) }; | |
| 118 | + let ret = unsafe { | |
| 119 | + bindings::devm_add_action(dev.as_raw(), Some(inner.callback), data.cast_mut().cast()) | |
| 120 | + }; | |
| 120 | 121 | |
| 121 | 122 | if ret != 0 { |
| 122 | 123 | // SAFETY: We just created another reference to `inner` in order to pass it to |
| @@ -130,7 +131,7 @@ impl<T> DevresInner<T> { · 7 unmodified lines | ||
| 130 | 131 | } |
| 131 | 132 | |
| 132 | 133 | fn as_ptr(&self) -> *const Self { |
| 133 | − self as _ | |
| 134 | + self | |
| 134 | 135 | } |
| 135 | 136 | |
| 136 | 137 | fn remove_action(this: &Arc<Self>) -> bool { |
| @@ -38,7 +38,7 @@ pub struct Attrs(u32); · 37 unmodified lines | ||
| 38 | 38 | impl Attrs { |
| 39 | 39 | /// Get the raw representation of this attribute. |
| 40 | 40 | pub(crate) fn as_raw(self) -> crate::ffi::c_ulong { |
| 41 | − self.0 as _ | |
| 41 | + self.0 as crate::ffi::c_ulong | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /// Check whether `flags` is contained in `self`. |
| @@ -89,7 +89,7 @@ impl<T: drm::Driver> Device<T> { · 88 unmodified lines | ||
| 89 | 89 | driver_features: drm::driver::FEAT_GEM, |
| 90 | 90 | ioctls: T::IOCTLS.as_ptr(), |
| 91 | 91 | num_ioctls: T::IOCTLS.len() as i32, |
| 92 | − fops: &Self::GEM_FOPS as _, | |
| 92 | + fops: &Self::GEM_FOPS, | |
| 93 | 93 | }; |
| 94 | 94 | |
| 95 | 95 | const GEM_FOPS: bindings::file_operations = drm::gem::create_fops(); |
| @@ -153,7 +153,7 @@ impl Error { · 152 unmodified lines | ||
| 153 | 153 | /// Returns the error encoded as a pointer. |
| 154 | 154 | pub fn to_ptr<T>(self) -> *mut T { |
| 155 | 155 | // SAFETY: `self.0` is a valid error due to its invariant. |
| 156 | − unsafe { bindings::ERR_PTR(self.0.get() as _).cast() } | |
| 156 | + unsafe { bindings::ERR_PTR(self.0.get() as crate::ffi::c_long).cast() } | |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /// Returns a string representing the error, if one exists. |
| @@ -5,7 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | //! C header: [`include/asm-generic/io.h`](srctree/include/asm-generic/io.h) |
| 6 | 6 | |
| 7 | 7 | use crate::error::{code::EINVAL, Result}; |
| 8 | −use crate::{bindings, build_assert}; | |
| 8 | +use crate::{bindings, build_assert, ffi::c_void}; | |
| 9 | 9 | |
| 10 | 10 | /// Raw representation of an MMIO region. |
| 11 | 11 | /// |
| @@ -56,7 +56,7 @@ impl<const SIZE: usize> IoRaw<SIZE> { · 44 unmodified lines | ||
| 56 | 56 | /// # Examples |
| 57 | 57 | /// |
| 58 | 58 | /// ```no_run |
| 59 | −/// # use kernel::{bindings, io::{Io, IoRaw}}; | |
| 59 | +/// # use kernel::{bindings, ffi::c_void, io::{Io, IoRaw}}; | |
| 60 | 60 | /// # use core::ops::Deref; |
| 61 | 61 | /// |
| 62 | 62 | /// // See also [`pci::Bar`] for a real example. |
| @@ -70,19 +70,19 @@ impl<const SIZE: usize> IoRaw<SIZE> { · 7 unmodified lines | ||
| 70 | 70 | /// unsafe fn new(paddr: usize) -> Result<Self>{ |
| 71 | 71 | /// // SAFETY: By the safety requirements of this function [`paddr`, `paddr` + `SIZE`) is |
| 72 | 72 | /// // valid for `ioremap`. |
| 73 | −/// let addr = unsafe { bindings::ioremap(paddr as _, SIZE as _) }; | |
| 73 | +/// let addr = unsafe { bindings::ioremap(paddr as bindings::phys_addr_t, SIZE) }; | |
| 74 | 74 | /// if addr.is_null() { |
| 75 | 75 | /// return Err(ENOMEM); |
| 76 | 76 | /// } |
| 77 | 77 | /// |
| 78 | −/// Ok(IoMem(IoRaw::new(addr as _, SIZE)?)) | |
| 78 | +/// Ok(IoMem(IoRaw::new(addr as usize, SIZE)?)) | |
| 79 | 79 | /// } |
| 80 | 80 | /// } |
| 81 | 81 | /// |
| 82 | 82 | /// impl<const SIZE: usize> Drop for IoMem<SIZE> { |
| 83 | 83 | /// fn drop(&mut self) { |
| 84 | 84 | /// // SAFETY: `self.0.addr()` is guaranteed to be properly mapped by `Self::new`. |
| 85 | −/// unsafe { bindings::iounmap(self.0.addr() as _); }; | |
| 85 | +/// unsafe { bindings::iounmap(self.0.addr() as *mut c_void); }; | |
| 86 | 86 | /// } |
| 87 | 87 | /// } |
| 88 | 88 | /// |
| @@ -119,7 +119,7 @@ macro_rules! define_read { · 30 unmodified lines | ||
| 119 | 119 | let addr = self.io_addr_assert::<$type_name>(offset); |
| 120 | 120 | |
| 121 | 121 | // SAFETY: By the type invariant `addr` is a valid address for MMIO operations. |
| 122 | − unsafe { bindings::$c_fn(addr as _) } | |
| 122 | + unsafe { bindings::$c_fn(addr as *const c_void) } | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /// Read IO data from a given offset. |
| @@ -131,7 +131,7 @@ macro_rules! define_read { · 5 unmodified lines | ||
| 131 | 131 | let addr = self.io_addr::<$type_name>(offset)?; |
| 132 | 132 | |
| 133 | 133 | // SAFETY: By the type invariant `addr` is a valid address for MMIO operations. |
| 134 | − Ok(unsafe { bindings::$c_fn(addr as _) }) | |
| 134 | + Ok(unsafe { bindings::$c_fn(addr as *const c_void) }) | |
| 135 | 135 | } |
| 136 | 136 | }; |
| 137 | 137 | } |
| @@ -148,7 +148,7 @@ macro_rules! define_write { · 10 unmodified lines | ||
| 148 | 148 | let addr = self.io_addr_assert::<$type_name>(offset); |
| 149 | 149 | |
| 150 | 150 | // SAFETY: By the type invariant `addr` is a valid address for MMIO operations. |
| 151 | − unsafe { bindings::$c_fn(value, addr as _, ) } | |
| 151 | + unsafe { bindings::$c_fn(value, addr as *mut c_void) } | |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /// Write IO data from a given offset. |
| @@ -160,7 +160,7 @@ macro_rules! define_write { · 5 unmodified lines | ||
| 160 | 160 | let addr = self.io_addr::<$type_name>(offset)?; |
| 161 | 161 | |
| 162 | 162 | // SAFETY: By the type invariant `addr` is a valid address for MMIO operations. |
| 163 | − unsafe { bindings::$c_fn(value, addr as _) } | |
| 163 | + unsafe { bindings::$c_fn(value, addr as *mut c_void) } | |
| 164 | 164 | Ok(()) |
| 165 | 165 | } |
| 166 | 166 | }; |
| @@ -34,7 +34,7 @@ impl MiscDeviceOptions { · 33 unmodified lines | ||
| 34 | 34 | pub const fn into_raw<T: MiscDevice>(self) -> bindings::miscdevice { |
| 35 | 35 | // SAFETY: All zeros is valid for this C type. |
| 36 | 36 | let mut result: bindings::miscdevice = unsafe { MaybeUninit::zeroed().assume_init() }; |
| 37 | − result.minor = bindings::MISC_DYNAMIC_MINOR as _; | |
| 37 | + result.minor = bindings::MISC_DYNAMIC_MINOR as ffi::c_int; | |
| 38 | 38 | result.name = self.name.as_char_ptr(); |
| 39 | 39 | result.fops = MiscdeviceVTable::<T>::build(); |
| 40 | 40 | result |
| @@ -392,80 +392,80 @@ pub mod flags { · 391 unmodified lines | ||
| 392 | 392 | use crate::bindings; |
| 393 | 393 | |
| 394 | 394 | /// No flags are set. |
| 395 | − pub const NONE: vm_flags_t = bindings::VM_NONE as _; | |
| 395 | + pub const NONE: vm_flags_t = bindings::VM_NONE as vm_flags_t; | |
| 396 | 396 | |
| 397 | 397 | /// Mapping allows reads. |
| 398 | − pub const READ: vm_flags_t = bindings::VM_READ as _; | |
| 398 | + pub const READ: vm_flags_t = bindings::VM_READ as vm_flags_t; | |
| 399 | 399 | |
| 400 | 400 | /// Mapping allows writes. |
| 401 | − pub const WRITE: vm_flags_t = bindings::VM_WRITE as _; | |
| 401 | + pub const WRITE: vm_flags_t = bindings::VM_WRITE as vm_flags_t; | |
| 402 | 402 | |
| 403 | 403 | /// Mapping allows execution. |
| 404 | − pub const EXEC: vm_flags_t = bindings::VM_EXEC as _; | |
| 404 | + pub const EXEC: vm_flags_t = bindings::VM_EXEC as vm_flags_t; | |
| 405 | 405 | |
| 406 | 406 | /// Mapping is shared. |
| 407 | − pub const SHARED: vm_flags_t = bindings::VM_SHARED as _; | |
| 407 | + pub const SHARED: vm_flags_t = bindings::VM_SHARED as vm_flags_t; | |
| 408 | 408 | |
| 409 | 409 | /// Mapping may be updated to allow reads. |
| 410 | − pub const MAYREAD: vm_flags_t = bindings::VM_MAYREAD as _; | |
| 410 | + pub const MAYREAD: vm_flags_t = bindings::VM_MAYREAD as vm_flags_t; | |
| 411 | 411 | |
| 412 | 412 | /// Mapping may be updated to allow writes. |
| 413 | − pub const MAYWRITE: vm_flags_t = bindings::VM_MAYWRITE as _; | |
| 413 | + pub const MAYWRITE: vm_flags_t = bindings::VM_MAYWRITE as vm_flags_t; | |
| 414 | 414 | |
| 415 | 415 | /// Mapping may be updated to allow execution. |
| 416 | − pub const MAYEXEC: vm_flags_t = bindings::VM_MAYEXEC as _; | |
| 416 | + pub const MAYEXEC: vm_flags_t = bindings::VM_MAYEXEC as vm_flags_t; | |
| 417 | 417 | |
| 418 | 418 | /// Mapping may be updated to be shared. |
| 419 | − pub const MAYSHARE: vm_flags_t = bindings::VM_MAYSHARE as _; | |
| 419 | + pub const MAYSHARE: vm_flags_t = bindings::VM_MAYSHARE as vm_flags_t; | |
| 420 | 420 | |
| 421 | 421 | /// Page-ranges managed without `struct page`, just pure PFN. |
| 422 | − pub const PFNMAP: vm_flags_t = bindings::VM_PFNMAP as _; | |
| 422 | + pub const PFNMAP: vm_flags_t = bindings::VM_PFNMAP as vm_flags_t; | |
| 423 | 423 | |
| 424 | 424 | /// Memory mapped I/O or similar. |
| 425 | − pub const IO: vm_flags_t = bindings::VM_IO as _; | |
| 425 | + pub const IO: vm_flags_t = bindings::VM_IO as vm_flags_t; | |
| 426 | 426 | |
| 427 | 427 | /// Do not copy this vma on fork. |
| 428 | − pub const DONTCOPY: vm_flags_t = bindings::VM_DONTCOPY as _; | |
| 428 | + pub const DONTCOPY: vm_flags_t = bindings::VM_DONTCOPY as vm_flags_t; | |
| 429 | 429 | |
| 430 | 430 | /// Cannot expand with mremap(). |
| 431 | − pub const DONTEXPAND: vm_flags_t = bindings::VM_DONTEXPAND as _; | |
| 431 | + pub const DONTEXPAND: vm_flags_t = bindings::VM_DONTEXPAND as vm_flags_t; | |
| 432 | 432 | |
| 433 | 433 | /// Lock the pages covered when they are faulted in. |
| 434 | − pub const LOCKONFAULT: vm_flags_t = bindings::VM_LOCKONFAULT as _; | |
| 434 | + pub const LOCKONFAULT: vm_flags_t = bindings::VM_LOCKONFAULT as vm_flags_t; | |
| 435 | 435 | |
| 436 | 436 | /// Is a VM accounted object. |
| 437 | − pub const ACCOUNT: vm_flags_t = bindings::VM_ACCOUNT as _; | |
| 437 | + pub const ACCOUNT: vm_flags_t = bindings::VM_ACCOUNT as vm_flags_t; | |
| 438 | 438 | |
| 439 | 439 | /// Should the VM suppress accounting. |
| 440 | − pub const NORESERVE: vm_flags_t = bindings::VM_NORESERVE as _; | |
| 440 | + pub const NORESERVE: vm_flags_t = bindings::VM_NORESERVE as vm_flags_t; | |
| 441 | 441 | |
| 442 | 442 | /// Huge TLB Page VM. |
| 443 | − pub const HUGETLB: vm_flags_t = bindings::VM_HUGETLB as _; | |
| 443 | + pub const HUGETLB: vm_flags_t = bindings::VM_HUGETLB as vm_flags_t; | |
| 444 | 444 | |
| 445 | 445 | /// Synchronous page faults. (DAX-specific) |
| 446 | − pub const SYNC: vm_flags_t = bindings::VM_SYNC as _; | |
| 446 | + pub const SYNC: vm_flags_t = bindings::VM_SYNC as vm_flags_t; | |
| 447 | 447 | |
| 448 | 448 | /// Architecture-specific flag. |
| 449 | − pub const ARCH_1: vm_flags_t = bindings::VM_ARCH_1 as _; | |
| 449 | + pub const ARCH_1: vm_flags_t = bindings::VM_ARCH_1 as vm_flags_t; | |
| 450 | 450 | |
| 451 | 451 | /// Wipe VMA contents in child on fork. |
| 452 | − pub const WIPEONFORK: vm_flags_t = bindings::VM_WIPEONFORK as _; | |
| 452 | + pub const WIPEONFORK: vm_flags_t = bindings::VM_WIPEONFORK as vm_flags_t; | |
| 453 | 453 | |
| 454 | 454 | /// Do not include in the core dump. |
| 455 | − pub const DONTDUMP: vm_flags_t = bindings::VM_DONTDUMP as _; | |
| 455 | + pub const DONTDUMP: vm_flags_t = bindings::VM_DONTDUMP as vm_flags_t; | |
| 456 | 456 | |
| 457 | 457 | /// Not soft dirty clean area. |
| 458 | − pub const SOFTDIRTY: vm_flags_t = bindings::VM_SOFTDIRTY as _; | |
| 458 | + pub const SOFTDIRTY: vm_flags_t = bindings::VM_SOFTDIRTY as vm_flags_t; | |
| 459 | 459 | |
| 460 | 460 | /// Can contain `struct page` and pure PFN pages. |
| 461 | − pub const MIXEDMAP: vm_flags_t = bindings::VM_MIXEDMAP as _; | |
| 461 | + pub const MIXEDMAP: vm_flags_t = bindings::VM_MIXEDMAP as vm_flags_t; | |
| 462 | 462 | |
| 463 | 463 | /// MADV_HUGEPAGE marked this vma. |
| 464 | − pub const HUGEPAGE: vm_flags_t = bindings::VM_HUGEPAGE as _; | |
| 464 | + pub const HUGEPAGE: vm_flags_t = bindings::VM_HUGEPAGE as vm_flags_t; | |
| 465 | 465 | |
| 466 | 466 | /// MADV_NOHUGEPAGE marked this vma. |
| 467 | − pub const NOHUGEPAGE: vm_flags_t = bindings::VM_NOHUGEPAGE as _; | |
| 467 | + pub const NOHUGEPAGE: vm_flags_t = bindings::VM_NOHUGEPAGE as vm_flags_t; | |
| 468 | 468 | |
| 469 | 469 | /// KSM may merge identical pages. |
| 470 | − pub const MERGEABLE: vm_flags_t = bindings::VM_MERGEABLE as _; | |
| 470 | + pub const MERGEABLE: vm_flags_t = bindings::VM_MERGEABLE as vm_flags_t; | |
| 471 | 471 | } |
| @@ -22,7 +22,7 @@ unsafe impl RawDeviceId for DeviceId { · 21 unmodified lines | ||
| 22 | 22 | const DRIVER_DATA_OFFSET: usize = core::mem::offset_of!(bindings::of_device_id, data); |
| 23 | 23 | |
| 24 | 24 | fn index(&self) -> usize { |
| 25 | − self.0.data as _ | |
| 25 | + self.0.data as usize | |
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| @@ -34,10 +34,10 @@ impl DeviceId { · 5 unmodified lines | ||
| 34 | 34 | // SAFETY: FFI type is valid to be zero-initialized. |
| 35 | 35 | let mut of: bindings::of_device_id = unsafe { core::mem::zeroed() }; |
| 36 | 36 | |
| 37 | − // TODO: Use `clone_from_slice` once the corresponding types do match. | |
| 37 | + // TODO: Use `copy_from_slice` once stabilized for `const`. | |
| 38 | 38 | let mut i = 0; |
| 39 | 39 | while i < src.len() { |
| 40 | − of.compatible[i] = src[i] as _; | |
| 40 | + of.compatible[i] = src[i]; | |
| 41 | 41 | i += 1; |
| 42 | 42 | } |
| 43 | 43 | |
| @@ -171,7 +171,7 @@ unsafe impl RawDeviceId for DeviceId { · 170 unmodified lines | ||
| 171 | 171 | const DRIVER_DATA_OFFSET: usize = core::mem::offset_of!(bindings::pci_device_id, driver_data); |
| 172 | 172 | |
| 173 | 173 | fn index(&self) -> usize { |
| 174 | − self.0.driver_data as _ | |
| 174 | + self.0.driver_data | |
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
| @@ -206,7 +206,10 @@ macro_rules! pci_device_table { · 28 unmodified lines | ||
| 206 | 206 | /// MODULE_PCI_TABLE, |
| 207 | 207 | /// <MyDriver as pci::Driver>::IdInfo, |
| 208 | 208 | /// [ |
| 209 | −/// (pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_REDHAT, bindings::PCI_ANY_ID as _), ()) | |
| 209 | +/// ( | |
| 210 | +/// pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_REDHAT, bindings::PCI_ANY_ID as u32), | |
| 211 | +/// (), | |
| 212 | +/// ) | |
| 210 | 213 | /// ] |
| 211 | 214 | /// ); |
| 212 | 215 | /// |
| @@ -330,7 +333,7 @@ impl<const SIZE: usize> Bar<SIZE> { · 117 unmodified lines | ||
| 330 | 333 | // `ioptr` is valid by the safety requirements. |
| 331 | 334 | // `num` is valid by the safety requirements. |
| 332 | 335 | unsafe { |
| 333 | − bindings::pci_iounmap(pdev.as_raw(), ioptr as _); | |
| 336 | + bindings::pci_iounmap(pdev.as_raw(), ioptr as *mut kernel::ffi::c_void); | |
| 334 | 337 | bindings::pci_release_region(pdev.as_raw(), num); |
| 335 | 338 | } |
| 336 | 339 | } |
| @@ -728,9 +728,9 @@ impl RawFormatter { · 727 unmodified lines | ||
| 728 | 728 | pub(crate) unsafe fn from_ptrs(pos: *mut u8, end: *mut u8) -> Self { |
| 729 | 729 | // INVARIANT: The safety requirements guarantee the type invariants. |
| 730 | 730 | Self { |
| 731 | − beg: pos as _, | |
| 732 | − pos: pos as _, | |
| 733 | − end: end as _, | |
| 731 | + beg: pos as usize, | |
| 732 | + pos: pos as usize, | |
| 733 | + end: end as usize, | |
| 734 | 734 | } |
| 735 | 735 | } |
| 736 | 736 | |
| @@ -755,7 +755,7 @@ impl RawFormatter { · 18 unmodified lines | ||
| 755 | 755 | /// |
| 756 | 756 | /// N.B. It may point to invalid memory. |
| 757 | 757 | pub(crate) fn pos(&self) -> *mut u8 { |
| 758 | − self.pos as _ | |
| 758 | + self.pos as *mut u8 | |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | /// Returns the number of bytes written to the formatter. |
| @@ -198,7 +198,7 @@ impl Queue { · 197 unmodified lines | ||
| 198 | 198 | unsafe { |
| 199 | 199 | w.__enqueue(move |work_ptr| { |
| 200 | 200 | bindings::queue_work_on( |
| 201 | − bindings::wq_misc_consts_WORK_CPU_UNBOUND as _, | |
| 201 | + bindings::wq_misc_consts_WORK_CPU_UNBOUND as ffi::c_int, | |
| 202 | 202 | queue_ptr, |
| 203 | 203 | work_ptr, |
| 204 | 204 | ) |