Lines Matching +full:self +full:- +full:working
1 // SPDX-License-Identifier: GPL-2.0-only
5 //! This module provides bindings for working with faux devices in kernel modules.
19 /// `self.0` always holds a valid pointer to an initialized and registered [`struct faux_device`].
27 pub fn new(name: &CStr) -> Result<Self> { in new() argument
29 // - `name` is copied by this function into its own storage in new()
30 // - `faux_ops` is safe to leave NULL according to the C API in new()
36 Ok(Self(NonNull::new(dev).ok_or(ENODEV)?)) in new()
39 fn as_raw(&self) -> *mut bindings::faux_device { in as_raw()
40 self.0.as_ptr() in as_raw()
45 fn as_ref(&self) -> &device::Device { in as_ref()
48 unsafe { device::Device::as_ref(addr_of_mut!((*self.as_raw()).dev)) } in as_ref()
53 fn drop(&mut self) { in drop() argument
54 // SAFETY: `self.0` is a valid registered faux_device via our type invariants. in drop()
55 unsafe { bindings::faux_device_destroy(self.as_raw()) } in drop()
59 // SAFETY: The faux device API is thread-safe as guaranteed by the device core, as long as
60 // faux_device_destroy() is guaranteed to only be called once - which is guaranteed by our type not
64 // SAFETY: The faux device API is thread-safe as guaranteed by the device core, as long as
65 // faux_device_destroy() is guaranteed to only be called once - which is guaranteed by our type not