mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
rust: platform: implement Sync for Device<Bound>
Implement Sync for Device<Bound> in addition to Device<Normal>. Device<Bound> uses the same underlying struct platform_device as Device<Normal>; Bound is a zero-sized type-state marker that does not affect thread safety. This is needed for drivers to store &'bound platform::Device<Bound> in their private data while remaining Send. Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Uwe Kleine-König <ukleinek@kernel.org> Tested-by: Dirk Behme <dirk.behme@de.bosch.com> Link: https://patch.msgid.link/20260525202921.124698-8-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
0b9a29c3a4
commit
a89111c00b
|
|
@ -565,3 +565,7 @@ unsafe impl Send for Device {}
|
|||
// SAFETY: `Device` can be shared among threads because all methods of `Device`
|
||||
// (i.e. `Device<Normal>) are thread safe.
|
||||
unsafe impl Sync for Device {}
|
||||
|
||||
// SAFETY: Same as `Device<Normal>` -- the underlying `struct platform_device` is the same;
|
||||
// `Bound` is a zero-sized type-state marker that does not affect thread safety.
|
||||
unsafe impl Sync for Device<device::Bound> {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user