All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Matthew Maurer" <mmaurer@google.com>,
	"Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"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>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v3 1/3] rust: Add soc_device support
Date: Wed, 14 Jan 2026 16:53:37 +0900	[thread overview]
Message-ID: <DFO5EMUQ33AP.2NM06WXNV5WH0@nvidia.com> (raw)
In-Reply-To: <CAGSQo0173bon2kGo5wGFXo-1x+LL1NpH376Z4GcshKaGVNLHXw@mail.gmail.com>

On Sat Dec 27, 2025 at 4:26 AM JST, Matthew Maurer wrote:
> On Tue, Dec 16, 2025 at 6:31 PM Alexandre Courbot <acourbot@nvidia.com> wrote:
>>
>> On Wed Dec 17, 2025 at 4:24 AM JST, Matthew Maurer wrote:
>> > Allow SoC drivers in Rust to present metadata about their devices to
>> > userspace through /sys/devices/socX and other drivers to identify their
>> > properties through `soc_device_match`.
>> >
>> > Signed-off-by: Matthew Maurer <mmaurer@google.com>
>> > ---
>> >  MAINTAINERS                     |   1 +
>> >  rust/bindings/bindings_helper.h |   1 +
>> >  rust/kernel/lib.rs              |   2 +
>> >  rust/kernel/soc.rs              | 135 ++++++++++++++++++++++++++++++++++++++++
>> >  4 files changed, 139 insertions(+)
>> >
>> > diff --git a/MAINTAINERS b/MAINTAINERS
>> > index c5a7cda26c600e49c7ab0d547306d3281333f672..4ff01fb0f1bda27002094113c0bf9d074d28fdb6 100644
>> > --- a/MAINTAINERS
>> > +++ b/MAINTAINERS
>> > @@ -7700,6 +7700,7 @@ F:      rust/kernel/devres.rs
>> >  F:   rust/kernel/driver.rs
>> >  F:   rust/kernel/faux.rs
>> >  F:   rust/kernel/platform.rs
>> > +F:   rust/kernel/soc.rs
>> >  F:   samples/rust/rust_debugfs.rs
>> >  F:   samples/rust/rust_debugfs_scoped.rs
>> >  F:   samples/rust/rust_driver_platform.rs
>> > diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
>> > index a067038b4b422b4256f4a2b75fe644d47e6e82c8..9fdf76ca630e00715503e2a3a809bedc895697fd 100644
>> > --- a/rust/bindings/bindings_helper.h
>> > +++ b/rust/bindings/bindings_helper.h
>> > @@ -80,6 +80,7 @@
>> >  #include <linux/sched.h>
>> >  #include <linux/security.h>
>> >  #include <linux/slab.h>
>> > +#include <linux/sys_soc.h>
>> >  #include <linux/task_work.h>
>> >  #include <linux/tracepoint.h>
>> >  #include <linux/usb.h>
>> > diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
>> > index f812cf12004286962985a068665443dc22c389a2..6d637e2fed1b605e2dfc2e7b2247179439a90ba9 100644
>> > --- a/rust/kernel/lib.rs
>> > +++ b/rust/kernel/lib.rs
>> > @@ -138,6 +138,8 @@
>> >  pub mod seq_file;
>> >  pub mod sizes;
>> >  pub mod slice;
>> > +#[cfg(CONFIG_SOC_BUS)]
>> > +pub mod soc;
>> >  mod static_assert;
>> >  #[doc(hidden)]
>> >  pub mod std_vendor;
>> > diff --git a/rust/kernel/soc.rs b/rust/kernel/soc.rs
>> > new file mode 100644
>> > index 0000000000000000000000000000000000000000..0d6a36c83cb67ef20dc1e3d3995752f36e25ac9f
>> > --- /dev/null
>> > +++ b/rust/kernel/soc.rs
>> > @@ -0,0 +1,135 @@
>> > +// SPDX-License-Identifier: GPL-2.0
>> > +
>> > +// Copyright (C) 2025 Google LLC.
>> > +
>> > +//! SoC Driver Abstraction.
>> > +//!
>> > +//! C header: [`include/linux/sys_soc.h`](srctree/include/linux/sys_soc.h)
>> > +
>> > +use crate::{
>> > +    bindings,
>> > +    error,
>> > +    prelude::*,
>> > +    str::CString,
>> > +    types::Opaque, //
>> > +};
>> > +use core::ptr::NonNull;
>> > +
>> > +/// Attributes for a SoC device.
>> > +///
>> > +/// These are both exported to userspace under /sys/devices/socX and provided to other drivers to
>> > +/// match against via `soc_device_match` (not yet available in Rust) to enable quirks or
>> > +/// device-specific support where necessary.
>> > +///
>> > +/// All fields are freeform - they have no specific formatting, just defined meanings.
>> > +/// For example, the [`machine`](`Attributes::machine`) field could be "DB8500" or
>> > +/// "Qualcomm Technologies, Inc. SM8560 HDK", but regardless it should identify a board or product.
>> > +pub struct Attributes {
>> > +    /// Should generally be a board ID or product ID. Examples
>> > +    /// include DB8500 (ST-Ericsson) or "Qualcomm Technologies, inc. SM8560 HDK".
>> > +    ///
>> > +    /// If this field is not populated, the SoC infrastructure will try to populate it from
>> > +    /// `/model` in the device tree.
>> > +    pub machine: Option<CString>,
>> > +    /// The broader class this SoC belongs to. Examples include ux500
>> > +    /// (for DB8500) or Snapdragon (for SM8650).
>>
>> Formatting of the comments seems a bit off (also appears in other
>> places, please reapply formatting globally to be sure).
>
> I have just re-run the `rustfmt` target on this commit, and see no
> changes. Is there something specific that you think is off?

rustfmt doesn't touch comments IIUC.

What I had in mind was for instance that the first line of the comment
for `machine` is shorter than it could be, i.e. the comments should be
re-wrapped for consistency.

  parent reply	other threads:[~2026-01-14  7:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-16 19:24 [PATCH v3 0/3] Support exporting SoC info from Rust Matthew Maurer
2025-12-16 19:24 ` [PATCH v3 1/3] rust: Add soc_device support Matthew Maurer
2025-12-17  2:31   ` Alexandre Courbot
2025-12-26 19:26     ` Matthew Maurer
2025-12-26 19:38       ` Matthew Maurer
2025-12-28 11:21         ` Miguel Ojeda
2026-01-14  7:54         ` Alexandre Courbot
2026-01-14  7:53       ` Alexandre Courbot [this message]
2025-12-16 19:24 ` [PATCH v3 2/3] docs: ABI: sysfs-devices-soc: Fix swapped sample values Matthew Maurer
2025-12-16 19:24 ` [PATCH v3 3/3] rust: Add SoC Driver Sample Matthew Maurer
2025-12-17  2:28   ` Alexandre Courbot

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=DFO5EMUQ33AP.2NM06WXNV5WH0@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=mmaurer@google.com \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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.