diff --git a/rust/kernel/usb.rs b/rust/kernel/usb.rs index 8899e7520b58..955fd93b6f52 100644 --- a/rust/kernel/usb.rs +++ b/rust/kernel/usb.rs @@ -340,14 +340,13 @@ impl AsRef> for Interface { } } -impl AsRef> for Interface { - fn as_ref(&self) -> &Device { - // SAFETY: `self.as_raw()` is valid by the type invariants. For a valid interface, - // the helper should always return a valid USB device pointer. +impl AsRef for Interface { + fn as_ref(&self) -> &Device { + // SAFETY: `self.as_raw()` is valid by the type invariants. let usb_dev = unsafe { bindings::interface_to_usbdev(self.as_raw()) }; - // SAFETY: The helper returns a valid interface pointer that shares the - // same `DeviceContext`. + // SAFETY: For a valid `struct usb_interface` pointer, the above call to + // `interface_to_usbdev()` guarantees to return a valid pointer to a `struct usb_device`. unsafe { &*(usb_dev.cast()) } } }