File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,10 @@ use core::ptr;
30
30
///
31
31
/// # Invariants
32
32
///
33
- /// The pointer stored in `Self` is non-null and valid for the lifetime of the `ARef` instance. In
34
- /// particular, the `ARef` instance owns an increment on the underlying object’s reference count.
33
+ /// A `Device` instance represents a valid `struct device` created by the C portion of the kernel.
34
+ ///
35
+ /// Instances of this type are always reference-counted, that is, a call to `get_device` ensures
36
+ /// that the allocation remains valid at least until the matching call to `put_device`.
35
37
///
36
38
/// `bindings::device::release` is valid to be called from any thread, hence `ARef<Device>` can be
37
39
/// dropped from any thread.
@@ -58,7 +60,8 @@ impl Device {
58
60
// CAST: `Self` is a `repr(transparent)` wrapper around `bindings::device`.
59
61
let ptr = ptr. cast :: < Self > ( ) ;
60
62
61
- // SAFETY: By the safety requirements, ptr is valid.
63
+ // SAFETY: `ptr` is valid by the safety requirements of this function. By the above call to
64
+ // `bindings::get_device` we also own a reference to the underlying `struct device`.
62
65
unsafe { ARef :: from_raw ( ptr:: NonNull :: new_unchecked ( ptr) ) }
63
66
}
64
67
You can’t perform that action at this time.
0 commit comments