summaryrefslogtreecommitdiffstats
path: root/rust/kernel/platform.rs
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2025-03-14 17:09:06 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-03-17 08:04:25 +0100
commit7b948a2af6b5d64a25c14da8f63d8084ea527cd9 (patch)
tree86379ff1cf83282fefb7ff530dfb7b8d2b650400 /rust/kernel/platform.rs
parent4d032779ab321baa1a430ff27791e5e0c98a0c2f (diff)
downloadlinux-stable-7b948a2af6b5d64a25c14da8f63d8084ea527cd9.tar.gz
linux-stable-7b948a2af6b5d64a25c14da8f63d8084ea527cd9.tar.bz2
linux-stable-7b948a2af6b5d64a25c14da8f63d8084ea527cd9.zip
rust: pci: fix unrestricted &mut pci::Device
As by now, pci::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 pci::Device as pub struct Device<Ctx: DeviceContext = Normal>( Opaque<bindings::pci_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 pci::Device<Core>. Consequently, we make this type accessible in bus callbacks only. Arbitrary references taken by the driver are still of type ARef<pci::Device> and hence don't provide access to methods that are reserved for bus callbacks. Fixes: 1bd8b6b2c5d3 ("rust: pci: add basic PCI device / driver abstractions") Reviewed-by: Benno Lossin <benno.lossin@proton.me> Signed-off-by: Danilo Krummrich <dakr@kernel.org> Acked-by: Boqun Feng <boqun.feng@gmail.com> Link: https://lore.kernel.org/r/20250314160932.100165-4-dakr@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'rust/kernel/platform.rs')
0 files changed, 0 insertions, 0 deletions