[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DDYEMP51XH3M.2XLXW0BRQVQVV@kernel.org>
Date: Sun, 02 Nov 2025 19:02:02 +0100
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Igor Korotin" <igor.korotin.linux@...il.com>
Cc: "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
 <alex.gaynor@...il.com>, "Wolfram Sang" <wsa+renesas@...g-engineering.com>,
 "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo" <gary@...yguo.net>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>, "Benno Lossin"
 <lossin@...nel.org>, "Andreas Hindborg" <a.hindborg@...nel.org>, "Alice
 Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>, "Greg
 Kroah-Hartman" <gregkh@...uxfoundation.org>, "Viresh Kumar"
 <viresh.kumar@...aro.org>, "Asahi Lina" <lina+kernel@...hilina.net>,
 "Wedson Almeida Filho" <wedsonaf@...il.com>, "Alex Hung"
 <alex.hung@....com>, "Tamir Duberstein" <tamird@...il.com>, "Xiangfei Ding"
 <dingxiangfei2009@...il.com>, <linux-kernel@...r.kernel.org>,
 <rust-for-linux@...r.kernel.org>, <linux-i2c@...r.kernel.org>
Subject: Re: [PATCH v6 2/3] rust: i2c: Add basic I2C driver abstractions
On Sun Nov 2, 2025 at 6:45 PM CET, Igor Korotin wrote:
> Hello Danilo
>
> On 10/27/2025 10:00 PM, Danilo Krummrich wrote:
>> It's called from other drivers (e.g. DRM drivers [1] or network drivers [2])
>> that are bound to some bus device themselves, e.g. a platform device or a PCI
>> device.
>> 
>> This is the device that we can give to i2c:Registration::new() and use for the
>> internal call to devres.
>
> After the recent change where i2c::Registration::new() returns impl 
> PinInit<Devres<Self>, Error> instead of Result<Self>, I’m unsure how to 
> adapt the Rust I2C sample driver. The sample doesn’t have a parent 
> device available.
Indeed, and that's a good thing that this doesn't work now. :)
I think the best course of action is to make the sample driver closer to a real
driver.
For this you can do what the debugfs sample (samples/rust/rust_debugfs.rs) does
and use a platform driver with either ACPI
	kernel::acpi_device_table!(
	    ACPI_TABLE,
	    MODULE_ACPI_TABLE,
	    <RustDebugFs as platform::Driver>::IdInfo,
	    [(acpi::DeviceId::new(c_str!("LNUXBEEF")), ())]
	);
or OF
	kernel::of_device_table!(
	    OF_TABLE,
	    MODULE_OF_TABLE,
	    <SampleDriver as platform::Driver>::IdInfo,
	    [(of::DeviceId::new(c_str!("test,rust-device")), Info(42))]
	);
and then create an i2c::Registration from platform::Driver::probe().
- Danilo
Powered by blists - more mailing lists