Skip to content

Commit 0c0695a

Browse files
Darksonnojeda
authored andcommitted
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 <daniel.almeida@collabora.com> Reviewed-by: Danilo Krummrich <dakr@kernel.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Boqun Feng <boqun.feng@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Brian Masney <bmasney@redhat.com> # Active contributor to clk Link: https://patch.msgid.link/20260223-clk-send-sync-v5-1-181bf2f35652@google.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 0a51b38 commit 0c0695a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

rust/kernel/clk.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ mod common_clk {
128128
#[repr(transparent)]
129129
pub struct Clk(*mut bindings::clk);
130130

131+
// SAFETY: It is safe to call `clk_put` on another thread than where `clk_get` was called.
132+
unsafe impl Send for Clk {}
133+
134+
// SAFETY: It is safe to call any combination of the `&self` methods in parallel, as the
135+
// methods are synchronized internally.
136+
unsafe impl Sync for Clk {}
137+
131138
impl Clk {
132139
/// Gets [`Clk`] corresponding to a [`Device`] and a connection id.
133140
///

0 commit comments

Comments
 (0)