rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Igor Korotin <igor.korotin.linux@gmail.com>
To: Danilo Krummrich <dakr@kernel.org>
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>,
	"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 v5 3/3] samples: rust: add Rust I2C sample driver
Date: Sat, 27 Sep 2025 19:20:52 +0100	[thread overview]
Message-ID: <10637103-7e15-406a-8e9c-0eee3c5c4922@gmail.com> (raw)
In-Reply-To: <DCQ9K980YX1W.HZIQI6S5MST9@kernel.org>

Hello Danilo

On 9/11/2025 9:46 PM, Danilo Krummrich wrote:
> On Thu Sep 11, 2025 at 5:50 PM CEST, Igor Korotin wrote:
>> +// 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>;
> 
> Not a huge fan of this type alias, but up to you. :)

I literally just unwrapped module_driver! macro to get to the init 
function.
This type was part of that macro. I do not see it necessary, so I'll 
remove it
in the next drop.
  >> +
>> +                i2c::Registration::new(adapter.as_ref(), &BOARD_INFO)
> 
> Does i2c_new_client_device() grab a reference count of the adapter? If not, you
> have to store an ARef<I2cAdapter> within your i2c::Registration as well.

Well, as far as I traced the C code, `adapter->dev` is a 
`client->dev->parent`. Inside of the i2c_new_client_device the new 
created client device is being registered and as part of this 
registration device's parent reference count is being incremented.

A big thanks for the review and comments.

Regards
Igor

      reply	other threads:[~2025-09-27 18:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11 15:47 [PATCH v5 0/3] rust: i2c: Add basic I2C driver abstractions Igor Korotin
2025-09-11 15:49 ` [PATCH v5 1/3] rust: i2c: add basic I2C device and " Igor Korotin
2025-09-11 19:24   ` Daniel Almeida
2025-09-11 20:23   ` Danilo Krummrich
2025-09-11 15:50 ` [PATCH v5 2/3] rust: i2c: add manual I2C device creation abstractions Igor Korotin
2025-09-11 20:34   ` Danilo Krummrich
2025-09-27 16:43     ` Igor Korotin
2025-09-11 15:50 ` [PATCH v5 3/3] samples: rust: add Rust I2C sample driver Igor Korotin
2025-09-11 20:46   ` Danilo Krummrich
2025-09-27 18:20     ` Igor Korotin [this message]

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=10637103-7e15-406a-8e9c-0eee3c5c4922@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=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;
as well as URLs for NNTP newsgroup(s).