mirror of
https://github.com/torvalds/linux.git
synced 2026-12-05 04:44:03 +00:00
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Signed-off-by: Mark Brown <[email protected]>
This commit is contained in:
committed by
Mark Brown
parent
f7fbf3091f
commit
9a200cbdb5
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user