mirror of
https://github.com/torvalds/linux.git
synced 2025-04-12 16:47:42 +00:00
rust: pci: use to_result() in enable_device_mem()
Simplify enable_device_mem() by using to_result() to handle the return value of the corresponding FFI call. Reviewed-by: Benno Lossin <benno.lossin@proton.me> Signed-off-by: Danilo Krummrich <dakr@kernel.org> Acked-by: Boqun Feng <boqun.feng@gmail.com> Link: https://lore.kernel.org/r/20250314160932.100165-2-dakr@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e01968420a
commit
d1f6d6c537
@ -382,12 +382,7 @@ impl Device {
|
||||
/// Enable memory resources for this device.
|
||||
pub fn enable_device_mem(&self) -> Result {
|
||||
// SAFETY: `self.as_raw` is guaranteed to be a pointer to a valid `struct pci_dev`.
|
||||
let ret = unsafe { bindings::pci_enable_device_mem(self.as_raw()) };
|
||||
if ret != 0 {
|
||||
Err(Error::from_errno(ret))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
to_result(unsafe { bindings::pci_enable_device_mem(self.as_raw()) })
|
||||
}
|
||||
|
||||
/// Enable bus-mastering for this device.
|
||||
|
Loading…
x
Reference in New Issue
Block a user