<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/rust/kernel/error.rs, branch v6.6.132</title>
<subtitle>Clone of https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git</subtitle>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/'/>
<entry>
<title>rust: error: add missing newline to pr_warn! calls</title>
<updated>2025-03-22T19:50:48+00:00</updated>
<author>
<name>Alban Kurti</name>
<email>kurti@invicto.ai</email>
</author>
<published>2025-02-06T21:07:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=5da54be46960b962b5d2c005be48327510ae890e'/>
<id>5da54be46960b962b5d2c005be48327510ae890e</id>
<content type='text'>
[ Upstream commit 6f5c36f56d475732981dcf624e0ac0cc7c8984c8 ]

Added missing newline at the end of pr_warn! usage
so the log is not missed.

Fixes: 6551a7fe0acb ("rust: error: Add Error::from_errno{_unchecked}()")
Reported-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Link: https://github.com/Rust-for-Linux/linux/issues/1139
Signed-off-by: Alban Kurti &lt;kurti@invicto.ai&gt;
Link: https://lore.kernel.org/r/20250206-printing_fix-v3-2-a85273b501ae@invicto.ai
[ Replaced Closes with Link since it fixes part of the issue. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 6f5c36f56d475732981dcf624e0ac0cc7c8984c8 ]

Added missing newline at the end of pr_warn! usage
so the log is not missed.

Fixes: 6551a7fe0acb ("rust: error: Add Error::from_errno{_unchecked}()")
Reported-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Link: https://github.com/Rust-for-Linux/linux/issues/1139
Signed-off-by: Alban Kurti &lt;kurti@invicto.ai&gt;
Link: https://lore.kernel.org/r/20250206-printing_fix-v3-2-a85273b501ae@invicto.ai
[ Replaced Closes with Link since it fixes part of the issue. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: error: Markdown style nit</title>
<updated>2023-10-12T20:58:52+00:00</updated>
<author>
<name>Manmohan Shukla</name>
<email>manmshuk@gmail.com</email>
</author>
<published>2023-09-06T20:48:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=2a7e0a52ec98566a863aba42ea35690c65e3da27'/>
<id>2a7e0a52ec98566a863aba42ea35690c65e3da27</id>
<content type='text'>
This patch fixes a trivial markdown style nit in the `SAFETY` comment.

Signed-off-by: Manmohan Shukla &lt;manmshuk@gmail.com&gt;
Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Jianguo Bao &lt;roidinev@gmail.com&gt;
Reviewed-by: Vincenzo Palazzo &lt;vincenzopalazzodev@gmail.com&gt;
Reviewed-by: Finn Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@samsung.com&gt;
Fixes: c7e20faa5fca ("rust: error: Add Error::to_ptr()")
Link: https://lore.kernel.org/r/20230906204857.85619-1-manmshuk@gmail.com
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch fixes a trivial markdown style nit in the `SAFETY` comment.

Signed-off-by: Manmohan Shukla &lt;manmshuk@gmail.com&gt;
Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Jianguo Bao &lt;roidinev@gmail.com&gt;
Reviewed-by: Vincenzo Palazzo &lt;vincenzopalazzodev@gmail.com&gt;
Reviewed-by: Finn Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@samsung.com&gt;
Fixes: c7e20faa5fca ("rust: error: Add Error::to_ptr()")
Link: https://lore.kernel.org/r/20230906204857.85619-1-manmshuk@gmail.com
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: error: fix the description for `ECHILD`</title>
<updated>2023-10-12T20:58:28+00:00</updated>
<author>
<name>Wedson Almeida Filho</name>
<email>walmeida@microsoft.com</email>
</author>
<published>2023-09-30T14:49:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=17bfcd6a81535d7d580ddafb6e54806890aaca6c'/>
<id>17bfcd6a81535d7d580ddafb6e54806890aaca6c</id>
<content type='text'>
A mistake was made and the description of `ECHILD` is wrong (it reuses
the description of `ENOEXEC`). This fixes it to reflect what's in
`errno-base.h`.

Signed-off-by: Wedson Almeida Filho &lt;walmeida@microsoft.com&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Finn Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Fixes: 266def2a0f5b ("rust: error: add codes from `errno-base.h`")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230930144958.46051-1-wedsonaf@gmail.com
[ Use the plural, as noticed by Benno. ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A mistake was made and the description of `ECHILD` is wrong (it reuses
the description of `ENOEXEC`). This fixes it to reflect what's in
`errno-base.h`.

Signed-off-by: Wedson Almeida Filho &lt;walmeida@microsoft.com&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Finn Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Fixes: 266def2a0f5b ("rust: error: add codes from `errno-base.h`")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230930144958.46051-1-wedsonaf@gmail.com
[ Use the plural, as noticed by Benno. ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: error: `impl Debug` for `Error` with `errname()` integration</title>
<updated>2023-06-12T23:24:42+00:00</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2023-05-31T17:44:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=d2e3115d717197cb2bc020dd1f06b06538474ac3'/>
<id>d2e3115d717197cb2bc020dd1f06b06538474ac3</id>
<content type='text'>
Integrate the `Error` type with `errname()` by providing a new
`name()` method.

Then, implement `Debug` for the type using the new method.

[ Miguel: under `CONFIG_SYMBOLIC_ERRNAME=n`, `errname()` is a
  `static inline`, so added a helper to support that case,
  like we had in the `rust` branch. Also moved `#include` up
  and reworded commit message for clarity. ]

Co-developed-by: Wedson Almeida Filho &lt;walmeida@microsoft.com&gt;
Signed-off-by: Wedson Almeida Filho &lt;walmeida@microsoft.com&gt;
Co-developed-by: Sven Van Asbroeck &lt;thesven73@gmail.com&gt;
Signed-off-by: Sven Van Asbroeck &lt;thesven73@gmail.com&gt;
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Link: https://lore.kernel.org/r/20230531174450.3733220-1-aliceryhl@google.com
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Integrate the `Error` type with `errname()` by providing a new
`name()` method.

Then, implement `Debug` for the type using the new method.

[ Miguel: under `CONFIG_SYMBOLIC_ERRNAME=n`, `errname()` is a
  `static inline`, so added a helper to support that case,
  like we had in the `rust` branch. Also moved `#include` up
  and reworded commit message for clarity. ]

Co-developed-by: Wedson Almeida Filho &lt;walmeida@microsoft.com&gt;
Signed-off-by: Wedson Almeida Filho &lt;walmeida@microsoft.com&gt;
Co-developed-by: Sven Van Asbroeck &lt;thesven73@gmail.com&gt;
Signed-off-by: Sven Van Asbroeck &lt;thesven73@gmail.com&gt;
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Link: https://lore.kernel.org/r/20230531174450.3733220-1-aliceryhl@google.com
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: error: add missing error codes</title>
<updated>2023-05-31T16:53:10+00:00</updated>
<author>
<name>Alice Ryhl</name>
<email>aliceryhl@google.com</email>
</author>
<published>2023-05-04T06:48:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=e37b654c379e514357ccadb22c6291d3471fa5e5'/>
<id>e37b654c379e514357ccadb22c6291d3471fa5e5</id>
<content type='text'>
This adds the error codes from `include/linux/errno.h` to the list of
Rust error constants. These errors were not included originally, because
they are not supposed to be visible from userspace. However, they are
still a perfectly valid error to use when writing a kernel driver. For
example, you might want to return ERESTARTSYS if you receive a signal
during a call to `schedule`.

This patch inserts an annotation to skip rustfmt on the list of error
codes. Without it, three of the error codes are split over several
lines, which looks terribly inconsistent.

Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Link: https://lore.kernel.org/r/20230504064854.774820-1-aliceryhl@google.com
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds the error codes from `include/linux/errno.h` to the list of
Rust error constants. These errors were not included originally, because
they are not supposed to be visible from userspace. However, they are
still a perfectly valid error to use when writing a kernel driver. For
example, you might want to return ERESTARTSYS if you receive a signal
during a call to `schedule`.

This patch inserts an annotation to skip rustfmt on the list of error
codes. Without it, three of the error codes are split over several
lines, which looks terribly inconsistent.

Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Link: https://lore.kernel.org/r/20230504064854.774820-1-aliceryhl@google.com
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: error: allow specifying error type on `Result`</title>
<updated>2023-05-31T16:53:10+00:00</updated>
<author>
<name>Alice Ryhl</name>
<email>aliceryhl@google.com</email>
</author>
<published>2023-05-02T12:40:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=4a59081c09cbfe17505baf3db50ebb9b97290bae'/>
<id>4a59081c09cbfe17505baf3db50ebb9b97290bae</id>
<content type='text'>
Currently, if the `kernel::error::Result` type is in scope (which is
often is, since it's in the kernel's prelude), you cannot write
`Result&lt;T, SomeOtherErrorType&gt;` when you want to use a different error
type than `kernel::error::Error`.

To solve this we change the error type from being hard-coded to just
being a default generic parameter. This still lets you write `Result&lt;T&gt;`
when you just want to use the `Error` error type, but also lets you
write `Result&lt;T, SomeOtherErrorType&gt;` when necessary.

Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
Reviewed-by: Asahi Lina &lt;lina@asahilina.net&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@samsung.com&gt;
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
Link: https://lore.kernel.org/r/20230502124015.356001-1-aliceryhl@google.com
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently, if the `kernel::error::Result` type is in scope (which is
often is, since it's in the kernel's prelude), you cannot write
`Result&lt;T, SomeOtherErrorType&gt;` when you want to use a different error
type than `kernel::error::Error`.

To solve this we change the error type from being hard-coded to just
being a default generic parameter. This still lets you write `Result&lt;T&gt;`
when you just want to use the `Error` error type, but also lets you
write `Result&lt;T, SomeOtherErrorType&gt;` when necessary.

Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
Reviewed-by: Asahi Lina &lt;lina@asahilina.net&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@samsung.com&gt;
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
Link: https://lore.kernel.org/r/20230502124015.356001-1-aliceryhl@google.com
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: error: Add from_result() helper</title>
<updated>2023-04-12T16:41:04+00:00</updated>
<author>
<name>Wedson Almeida Filho</name>
<email>wedsonaf@gmail.com</email>
</author>
<published>2023-04-03T09:48:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=ef4dc4cc7001e9cce8a3b556362171648be9ad92'/>
<id>ef4dc4cc7001e9cce8a3b556362171648be9ad92</id>
<content type='text'>
Add a helper function to easily return C result codes from a Rust function
that calls functions which return a Result&lt;T&gt;.

Lina: Imported from rust-for-linux/rust, originally developed by Wedson
as part of file_operations.rs. Added the allow() flags since there is no
user in the kernel crate yet and fixed a typo in a comment. Replaced the
macro with a function taking a closure, per discussion on the ML.

Co-developed-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Signed-off-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Co-developed-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Signed-off-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Signed-off-by: Asahi Lina &lt;lina@asahilina.net&gt;
Link: https://lore.kernel.org/r/20230224-rust-error-v3-6-03779bddc02b@asahilina.net
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a helper function to easily return C result codes from a Rust function
that calls functions which return a Result&lt;T&gt;.

Lina: Imported from rust-for-linux/rust, originally developed by Wedson
as part of file_operations.rs. Added the allow() flags since there is no
user in the kernel crate yet and fixed a typo in a comment. Replaced the
macro with a function taking a closure, per discussion on the ML.

Co-developed-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Signed-off-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Co-developed-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Signed-off-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Signed-off-by: Asahi Lina &lt;lina@asahilina.net&gt;
Link: https://lore.kernel.org/r/20230224-rust-error-v3-6-03779bddc02b@asahilina.net
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: error: Add a helper to convert a C ERR_PTR to a `Result`</title>
<updated>2023-04-12T16:41:04+00:00</updated>
<author>
<name>Sven Van Asbroeck</name>
<email>thesven73@gmail.com</email>
</author>
<published>2023-04-03T09:48:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=752417b3f0e7721f1d630f40da22d57e0dae043e'/>
<id>752417b3f0e7721f1d630f40da22d57e0dae043e</id>
<content type='text'>
Some kernel C API functions return a pointer which embeds an optional
`errno`. Callers are supposed to check the returned pointer with
`IS_ERR()` and if this returns `true`, retrieve the `errno` using
`PTR_ERR()`.

Create a Rust helper function to implement the Rust equivalent:
transform a `*mut T` to `Result&lt;*mut T&gt;`.

Lina: Imported from rust-for-linux/linux, with subsequent refactoring
and contributions squashed in and attributed below. Renamed the function
to from_err_ptr().

Co-developed-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Signed-off-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Co-developed-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Co-developed-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Signed-off-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Co-developed-by: Gary Guo &lt;gary@garyguo.net&gt;
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
Signed-off-by: Sven Van Asbroeck &lt;thesven73@gmail.com&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Signed-off-by: Asahi Lina &lt;lina@asahilina.net&gt;
Link: https://lore.kernel.org/r/20230224-rust-error-v3-5-03779bddc02b@asahilina.net
[ Add a removal of `#[allow(dead_code)]`. ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Some kernel C API functions return a pointer which embeds an optional
`errno`. Callers are supposed to check the returned pointer with
`IS_ERR()` and if this returns `true`, retrieve the `errno` using
`PTR_ERR()`.

Create a Rust helper function to implement the Rust equivalent:
transform a `*mut T` to `Result&lt;*mut T&gt;`.

Lina: Imported from rust-for-linux/linux, with subsequent refactoring
and contributions squashed in and attributed below. Renamed the function
to from_err_ptr().

Co-developed-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Signed-off-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Co-developed-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Co-developed-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Signed-off-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Co-developed-by: Gary Guo &lt;gary@garyguo.net&gt;
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
Signed-off-by: Sven Van Asbroeck &lt;thesven73@gmail.com&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Signed-off-by: Asahi Lina &lt;lina@asahilina.net&gt;
Link: https://lore.kernel.org/r/20230224-rust-error-v3-5-03779bddc02b@asahilina.net
[ Add a removal of `#[allow(dead_code)]`. ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: error: Add to_result() helper</title>
<updated>2023-04-12T16:41:04+00:00</updated>
<author>
<name>Wedson Almeida Filho</name>
<email>wedsonaf@gmail.com</email>
</author>
<published>2023-04-03T09:48:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=086fbfa3b328901fa8b369093ba468864e20544e'/>
<id>086fbfa3b328901fa8b369093ba468864e20544e</id>
<content type='text'>
Add a to_result() helper to convert kernel C return values to a Rust
Result, mapping &gt;=0 values to Ok(()) and negative values to Err(...),
with Error::from_errno() ensuring that the errno is within range.

Lina: Imported from rust-for-linux/rust, originally developed by Wedson
as part of the AMBA device driver support.

Signed-off-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@samsung.com&gt;
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Signed-off-by: Asahi Lina &lt;lina@asahilina.net&gt;
Link: https://lore.kernel.org/r/20230224-rust-error-v3-4-03779bddc02b@asahilina.net
[ Add a removal of `#[allow(dead_code)]`. ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a to_result() helper to convert kernel C return values to a Rust
Result, mapping &gt;=0 values to Ok(()) and negative values to Err(...),
with Error::from_errno() ensuring that the errno is within range.

Lina: Imported from rust-for-linux/rust, originally developed by Wedson
as part of the AMBA device driver support.

Signed-off-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@samsung.com&gt;
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Signed-off-by: Asahi Lina &lt;lina@asahilina.net&gt;
Link: https://lore.kernel.org/r/20230224-rust-error-v3-4-03779bddc02b@asahilina.net
[ Add a removal of `#[allow(dead_code)]`. ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: error: Add Error::from_errno{_unchecked}()</title>
<updated>2023-04-12T16:41:04+00:00</updated>
<author>
<name>Miguel Ojeda</name>
<email>ojeda@kernel.org</email>
</author>
<published>2023-04-03T09:48:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=6551a7fe0acbbc816802350414b37d9b42daccc8'/>
<id>6551a7fe0acbbc816802350414b37d9b42daccc8</id>
<content type='text'>
Add a function to create `Error` values out of a kernel error return,
which safely upholds the invariant that the error code is well-formed
(negative and greater than -MAX_ERRNO). If a malformed code is passed
in, it will be converted to EINVAL.

Lina: Imported from rust-for-linux/rust as authored by Miguel and Fox
with refactoring from Wedson, renamed from_kernel_errno() to
from_errno().

Co-developed-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Signed-off-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Co-developed-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
Signed-off-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@samsung.com&gt;
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Signed-off-by: Asahi Lina &lt;lina@asahilina.net&gt;
Link: https://lore.kernel.org/r/20230224-rust-error-v3-3-03779bddc02b@asahilina.net
[ Mark the new associated functions as `#[allow(dead_code)]`. ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a function to create `Error` values out of a kernel error return,
which safely upholds the invariant that the error code is well-formed
(negative and greater than -MAX_ERRNO). If a malformed code is passed
in, it will be converted to EINVAL.

Lina: Imported from rust-for-linux/rust as authored by Miguel and Fox
with refactoring from Wedson, renamed from_kernel_errno() to
from_errno().

Co-developed-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Signed-off-by: Fox Chen &lt;foxhlchen@gmail.com&gt;
Co-developed-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
Signed-off-by: Wedson Almeida Filho &lt;wedsonaf@gmail.com&gt;
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@samsung.com&gt;
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
Reviewed-by: Martin Rodriguez Reboredo &lt;yakoyoku@gmail.com&gt;
Signed-off-by: Asahi Lina &lt;lina@asahilina.net&gt;
Link: https://lore.kernel.org/r/20230224-rust-error-v3-3-03779bddc02b@asahilina.net
[ Mark the new associated functions as `#[allow(dead_code)]`. ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
