summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-07-26 22:56:54 +0100
committerMark Brown <broonie@kernel.org>2026-07-26 22:56:54 +0100
commite7c0c71ccd3f661f45d0c6f462c5be530a52e961 (patch)
treeeb83ec7d94453fd80c8ab14eb387b0f590f06b48 /rust
parent38676d87eaa68ec0931df86e7e18ae9c93fcfc7e (diff)
parentcae6572efdd0948a7b676b3c5a7cebf9483bc781 (diff)
downloadlinux-next-e7c0c71ccd3f661f45d0c6f462c5be530a52e961.tar.gz
linux-next-e7c0c71ccd3f661f45d0c6f462c5be530a52e961.zip
Merge branch 'usb-next' of https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
Diffstat (limited to 'rust')
-rw-r--r--rust/kernel/usb.rs35
1 files changed, 14 insertions, 21 deletions
diff --git a/rust/kernel/usb.rs b/rust/kernel/usb.rs
index 7aff0c82d0af..6dfdd64dd617 100644
--- a/rust/kernel/usb.rs
+++ b/rust/kernel/usb.rs
@@ -24,11 +24,8 @@ use crate::{
};
use core::{
marker::PhantomData,
- mem::{
- offset_of,
- MaybeUninit, //
- },
- ptr::NonNull,
+ mem::offset_of,
+ ptr::NonNull, //
};
/// An adapter for the registration of USB drivers.
@@ -130,8 +127,7 @@ impl DeviceId {
match_flags: bindings::USB_DEVICE_ID_MATCH_DEVICE as u16,
idVendor: vendor,
idProduct: product,
- // SAFETY: It is safe to use all zeroes for the other fields of `usb_device_id`.
- ..unsafe { MaybeUninit::zeroed().assume_init() }
+ ..pin_init::zeroed()
})
}
@@ -143,8 +139,7 @@ impl DeviceId {
idProduct: product,
bcdDevice_lo: bcd_lo,
bcdDevice_hi: bcd_hi,
- // SAFETY: It is safe to use all zeroes for the other fields of `usb_device_id`.
- ..unsafe { MaybeUninit::zeroed().assume_init() }
+ ..pin_init::zeroed()
})
}
@@ -155,8 +150,7 @@ impl DeviceId {
bDeviceClass: class,
bDeviceSubClass: subclass,
bDeviceProtocol: protocol,
- // SAFETY: It is safe to use all zeroes for the other fields of `usb_device_id`.
- ..unsafe { MaybeUninit::zeroed().assume_init() }
+ ..pin_init::zeroed()
})
}
@@ -167,8 +161,7 @@ impl DeviceId {
bInterfaceClass: class,
bInterfaceSubClass: subclass,
bInterfaceProtocol: protocol,
- // SAFETY: It is safe to use all zeroes for the other fields of `usb_device_id`.
- ..unsafe { MaybeUninit::zeroed().assume_init() }
+ ..pin_init::zeroed()
})
}
@@ -180,8 +173,7 @@ impl DeviceId {
idVendor: vendor,
idProduct: product,
bInterfaceClass: class,
- // SAFETY: It is safe to use all zeroes for the other fields of `usb_device_id`.
- ..unsafe { MaybeUninit::zeroed().assume_init() }
+ ..pin_init::zeroed()
})
}
@@ -193,8 +185,7 @@ impl DeviceId {
idVendor: vendor,
idProduct: product,
bInterfaceProtocol: protocol,
- // SAFETY: It is safe to use all zeroes for the other fields of `usb_device_id`.
- ..unsafe { MaybeUninit::zeroed().assume_init() }
+ ..pin_init::zeroed()
})
}
@@ -206,8 +197,7 @@ impl DeviceId {
idVendor: vendor,
idProduct: product,
bInterfaceNumber: number,
- // SAFETY: It is safe to use all zeroes for the other fields of `usb_device_id`.
- ..unsafe { MaybeUninit::zeroed().assume_init() }
+ ..pin_init::zeroed()
})
}
@@ -227,8 +217,7 @@ impl DeviceId {
bInterfaceClass: class,
bInterfaceSubClass: subclass,
bInterfaceProtocol: protocol,
- // SAFETY: It is safe to use all zeroes for the other fields of `usb_device_id`.
- ..unsafe { MaybeUninit::zeroed().assume_init() }
+ ..pin_init::zeroed()
})
}
}
@@ -393,6 +382,7 @@ impl<Ctx: device::DeviceContext> AsRef<Device> for Interface<Ctx> {
// SAFETY: Instances of `Interface` are always reference-counted.
unsafe impl AlwaysRefCounted for Interface {
+ #[inline]
fn inc_ref(&self) {
// SAFETY: The invariants of `Interface` guarantee that `self.as_raw()`
// returns a valid `struct usb_interface` pointer, for which we will
@@ -400,6 +390,7 @@ unsafe impl AlwaysRefCounted for Interface {
unsafe { bindings::usb_get_intf(self.as_raw()) };
}
+ #[inline]
unsafe fn dec_ref(obj: NonNull<Self>) {
// SAFETY: The safety requirements guarantee that the refcount is non-zero.
unsafe { bindings::usb_put_intf(obj.cast().as_ptr()) }
@@ -444,6 +435,7 @@ kernel::impl_device_context_into_aref!(Device);
// SAFETY: Instances of `Device` are always reference-counted.
unsafe impl AlwaysRefCounted for Device {
+ #[inline]
fn inc_ref(&self) {
// SAFETY: The invariants of `Device` guarantee that `self.as_raw()`
// returns a valid `struct usb_device` pointer, for which we will
@@ -451,6 +443,7 @@ unsafe impl AlwaysRefCounted for Device {
unsafe { bindings::usb_get_dev(self.as_raw()) };
}
+ #[inline]
unsafe fn dec_ref(obj: NonNull<Self>) {
// SAFETY: The safety requirements guarantee that the refcount is non-zero.
unsafe { bindings::usb_put_dev(obj.cast().as_ptr()) }