[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DCBSZC9IDT4L.SPHF4KVM5KEW@kernel.org>
Date: Mon, 25 Aug 2025 22:49:31 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Daniel Almeida" <daniel.almeida@...labora.com>, "Miguel Ojeda"
<ojeda@...nel.org>, "Alex Gaynor" <alex.gaynor@...il.com>, "Boqun Feng"
<boqun.feng@...il.com>, "Gary Guo" <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>, "Andreas
Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
"Trevor Gross" <tmgross@...ch.edu>, "Danilo Krummrich" <dakr@...nel.org>,
"Greg Kroah-Hartman" <gregkh@...uxfoundation.org>
Cc: <linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>,
<linux-usb@...r.kernel.org>
Subject: Re: [PATCH 1/2] rust: usb: add basic USB abstractions
On Mon Aug 25, 2025 at 8:18 PM CEST, Daniel Almeida wrote:
> +impl DeviceId {
> + /// Equivalent to C's `USB_DEVICE` macro.
> + pub const fn from_id(vendor: u16, product: u16) -> Self {
> + Self(bindings::usb_device_id {
> + 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() }
You can avoid this usage of `unsafe` with this patch series:
https://lore.kernel.org/all/20250814093046.2071971-1-lossin@kernel.org
I'd like to avoid introducing any new one of these.
---
Cheers,
Benno
> + })
> + }
Powered by blists - more mailing lists