* Re: [PATCH RFC 0/2] rust: usb: abstractions towards the port of usbsevseg.c to Rust
[not found] <20260801-rust-usb_control_msg-v1-0-124cf21c82ee@wyliodrin.com>
@ 2026-08-01 2:23 ` Alrexandru Radovici
0 siblings, 0 replies; 2+ messages in thread
From: Alrexandru Radovici @ 2026-08-01 2:23 UTC (permalink / raw)
To: Alexandru Radovici, Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan
Cc: linux-kernel, linux-usb, rust-for-linux
On Sat Aug 1, 2026 at 2:59 AM EEST, Alexandru Radovici wrote:
Fixed some mistakes, will include them in v2:
- use `Duration` instead of `i32` for control functions timeout
- fix control function 0 value timeout from "for ever" to `USB_MAX_SYNCHRONOUS_TIMEOUT`
- add `#[inline]` to short functions
- use `u16::from_le` to read `wMaxPacketSize`
- rename `Generic` generic type to `Dir`
- impl `max_nak_rate` for `HostEndpoint<Bidirectional, Control>`
- make data `&mut [u8]` for `receive_control_message`
Alexandru
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH RFC 0/2] rust: usb: abstractions towards the port of usbsevseg.c to Rust
@ 2026-08-01 0:01 Alexandru Radovici
0 siblings, 0 replies; 2+ messages in thread
From: Alexandru Radovici @ 2026-08-01 0:01 UTC (permalink / raw)
To: Greg Kroah-Hartman, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan
Cc: linux-kernel, linux-usb, rust-for-linux, Alexandru Radovici
My end goal is to port the usbsevseg.c USB driver to Rust. That driver is
small enough to make a useful first target; the remaining piece it
needs is sysfs attribute support for USB devices, which I plan to send
separately.
Porting the driver requires:
- retrieving endpoints and sending control messages API (this series)
- enabling sysfs attributes API for USB devices (future patch)
These patches add the USB abstractions needed to port
drivers/usb/misc/usbsevseg.c to Rust: retrieving an interface's
endpoints, and sending and receiving control messages.
Patch 1 adds `AlternateEndpoint`, along with `AlternateSetting`
and the accessors needed to reach one. Patch 2 adds the
control transfer methods and the `Request` type describing a setup packet.
The part I would most like feedback on is the typestate design in patch
1. `HostEndpoint` is generic over a direction and a transfer type, both
sealed 1-ZST markers, so a function can require e.g.
`&HostEndpoint<In, Bulk>` and skip checking the descriptor itself. Control
endpoints get a `Bidirectional` marker rather than a direction, since
bit 7 of bEndpointAddress is ignored for them. I am not sure whether
this earns its complexity for the drivers we expect, or whether plain
run-time check would be better.
Only `as_control()`, `as_in()` and `as_out()` are implemented so far;
`as_bulk()`, `as_interrupt()` and `as_isochronous()` are skiped for now
as no current user needs them.
Signed-off-by: Alexandru Radovici <alexandru.radovici@wyliodrin.com>
---
Alexandru Radovici (2):
rust: usb: add endpoint abstraction
rust: usb: add control message send and receive
rust/kernel/usb.rs | 127 ++++++++++-
rust/kernel/usb/control.rs | 353 ++++++++++++++++++++++++++++++
rust/kernel/usb/endpoint.rs | 508 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 987 insertions(+), 1 deletion(-)
---
base-commit: 8ba098e6b6ff0db8edf28528d1552be261af30d4
change-id: 20260801-rust-usb_control_msg-ee34e002b818
Best regards,
--
Alexandru Radovici <alexandru.radovici@wyliodrin.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-01 2:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20260801-rust-usb_control_msg-v1-0-124cf21c82ee@wyliodrin.com>
2026-08-01 2:23 ` [PATCH RFC 0/2] rust: usb: abstractions towards the port of usbsevseg.c to Rust Alrexandru Radovici
2026-08-01 0:01 Alexandru Radovici
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®