Skip to content

Commit e8b874f

Browse files
felipeaggerjfvogel
authored andcommitted
rust: error: make conversion functions public
commit 5ed1474 upstream. Change visibility to public of functions in error.rs: from_err_ptr, from_errno, from_result and to_ptr. Additionally, remove dead_code annotations. Link: Rust-for-Linux/linux#1105 Reviewed-by: Alice Ryhl <[email protected]> Signed-off-by: Filipe Xavier <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Gary Guo <[email protected]> Link: https://lore.kernel.org/r/DM4PR14MB7276E6948E67B3B23D8EA847E9652@DM4PR14MB7276.namprd14.prod.outlook.com Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 6e5a4992d1468333783e4395e66aff5cca78d49b) Signed-off-by: Jack Vogel <[email protected]>
1 parent f56decf commit e8b874f

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

rust/kernel/error.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Error {
9595
///
9696
/// It is a bug to pass an out-of-range `errno`. `EINVAL` would
9797
/// be returned in such a case.
98-
pub(crate) fn from_errno(errno: core::ffi::c_int) -> Error {
98+
pub fn from_errno(errno: core::ffi::c_int) -> Error {
9999
if errno < -(bindings::MAX_ERRNO as i32) || errno >= 0 {
100100
// TODO: Make it a `WARN_ONCE` once available.
101101
crate::pr_warn!(
@@ -133,8 +133,7 @@ impl Error {
133133
}
134134

135135
/// Returns the error encoded as a pointer.
136-
#[expect(dead_code)]
137-
pub(crate) fn to_ptr<T>(self) -> *mut T {
136+
pub fn to_ptr<T>(self) -> *mut T {
138137
#[cfg_attr(target_pointer_width = "32", allow(clippy::useless_conversion))]
139138
// SAFETY: `self.0` is a valid error due to its invariant.
140139
unsafe {
@@ -270,9 +269,7 @@ pub fn to_result(err: core::ffi::c_int) -> Result {
270269
/// from_err_ptr(unsafe { bindings::devm_platform_ioremap_resource(pdev.to_ptr(), index) })
271270
/// }
272271
/// ```
273-
// TODO: Remove `dead_code` marker once an in-kernel client is available.
274-
#[allow(dead_code)]
275-
pub(crate) fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
272+
pub fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
276273
// CAST: Casting a pointer to `*const core::ffi::c_void` is always valid.
277274
let const_ptr: *const core::ffi::c_void = ptr.cast();
278275
// SAFETY: The FFI function does not deref the pointer.
@@ -318,9 +315,7 @@ pub(crate) fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
318315
/// })
319316
/// }
320317
/// ```
321-
// TODO: Remove `dead_code` marker once an in-kernel client is available.
322-
#[allow(dead_code)]
323-
pub(crate) fn from_result<T, F>(f: F) -> T
318+
pub fn from_result<T, F>(f: F) -> T
324319
where
325320
T: From<i16>,
326321
F: FnOnce() -> Result<T>,

0 commit comments

Comments
 (0)