diff options
author | Daniel Almeida <daniel.almeida@collabora.com> | 2025-07-29 14:31:41 -0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2025-08-10 21:09:34 +0100 |
commit | 9a200cbdb54349909a42b45379e792e4b39dd223 (patch) | |
tree | fe817b3d51a7b80e6c8f1f5b7a70034f5603e3d3 /rust/kernel | |
parent | f7fbf3091f4cc4133574852f655593e1613d1af0 (diff) |
rust: regulator: implement Send and Sync for Regulator<T>
Sending a &Regulator<T> to another thread is safe, as the regulator core
will properly handle the locking for us. Additionally, there are no
restrictions that prevents sending a Regulator<T> to another thread.
Given these two facts, implement Send and Sync.
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://patch.msgid.link/20250729-regulator-send-sync-v1-2-8bcbd546b940@collabora.com
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'rust/kernel')
-rw-r--r-- | rust/kernel/regulator.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/rust/kernel/regulator.rs b/rust/kernel/regulator.rs index d56aa229e838..704147e18bfc 100644 --- a/rust/kernel/regulator.rs +++ b/rust/kernel/regulator.rs @@ -398,6 +398,14 @@ impl<T: RegulatorState> Drop for Regulator<T> { } } +// SAFETY: It is safe to send a `Regulator<T>` across threads. In particular, a +// Regulator<T> can be dropped from any thread. +unsafe impl<T: RegulatorState> Send for Regulator<T> {} + +// SAFETY: It is safe to send a &Regulator<T> across threads because the C side +// handles its own locking. +unsafe impl<T: RegulatorState> Sync for Regulator<T> {} + /// A voltage. /// /// This type represents a voltage value in microvolts. |