pub struct Data<T, U, V> { /* private fields */ }
Expand description
Device data.
When a device is removed (for whatever reason, for example, because the device was unplugged or because the user decided to unbind the driver), the driver is given a chance to clean its state up, and all io resources should ideally not be used anymore.
However, the device data is reference-counted because other subsystems hold pointers to it. So some device state must be freed and not used anymore, while others must remain accessible.
This struct separates the device data into three categories:
- Registrations: are destroyed when the device is removed, but before the io resources become inaccessible.
- Io resources: are available until the device is removed.
- General data: remain available as long as the ref count is nonzero.
This struct implements the DeviceRemoval
trait so that it can clean resources up even if not
explicitly called by the device drivers.
Implementations
sourceimpl<T, U, V> Data<T, U, V>
impl<T, U, V> Data<T, U, V>
sourcepub fn try_new(
registrations: T,
resources: U,
general: V,
name: &'static CStr,
key1: &'static LockClassKey,
key2: &'static LockClassKey
) -> Result<Pin<UniqueRef<Self>>>
pub fn try_new(
registrations: T,
resources: U,
general: V,
name: &'static CStr,
key1: &'static LockClassKey,
key2: &'static LockClassKey
) -> Result<Pin<UniqueRef<Self>>>
Creates a new instance of Data
.
It is recommended that the [new_device_data
] macro be used as it automatically creates
the lock classes.
sourcepub fn resources(&self) -> Option<RevocableGuard<'_, U>>
pub fn resources(&self) -> Option<RevocableGuard<'_, U>>
Returns the resources if they’re still available.
sourcepub fn registrations(&self) -> Option<RevocableMutexGuard<'_, T>>
pub fn registrations(&self) -> Option<RevocableMutexGuard<'_, T>>
Returns the locked registrations if they’re still available.
Trait Implementations
sourceimpl<T, U, V> DeviceRemoval for Data<T, U, V>
impl<T, U, V> DeviceRemoval for Data<T, U, V>
sourcefn device_remove(&self)
fn device_remove(&self)
Cleans resources up when the device is removed. Read more
Auto Trait Implementations
impl<T, U, V> !RefUnwindSafe for Data<T, U, V>
impl<T, U, V> Send for Data<T, U, V> where
T: Send,
U: Send,
V: Send,
impl<T, U, V> Sync for Data<T, U, V> where
T: Send,
U: Send + Sync,
V: Sync,
impl<T, U, V> !Unpin for Data<T, U, V>
impl<T, U, V> UnwindSafe for Data<T, U, V> where
T: UnwindSafe,
U: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more