samples/rust/rust_soc.rs
Source file repositories/reference/linux-study-clean/samples/rust/rust_soc.rs
File Facts
- System
- Linux kernel
- Corpus path
samples/rust/rust_soc.rs- Extension
.rs- Size
- 2156 bytes
- Lines
- 81
- 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 SampleSocDriver
Annotated Snippet
struct SampleSocDriver {
pdev: ARef<platform::Device>,
#[pin]
_dev_reg: soc::Registration,
}
kernel::of_device_table!(
OF_TABLE,
MODULE_OF_TABLE,
<SampleSocDriver as platform::Driver>::IdInfo,
[(of::DeviceId::new(c"test,rust-device"), ())]
);
kernel::acpi_device_table!(
ACPI_TABLE,
MODULE_ACPI_TABLE,
<SampleSocDriver as platform::Driver>::IdInfo,
[(acpi::DeviceId::new(c"LNUXBEEF"), ())]
);
impl platform::Driver for SampleSocDriver {
type IdInfo = ();
type Data<'bound> = Self;
const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);
fn probe<'bound>(
pdev: &'bound platform::Device<Core<'_>>,
_info: Option<&'bound Self::IdInfo>,
) -> impl PinInit<Self, Error> + 'bound {
dev_dbg!(pdev, "Probe Rust SoC driver sample.\n");
let pdev = pdev.into();
pin_init_scope(move || {
let machine = CString::try_from(c"My cool ACME15 dev board")?;
let family = CString::try_from(c"ACME")?;
let revision = CString::try_from(c"1.2")?;
let serial_number = CString::try_from(c"12345")?;
let soc_id = CString::try_from(c"ACME15")?;
let attr = soc::Attributes {
machine: Some(machine),
family: Some(family),
revision: Some(revision),
serial_number: Some(serial_number),
soc_id: Some(soc_id),
};
Ok(try_pin_init!(SampleSocDriver {
pdev: pdev,
_dev_reg <- soc::Registration::new(attr),
}? Error))
})
}
}
kernel::module_platform_driver! {
type: SampleSocDriver,
name: "rust_soc",
authors: ["Matthew Maurer"],
description: "Rust SoC Driver",
license: "GPL",
}
Annotation
- Detected declarations: `struct SampleSocDriver`.
- 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.