* [PATCH 1/3] firmware: rust: improve safety comments
@ 2024-06-19 13:20 Danilo Krummrich
2024-06-19 13:20 ` [PATCH 2/3] MAINTAINERS: add Rust FW abstractions to FIRMWARE LOADER Danilo Krummrich
2024-06-19 13:20 ` [PATCH 3/3] MAINTAINERS: add Danilo as FIRMWARE LOADER maintainer Danilo Krummrich
0 siblings, 2 replies; 3+ messages in thread
From: Danilo Krummrich @ 2024-06-19 13:20 UTC (permalink / raw)
To: mcgrof, russ.weight, gregkh
Cc: linux-kernel, rust-for-linux, Danilo Krummrich, Benno Lossin
Improve the wording of safety comments to be more explicit about what
exactly is guaranteed to be valid.
Suggested-by: Benno Lossin <benno.lossin@proton.me>
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
rust/kernel/firmware.rs | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/rust/kernel/firmware.rs b/rust/kernel/firmware.rs
index b55ea1b45368..386c8fb44785 100644
--- a/rust/kernel/firmware.rs
+++ b/rust/kernel/firmware.rs
@@ -22,8 +22,7 @@
///
/// The pointer is valid, and has ownership over the instance of `struct firmware`.
///
-/// Once requested, the `Firmware` backing buffer is not modified until it is freed when `Firmware`
-/// is dropped.
+/// The `Firmware`'s backing buffer is not modified.
///
/// # Examples
///
@@ -72,22 +71,22 @@ fn as_raw(&self) -> *mut bindings::firmware {
/// Returns the size of the requested firmware in bytes.
pub fn size(&self) -> usize {
- // SAFETY: Safe by the type invariant.
+ // SAFETY: `self.as_raw()` is valid by the type invariant.
unsafe { (*self.as_raw()).size }
}
/// Returns the requested firmware as `&[u8]`.
pub fn data(&self) -> &[u8] {
- // SAFETY: Safe by the type invariant. Additionally, `bindings::firmware` guarantees, if
- // successfully requested, that `bindings::firmware::data` has a size of
- // `bindings::firmware::size` bytes.
+ // SAFETY: `self.as_raw()` is valid by the type invariant. Additionally,
+ // `bindings::firmware` guarantees, if successfully requested, that
+ // `bindings::firmware::data` has a size of `bindings::firmware::size` bytes.
unsafe { core::slice::from_raw_parts((*self.as_raw()).data, self.size()) }
}
}
impl Drop for Firmware {
fn drop(&mut self) {
- // SAFETY: Safe by the type invariant.
+ // SAFETY: `self.as_raw()` is valid by the type invariant.
unsafe { bindings::release_firmware(self.as_raw()) };
}
}
base-commit: de6582833db0e695ba0c548e3cc2ad7dbb6aa260
--
2.45.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/3] MAINTAINERS: add Rust FW abstractions to FIRMWARE LOADER
2024-06-19 13:20 [PATCH 1/3] firmware: rust: improve safety comments Danilo Krummrich
@ 2024-06-19 13:20 ` Danilo Krummrich
2024-06-19 13:20 ` [PATCH 3/3] MAINTAINERS: add Danilo as FIRMWARE LOADER maintainer Danilo Krummrich
1 sibling, 0 replies; 3+ messages in thread
From: Danilo Krummrich @ 2024-06-19 13:20 UTC (permalink / raw)
To: mcgrof, russ.weight, gregkh
Cc: linux-kernel, rust-for-linux, Danilo Krummrich
Add missing file path of the Rust abstractions to the maintainers entry,
until we can move it to 'drivers/base/firmware_loader/'.
CC: Luis Chamberlain <mcgrof@kernel.org>
CC: Russ Weight <russ.weight@linux.dev>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
MAINTAINERS | 1 +
1 file changed, 1 insertion(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index cf9c9221c388..38e7e0edd9b8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8573,6 +8573,7 @@ L: linux-kernel@vger.kernel.org
S: Maintained
F: Documentation/firmware_class/
F: drivers/base/firmware_loader/
+F: rust/kernel/firmware.rs
F: include/linux/firmware.h
FLEXTIMER FTM-QUADDEC DRIVER
--
2.45.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] MAINTAINERS: add Danilo as FIRMWARE LOADER maintainer
2024-06-19 13:20 [PATCH 1/3] firmware: rust: improve safety comments Danilo Krummrich
2024-06-19 13:20 ` [PATCH 2/3] MAINTAINERS: add Rust FW abstractions to FIRMWARE LOADER Danilo Krummrich
@ 2024-06-19 13:20 ` Danilo Krummrich
1 sibling, 0 replies; 3+ messages in thread
From: Danilo Krummrich @ 2024-06-19 13:20 UTC (permalink / raw)
To: mcgrof, russ.weight, gregkh
Cc: linux-kernel, rust-for-linux, Danilo Krummrich
Add myself as firmware loader maintainer, as suggested by Luis in [1].
CC: Luis Chamberlain <mcgrof@kernel.org>
CC: Russ Weight <russ.weight@linux.dev>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/rust-for-linux/ZnHkQpyiX4UKdLEt@bombadil.infradead.org/ [1]
Suggested-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
MAINTAINERS | 1 +
1 file changed, 1 insertion(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 38e7e0edd9b8..19e4a21e574e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8569,6 +8569,7 @@ F: include/linux/arm_ffa.h
FIRMWARE LOADER (request_firmware)
M: Luis Chamberlain <mcgrof@kernel.org>
M: Russ Weight <russ.weight@linux.dev>
+M: Danilo Krummrich <dakr@redhat.com>
L: linux-kernel@vger.kernel.org
S: Maintained
F: Documentation/firmware_class/
--
2.45.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-19 13:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 13:20 [PATCH 1/3] firmware: rust: improve safety comments Danilo Krummrich
2024-06-19 13:20 ` [PATCH 2/3] MAINTAINERS: add Rust FW abstractions to FIRMWARE LOADER Danilo Krummrich
2024-06-19 13:20 ` [PATCH 3/3] MAINTAINERS: add Danilo as FIRMWARE LOADER maintainer Danilo Krummrich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.