From: Alice Ryhl Date: Mon, 23 Feb 2026 10:08:25 +0000 (+0000) Subject: rust: clk: implement Send and Sync X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0c0695a9d8c97f63d71dc890faa6999eef728f57;p=thirdparty%2Fkernel%2Flinux.git rust: clk: implement Send and Sync These traits are required for drivers to embed the Clk type in their own data structures because driver data structures are usually required to be Send. Since the Clk type is thread-safe, implement the relevant traits. Reviewed-by: Daniel Almeida Reviewed-by: Danilo Krummrich Acked-by: Viresh Kumar Reviewed-by: Boqun Feng Reviewed-by: Gary Guo Signed-off-by: Alice Ryhl Acked-by: Brian Masney # Active contributor to clk Link: https://patch.msgid.link/20260223-clk-send-sync-v5-1-181bf2f35652@google.com Signed-off-by: Miguel Ojeda --- diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs index 4059aff34d096..7abbd0767d8cf 100644 --- a/rust/kernel/clk.rs +++ b/rust/kernel/clk.rs @@ -128,6 +128,13 @@ mod common_clk { #[repr(transparent)] pub struct Clk(*mut bindings::clk); + // SAFETY: It is safe to call `clk_put` on another thread than where `clk_get` was called. + unsafe impl Send for Clk {} + + // SAFETY: It is safe to call any combination of the `&self` methods in parallel, as the + // methods are synchronized internally. + unsafe impl Sync for Clk {} + impl Clk { /// Gets [`Clk`] corresponding to a [`Device`] and a connection id. ///