aboutsummaryrefslogtreecommitdiffstats
path: root/samples/rust/rust_driver_pci.rs
diff options
context:
space:
mode:
authorDanilo Krummrich <[email protected]>2025-03-14 16:09:07 +0000
committerGreg Kroah-Hartman <[email protected]>2025-03-17 07:04:25 +0000
commit4d320e30ee04c25c660eca2bb33e846ebb71a79a (patch)
tree57a65743c3a8b5ccbeff41420267ce9bc1b3be51 /samples/rust/rust_driver_pci.rs
parentrust: pci: fix unrestricted &mut pci::Device (diff)
downloadkernel-4d320e30ee04c25c660eca2bb33e846ebb71a79a.tar.gz
kernel-4d320e30ee04c25c660eca2bb33e846ebb71a79a.zip
rust: platform: fix unrestricted &mut platform::Device
As by now, platform::Device is implemented as: #[derive(Clone)] pub struct Device(ARef<device::Device>); This may be convenient, but has the implication that drivers can call device methods that require a mutable reference concurrently at any point of time. Instead define platform::Device as pub struct Device<Ctx: DeviceContext = Normal>( Opaque<bindings::platform_dev>, PhantomData<Ctx>, ); and manually implement the AlwaysRefCounted trait. With this we can implement methods that should only be called from bus callbacks (such as probe()) for platform::Device<Core>. Consequently, we make this type accessible in bus callbacks only. Arbitrary references taken by the driver are still of type ARef<platform::Device> and hence don't provide access to methods that are reserved for bus callbacks. Fixes: 683a63befc73 ("rust: platform: add basic platform device / driver abstractions") Reviewed-by: Benno Lossin <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Acked-by: Boqun Feng <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'samples/rust/rust_driver_pci.rs')
0 files changed, 0 insertions, 0 deletions