diff mbox series

rust: error.rs: Remove dead_code marker and make from_err_ptr, from_result and to_ptr public

Message ID DM4PR14MB72760296911674F92C7A6C01E99F2@DM4PR14MB7276.namprd14.prod.outlook.com (mailing list archive)
State New
Headers show
Series rust: error.rs: Remove dead_code marker and make from_err_ptr, from_result and to_ptr public | expand

Commit Message

Felipe Alves Sept. 7, 2024, 6:19 p.m. UTC
From 93dc3be19450447a3a7090bd1dfb9f3daac3e8d2 Mon Sep 17 00:00:00 2001
From: Filipe Xavier <felipe_life@live.com>
Date: Sat, 7 Sep 2024 14:50:33 +0200
Subject: [PATCH] rust: error.rs: Remove dead_code marker and make from_err_ptr, from_result and to_ptr public

Remove dead_code annotation from from_err_ptr, from_result and to_ptr functions in error.rs file and change visibility to public, making it accessible outside the kernel crate(issue #1105).

Signed-off-by: Filipe Xavier <felipe_life@live.com>
---
diff mbox series

Patch

From 93dc3be19450447a3a7090bd1dfb9f3daac3e8d2 Mon Sep 17 00:00:00 2001
From: Filipe Xavier <felipe_life@live.com>
Date: Sat, 7 Sep 2024 14:50:33 +0200
Subject: [PATCH] rust: error.rs: Remove dead_code marker and make from_err_ptr, from_result and to_ptr public

Remove dead_code annotation from from_err_ptr, from_result and to_ptr functions in error.rs file and change visibility to public, making it accessible outside the kernel crate(issue #1105).

Signed-off-by: Filipe Xavier <felipe_life@live.com>
---
diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index 6f1587a2524e..ecfa6aa41034 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -133,8 +133,7 @@  pub(crate) fn to_blk_status(self) -> bindings::blk_status_t {
     }
 
     /// Returns the error encoded as a pointer.
-    #[allow(dead_code)]
-    pub(crate) fn to_ptr<T>(self) -> *mut T {
+    pub fn to_ptr<T>(self) -> *mut T {
         #[cfg_attr(target_pointer_width = "32", allow(clippy::useless_conversion))]
         // SAFETY: `self.0` is a valid error due to its invariant.
         unsafe {
@@ -268,9 +267,7 @@  pub fn to_result(err: core::ffi::c_int) -> Result {
 ///     from_err_ptr(unsafe { bindings::devm_platform_ioremap_resource(pdev.to_ptr(), index) })
 /// }
 /// ```
-// TODO: Remove `dead_code` marker once an in-kernel client is available.
-#[allow(dead_code)]
-pub(crate) fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
+pub fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
     // CAST: Casting a pointer to `*const core::ffi::c_void` is always valid.
     let const_ptr: *const core::ffi::c_void = ptr.cast();
     // SAFETY: The FFI function does not deref the pointer.
@@ -315,9 +312,7 @@  pub(crate) fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
 ///     })
 /// }
 /// ```
-// TODO: Remove `dead_code` marker once an in-kernel client is available.
-#[allow(dead_code)]
-pub(crate) fn from_result<T, F>(f: F) -> T
+pub fn from_result<T, F>(f: F) -> T
 where
     T: From<i16>,
     F: FnOnce() -> Result<T>,