Re: [PATCH v7 4/4] samples: rust: add Rust I2C client registration sample
From: Danilo Krummrich
Date: Tue Nov 11 2025 - 03:25:17 EST
On Mon Nov 10, 2025 at 10:31 PM AEDT, Igor Korotin wrote:
> +impl platform::Driver for SampleDriver {
> + type IdInfo = ();
> + 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(
> + pdev: &platform::Device<device::Core>,
> + _info: Option<&Self::IdInfo>,
> + ) -> impl PinInit<Self, Error> {
> + pin_init::pin_init_scope(move || {
We probably don't need pin_init_scope() here.
> + dev_info!(
> + pdev.as_ref(),
> + "Probe Rust I2C Client registration sample.\n"
> + );
> +
> + Ok(kernel::try_pin_init!( Self {
> + parent_dev: pdev.into(),
> +
> + idev <- {
> + let adapter = i2c::I2cAdapter::get(SAMPLE_I2C_ADAPTER_INDEX)?;
> +
> + i2c::Registration::new(&adapter, &BOARD_INFO, pdev.as_ref())
> + }
> + }))
> + })
> + }
> +}
> +
> +#[pinned_drop]
> +impl PinnedDrop for SampleDriver {
> + fn drop(self: Pin<&mut Self>) {
> + dev_info!(
> + self.parent_dev.as_ref(),
> + "Remove Rust Platform driver for I2C Client registration sample.\n"
> + );
> + }
Let's use unbind() here as well.
(Yes, the existing samples need to be updated. :)