[PATCH v1 4/4] samples: rust: show ACPI ID-table in I2C sample driver

From: Igor Korotin
Date: Thu Jun 26 2025 - 13:57:52 EST


Add an `acpi_device_table!` example and set
`SampleDriver::ACPI_ID_TABLE` to demonstrate ACPI usage.

Depends-on: <20250620152425.285683-1-igor.korotin.linux@xxxxxxxxx>
Signed-off-by: Igor Korotin <igor.korotin.linux@xxxxxxxxx>
---
samples/rust/rust_driver_i2c.rs | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/samples/rust/rust_driver_i2c.rs b/samples/rust/rust_driver_i2c.rs
index 7c5def930fe0..98bda18fd098 100644
--- a/samples/rust/rust_driver_i2c.rs
+++ b/samples/rust/rust_driver_i2c.rs
@@ -2,12 +2,19 @@

//! Rust I2C driver sample.

-use kernel::{c_str, device::Core, i2c, of, prelude::*, types::ARef};
+use kernel::{acpi, c_str, device::Core, i2c, of, prelude::*, types::ARef};

struct SampleDriver {
pdev: ARef<i2c::Device>,
}

+kernel::acpi_device_table! {
+ ACPI_TABLE,
+ MODULE_ACPI_TABLE,
+ <SampleDriver as i2c::Driver>::IdInfo,
+ [(acpi::DeviceId::new(b"TST0001"), 0)]
+}
+
kernel::i2c_device_table! {
I2C_TABLE,
MODULE_I2C_TABLE,
@@ -25,6 +32,7 @@ struct SampleDriver {
impl i2c::Driver for SampleDriver {
type IdInfo = u32;

+ const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);
const I2C_ID_TABLE: Option<i2c::IdTable<Self::IdInfo>> = Some(&I2C_TABLE);
const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);

--
2.43.0