diff options
author | Danilo Krummrich <dakr@kernel.org> | 2025-03-14 17:09:04 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-03-17 08:04:25 +0100 |
commit | d1f6d6c537d488b1a8f04091c7751124985a0ab9 (patch) | |
tree | ac8680355da2ca0bfd5a7ba4f19f4514a2c76152 /rust/kernel/pci.rs | |
parent | e01968420a99ab34f607ad35111b9158caabc3db (diff) | |
download | linux-d1f6d6c537d488b1a8f04091c7751124985a0ab9.tar.gz linux-d1f6d6c537d488b1a8f04091c7751124985a0ab9.tar.bz2 linux-d1f6d6c537d488b1a8f04091c7751124985a0ab9.zip |
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>
Diffstat (limited to 'rust/kernel/pci.rs')
-rw-r--r-- | rust/kernel/pci.rs | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index 4c98b5b9aa1e..386484dcf36e 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -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. |