mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Igor Korotin <igor.korotin.linux@gmail.com>
To: Daniel Almeida <daniel.almeida@collabora.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Asahi Lina" <lina+kernel@asahilina.net>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Alex Hung" <alex.hung@amd.com>,
	"Tamir Duberstein" <tamird@gmail.com>,
	"Xiangfei Ding" <dingxiangfei2009@gmail.com>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	linux-i2c@vger.kernel.org
Subject: Re: [PATCH v4 3/3] samples: rust: add Rust I2C sample driver
Date: Tue, 9 Sep 2025 18:55:52 +0100	[thread overview]
Message-ID: <dd798632-1865-464d-8a02-f8d9e20a16b6@gmail.com> (raw)
In-Reply-To: <C5AFA553-6EB1-453E-B396-DD19139E7228@collabora.com>

Hello Daniel

On 8/27/2025 8:38 PM, Daniel Almeida wrote:
>> +    }
>> +}
>> +
>> +impl Drop for SampleDriver {
>> +    fn drop(&mut self) {
>> +        dev_dbg!(self.pdev.as_ref(), "Remove Rust I2C driver sample.\n");
>> +    }
>> +}
>> +
>> +// NOTE: The code below is expanded macro module_i2c_driver. It is not used here
>> +//       because we need to manually create an I2C client in `init()`. The macro
>> +//       hides `init()`, so to demo client creation on adapter SAMPLE_I2C_ADAPTER_INDEX
>> +//       we expand it by hand.
>> +type Ops<T> = kernel::i2c::Adapter<T>;
> 
> I am not sure I understand. How is a type alias related to module_i2c_driver at
> all?
> 
> Do all drivers need to introduce the alias above?
> 
>> +
>> +#[pin_data]
>> +struct DriverModule {
>> +    #[pin]
>> +    _driver: kernel::driver::Registration<Ops<SampleDriver>>,
>> +    _reg: i2c::Registration,
>> +}
> 
> I was expecting this to be ARef of something, most likely I2cClient?
> 
> This is where my knowledge of i2c drivers start to fall short, but others will
> probably chime in :)

You're right to mention this. This rust_driver_i2c is not the standard 
way of handling I2C devices. The idea was suggested by Danilo in the 
review of Patch v2: this driver merges an I2C driver sample with manual 
I2C device creation. The module creates a new I2cClient in its init 
function, and this new I2cClient is then probed by the SampleDriver.

In a normal driver it should be different. For example, let’s say 
there’s a platform device — the probe function for this platform device 
would create an I2cClient, and an appropriate I2C driver would then 
probe it.
Thanks for the review.

Best Regards
Igor

  reply	other threads:[~2025-09-09 17:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20 15:14 [PATCH v4 0/3] rust: i2c: Add basic I2C driver abstractions Igor Korotin
2025-08-20 15:19 ` [PATCH v4 1/3] rust: i2c: add basic I2C device and " Igor Korotin
2025-08-27 18:37   ` Daniel Almeida
2025-09-09 17:19     ` Igor Korotin
2025-09-09 17:53       ` Daniel Almeida
2025-09-09 18:19         ` Danilo Krummrich
2025-09-09 18:22           ` Daniel Almeida
2025-08-20 15:21 ` [PATCH v4 2/3] rust: i2c: add manual I2C device creation abstractions Igor Korotin
2025-08-27 19:23   ` Daniel Almeida
2025-08-20 15:23 ` [PATCH v4 3/3] samples: rust: add Rust I2C sample driver Igor Korotin
2025-08-27 19:38   ` Daniel Almeida
2025-09-09 17:55     ` Igor Korotin [this message]
2025-09-09 18:34       ` Danilo Krummrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dd798632-1865-464d-8a02-f8d9e20a16b6@gmail.com \
    --to=igor.korotin.linux@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=alex.hung@amd.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dingxiangfei2009@gmail.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=lina+kernel@asahilina.net \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@gmail.com \
    --cc=tmgross@umich.edu \
    --cc=viresh.kumar@linaro.org \
    --cc=wedsonaf@gmail.com \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®