samples/rust/rust_driver_usb.rs
Source file repositories/reference/linux-study-clean/samples/rust/rust_driver_usb.rs
File Facts
- System
- Linux kernel
- Corpus path
samples/rust/rust_driver_usb.rs- Extension
.rs- Size
- 1371 bytes
- Lines
- 56
- Domain
- Support Tooling And Documentation
- Bucket
- samples
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
struct SampleDriverfunction Ok
Annotated Snippet
struct SampleDriver {
_intf: ARef<usb::Interface>,
}
kernel::usb_device_table!(
USB_TABLE,
MODULE_USB_TABLE,
<SampleDriver as usb::Driver>::IdInfo,
[(usb::DeviceId::from_id(0x1234, 0x5678), ()),]
);
impl usb::Driver for SampleDriver {
type IdInfo = ();
type Data<'bound> = Self;
const ID_TABLE: usb::IdTable<Self::IdInfo> = &USB_TABLE;
fn probe<'bound>(
intf: &'bound usb::Interface<Core<'_>>,
_id: &usb::DeviceId,
_info: &'bound Self::IdInfo,
) -> impl PinInit<Self, Error> + 'bound {
let dev: &device::Device<Core<'_>> = intf.as_ref();
dev_info!(dev, "Rust USB driver sample probed\n");
Ok(Self { _intf: intf.into() })
}
fn disconnect<'bound>(intf: &'bound usb::Interface<Core<'_>>, _data: Pin<&Self>) {
let dev: &device::Device<Core<'_>> = intf.as_ref();
dev_info!(dev, "Rust USB driver sample disconnected\n");
}
}
kernel::module_usb_driver! {
type: SampleDriver,
name: "rust_driver_usb",
authors: ["Daniel Almeida"],
description: "Rust USB driver sample",
license: "GPL v2",
}
Annotation
- Detected declarations: `struct SampleDriver`, `function Ok`.
- Atlas domain: Support Tooling And Documentation / samples.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.