Thread (11 messages) 11 messages, 2 authors, 2025-11-11

Re: [PATCH v7 4/4] samples: rust: add Rust I2C client registration sample

From: "Danilo Krummrich" <dakr@kernel.org>
Date: 2025-11-11 08:21:03
Also in: linux-i2c, lkml

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. :)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help