diff options
| author | Alice Ryhl <aliceryhl@google.com> | 2026-02-23 10:08:25 +0000 |
|---|---|---|
| committer | Miguel Ojeda <ojeda@kernel.org> | 2026-04-03 11:57:35 +0200 |
| commit | 0c0695a9d8c97f63d71dc890faa6999eef728f57 (patch) | |
| tree | a847d1b37cb93e4947a3b14746a60a91a30de23d /rust | |
| parent | 0a51b384e0decfe9dfe65d721a5e9cd39cabc152 (diff) | |
| download | linux-next-history-0c0695a9d8c97f63d71dc890faa6999eef728f57.tar.gz | |
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>
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/kernel/clk.rs | 7 |
1 files changed, 7 insertions, 0 deletions
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. /// |
