Re: [PATCH v4 01/16] rust: io: register: reimplement as proc macro

From: Alexandre Courbot

Date: Thu Sep 03 2026 - 07:55:02 EST


On Wed Sep 2, 2026 at 1:50 AM JST, Gary Guo wrote:
<...>
> diff --git a/rust/macros/io/mod.rs b/rust/macros/io/mod.rs
> new file mode 100644
> index 000000000000..87f7742f4619
> --- /dev/null
> +++ b/rust/macros/io/mod.rs
> @@ -0,0 +1,3 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +pub(crate) mod register;
> diff --git a/rust/macros/io/register.rs b/rust/macros/io/register.rs
> new file mode 100644
> index 000000000000..83ba4dd75ab3
> --- /dev/null
> +++ b/rust/macros/io/register.rs
> @@ -0,0 +1,276 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +//! Documention and usage example of the macro can be found at `rust/kernel/io/register.rs`.

s/Documention/Documentation

> +
> +use proc_macro2::{
> + Group,
> + Literal,
> + Span,
> + TokenStream, //
> +};
> +use quote::{
> + quote,
> + quote_spanned, //
> +};
> +use syn::{
> + bracketed,
> + parenthesized,
> + parse::Parse,
> + spanned::Spanned,
> + token,
> + Attribute,
> + Expr,
> + Ident,
> + Path,
> + Result,
> + Token,
> + Type,
> + Visibility, //
> +};
> +
> +mod kw {
> + syn::custom_keyword!(stride);
> +}
> +
> +/// Definition of a register array.
> +///
> +/// Specify a size, and optionally a stride. Syntax is of form `[size: EXPR, $(stride = EXPR)?]`.

IIUC the syntax is actually `[EXPR $(, stride = EXPR)?]`.

With these fixed,

Reviewed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>