An initial set of Linux kernel patches were posted this week for allowing USB Rust kernel drivers to be developed for Linux.
Daniel Almeida of Collabora posted the initial set of patches to begin hashing out the Rust USB abstractions for the Linux kernel.
Almedia explained on the patch series:
“This adds initial support for USB Rust drivers, not only because I see a widespread use of module_usb_driver() in media (which is a subsystem I aim to support) but also because I want to learn about USB in general and this is a nice opportunity to start doing so.
I tried to keep things as consistent with pci.rs and platform.rs as possible and tested it by manually binding a device (i.e.: my Logitech mouse) to the sample driver via:
/sys/bus/usb/drivers/rust_driver_usb/new_id
This initial patch is therefore comprised of the same patterns that are known to work for pci and platform already.
Physically disconnecting the device also worked, i.e.: nothing bad showed up in dmesg.”
This is just the very initial patches with further revisions expected before the Rust USB abstractions would be upstreamed into the Linux kernel. In current form usb.rs is less than five hundred lines of new code.
These patches are also just the very initial USB device driver abstractions with further work then needed for extending it out to cover USB media drivers and other possible USB driver scenarios within the Rust programming language. In addition to the abstractions is also a sample Rust USB driver in less than 50 lines of Rust code.