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 v7 1/4] rust: i2c: add basic I2C device and driver abstractions
Date: Tue, 11 Nov 2025 19:10:11 +1100 [thread overview]
Message-ID: <DE5POG7G08QG.LT9YJCA0IN11@kernel.org> (raw)
In-Reply-To: <20251110112507.50525-1-igor.korotin.linux@gmail.com>
On Mon Nov 10, 2025 at 10:25 PM AEDT, Igor Korotin wrote:
> diff --git a/rust/kernel/i2c.rs b/rust/kernel/i2c.rs
> new file mode 100644
> index 000000000000..41ef7c65c555
> --- /dev/null
> +++ b/rust/kernel/i2c.rs
> @@ -0,0 +1,425 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +//! I2C Driver subsystem
> +
> +// I2C Driver abstractions.
> +use crate::{
> + acpi, container_of, device,
> + device_id::{RawDeviceId, RawDeviceIdIndex},
> + driver,
> + error::*,
> + of,
> + prelude::*,
> + types::{AlwaysRefCounted, Opaque},
> +};
> +
> +use core::{marker::PhantomData, ptr::NonNull};
Please use kernel "vertical style" [1].
[1] https://docs.kernel.org/rust/coding-guidelines.html#imports
Please also run ./scripts/checkpatch.pl on all patches, there are a few warnings
to address.
> +
> +/// An I2C device id table.
> +#[repr(transparent)]
> +#[derive(Clone, Copy)]
> +pub struct DeviceId(bindings::i2c_device_id);
> +
> +impl DeviceId {
> + const I2C_NAME_SIZE: usize = 20;
> +
> + /// Create a new device id from an I2C 'id' string.
> + #[inline(always)]
> + pub const fn new(id: &'static CStr) -> Self {
> + build_assert!(
> + id.len_with_nul() <= Self::I2C_NAME_SIZE,
> + "ID exceeds 20 bytes"
> + );
> + let src = id.as_bytes_with_nul();
> + // Replace with `bindings::acpi_device_id::default()` once stabilized for `const`.
> + // SAFETY: FFI type is valid to be zero-initialized.
> + let mut i2c: bindings::i2c_device_id = unsafe { core::mem::zeroed() };
You can use pin_init::zeroed() for this.
> + let mut i = 0;
> + while i < src.len() {
> + i2c.name[i] = src[i];
> + i += 1;
> + }
> +
> + Self(i2c)
> + }
> +}
next prev parent reply other threads:[~2025-11-11 8:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 11:24 [PATCH v7 0/4] rust: i2c: Add basic I2C driver abstractions Igor Korotin
2025-11-10 11:25 ` [PATCH v7 1/4] rust: i2c: add basic I2C device and " Igor Korotin
2025-11-11 8:10 ` Danilo Krummrich [this message]
2025-11-10 11:30 ` [PATCH v7 2/4] rust: i2c: add manual I2C device creation abstractions Igor Korotin
2025-11-11 8:14 ` Danilo Krummrich
2025-11-10 11:30 ` [PATCH v7 1/4] rust: i2c: add basic I2C device and driver abstractions Igor Korotin
2025-11-10 11:31 ` [PATCH v7 3/4] samples: rust: add Rust I2C sample driver Igor Korotin
2025-11-11 8:16 ` Danilo Krummrich
2025-11-10 11:31 ` [PATCH v7 4/4] samples: rust: add Rust I2C client registration sample Igor Korotin
2025-11-11 8:20 ` Danilo Krummrich
2025-11-11 8:05 ` [PATCH v7 0/4] rust: i2c: Add basic I2C driver abstractions 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=DE5POG7G08QG.LT9YJCA0IN11@kernel.org \
--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.