diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 01cde2ddb68161..4c76190eddc73f 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -60,25 +60,6 @@ impl Error { /// Bad file number. pub const EBADF: Self = Error(-(bindings::EBADF as i32)); - /// Creates an [`Error`] from a kernel error code. - /// - /// It is a bug to pass an out-of-range `errno`. `EINVAL` would - /// be returned in such a case. - pub(crate) fn from_kernel_errno(errno: c_types::c_int) -> Error { - if errno < -(bindings::MAX_ERRNO as i32) || errno >= 0 { - // TODO: make it a `WARN_ONCE` once available. - crate::pr_warn!( - "attempted to create `Error` with out of range `errno`: {}", - errno - ); - return Error::EINVAL; - } - - // INVARIANT: the check above ensures the type invariant - // will hold. - Error(errno) - } - /// Creates an [`Error`] from a kernel error code. /// /// # Safety