lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aGgyg5SEHU7-G70W@cassiopeiae>
Date: Fri, 4 Jul 2025 21:58:59 +0200
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 v2 4/4] samples: rust: add Rust manual I2C device
 creation sample

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 })
> +    }
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ