All of lore.kernel.org
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: Igor Korotin <igor.korotin.linux@gmail.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>,
	"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 v2 4/4] samples: rust: add Rust manual I2C device creation sample
Date: Fri, 4 Jul 2025 21:58:59 +0200	[thread overview]
Message-ID: <aGgyg5SEHU7-G70W@cassiopeiae> (raw)
In-Reply-To: <20250704154345.1198721-1-igor.korotin.linux@gmail.com>

On Fri, Jul 04, 2025 at 04:43:41PM +0100, Igor Korotin wrote:
> +struct SampleDriver {
> +    _owned: i2c::DeviceOwned<Core>,
> +}
> +
> +const BOARD_INFO: i2c::I2cBoardInfo = i2c::I2cBoardInfo::new(c_str!("rust_driver_i2c"), 0x30);
> +
> +impl kernel::Module for SampleDriver {
> +    fn init(_module: &'static ThisModule) -> Result<Self> {
> +        pr_debug!("Probe Rust I2C device sample.\n");
> +
> +        let adapter = i2c::I2cAdapterRef::get(0).ok_or(EINVAL)?;
> +
> +        let device = i2c::DeviceOwned::<Core>::new(&adapter, &BOARD_INFO).ok_or(EINVAL)?;

This can't be device::Core, since the scope of device is not limited to I2C bus
callback. Also, device::Core dereferences to device::Bound, and device is also
not limited to scope where it can be guaranteed that the device is actually
bound.

It could be device::Normal, but as mentioned in the other thread, you're
thinking this too complicated. You really want t simple i2c::Registration type,
just like auxiliary::Registration. Please take a look at that instead.

> +        Ok(Self { _owned: device })
> +    }
> +}

      reply	other threads:[~2025-07-04 19:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-04 15:33 [PATCH v2 0/4] rust: i2c: Add basic I2C driver abstractions Igor Korotin
2025-07-04 15:36 ` [PATCH v2 1/4] rust: i2c: add basic I2C device and " Igor Korotin
2025-07-04 20:16   ` Danilo Krummrich
2025-07-07 10:28     ` Igor Korotin
2025-07-07 10:47       ` Miguel Ojeda
2025-07-07 11:23         ` Igor Korotin
2025-07-10 14:04     ` Igor Korotin
2025-07-10 14:46       ` Danilo Krummrich
2025-07-04 15:39 ` [PATCH v2 2/4] rust: i2c: add manual I2C device creation abstractions Igor Korotin
2025-07-04 19:54   ` Danilo Krummrich
2025-07-07 10:35     ` Igor Korotin
2025-07-07 11:20     ` Igor Korotin
2025-07-07 12:02       ` Danilo Krummrich
2025-07-07 14:31         ` Igor Korotin
2025-07-07 14:39           ` Danilo Krummrich
2025-07-04 15:41 ` [PATCH v2 3/4] samples: rust: add Rust I2C sample driver Igor Korotin
2025-07-04 15:43 ` [PATCH v2 4/4] samples: rust: add Rust manual I2C device creation sample Igor Korotin
2025-07-04 19:58   ` Danilo Krummrich [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=aGgyg5SEHU7-G70W@cassiopeiae \
    --to=dakr@kernel.org \
    --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=dingxiangfei2009@gmail.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=igor.korotin.linux@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.