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.
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
rust/kernel/clk.rs | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
index 1e6c8c42fb3a321951e275101848b35e1ae5c2a8..0a290202da69669d670ddad2b6762a1d5f1d912e 100644
--- a/rust/kernel/clk.rs
+++ b/rust/kernel/clk.rs
@@ -129,6 +129,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.
///
--
2.51.0.915.g61a8936c21-goog
On 10/20/25 11:35 AM, Alice Ryhl wrote: > 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. > > Signed-off-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Danilo Krummrich <dakr@kernel.org>
On 20-10-25, 09:35, Alice Ryhl wrote:
> 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.
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
> rust/kernel/clk.rs | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
> index 1e6c8c42fb3a321951e275101848b35e1ae5c2a8..0a290202da69669d670ddad2b6762a1d5f1d912e 100644
> --- a/rust/kernel/clk.rs
> +++ b/rust/kernel/clk.rs
> @@ -129,6 +129,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.
> ///
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
On Wed, Oct 22, 2025 at 09:21:38AM +0530, Viresh Kumar wrote:
> On 20-10-25, 09:35, Alice Ryhl wrote:
> > 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.
> >
> > Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> > ---
> > rust/kernel/clk.rs | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
> > index 1e6c8c42fb3a321951e275101848b35e1ae5c2a8..0a290202da69669d670ddad2b6762a1d5f1d912e 100644
> > --- a/rust/kernel/clk.rs
> > +++ b/rust/kernel/clk.rs
> > @@ -129,6 +129,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.
> > ///
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
I'm guessing this means you want me to take it through drm-rust? See
what I put in the cover letter about choice of tree.
Alice
On 22-10-25, 08:19, Alice Ryhl wrote: > I'm guessing this means you want me to take it through drm-rust? See > what I put in the cover letter about choice of tree. I was expecting Stephen to pick it up directly. -- viresh
On Wed, Oct 22, 2025 at 03:03:26PM +0530, Viresh Kumar wrote: > On 22-10-25, 08:19, Alice Ryhl wrote: > > I'm guessing this means you want me to take it through drm-rust? See > > what I put in the cover letter about choice of tree. > > I was expecting Stephen to pick it up directly. Ah, that's fine, thanks. Alice
© 2016 - 2026 Red Hat, Inc.