From nobody Mon Feb 9 23:15:59 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010015.outbound.protection.outlook.com [52.101.46.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3823F34572A; Thu, 16 Oct 2025 15:13:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760627623; cv=fail; b=LJc0DxgHdS5TW+LhV3ksO7Ytj1rHTxgViYRFiT7HZkW1A6lbnmVw3doPG/EHqr0chkrJZqHfNhHwgIZV2fm0fu5DEhnOrAIWTUoo90yCCtsVvvklp+XUEyw3OWJ7fiV5ha2T4FK/I5txy6hlcjyD+SsND+q4Lyjtch+rrHHiXEM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760627623; c=relaxed/simple; bh=Zy6CeLa1IX+DLumKsCyO9borr12sd5dLcoQdkz29W14=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nKVvylPegUYNcSLAWaiz55oMt+Um6BM8xME+xoo5nik6DplzPrwC8HNUR6NHUHk2jWXjzQxRr1BOtI9wgZh/YfOKgynZAYLd9hLdE0E1nHRSB+8PFF8VmQE2JPRkVDj4t0zT3/6HkX90Kdqve/AnmEWnMZZrsYwAkpxWvsq3Rlg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=BtlJYtMb; arc=fail smtp.client-ip=52.101.46.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="BtlJYtMb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yg3RavisxMivMFZ4Xnf3sLry4BVJyllCMYrs7OHqj0C8AtUWDT//Y71CwbgZKvzmVr6Y7Ek7OwcOKS0HzukO6x1jfJRSm5PJNOxhjWK1eV3jb4j7+q6cPUdOmnUB19e9+DMhPG3B77JWorimL57lUKPEkbbD5AYMeMIOuFFryozpGcgOvSYSOpUrB3hlnDY1nZI86HrX1FLRFmsiOn8Vvud7BMjqt8ELzy7UjzIXRnCxYdQGQ8MEs7ucJ9F9oNmKo+ziOzbBVpeG2X04FHsXiULwP8kbgamEzyH+1iapUFxPpKmBNFLsqIy8O7zNs3B2LtU/8EjWJHI8Th2ZoHFmXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Or4vegJ37dm6vFkg9XIyhJHgngzh+8yUExNw16FJvCk=; b=qkqZNY5WaGFMiRx97uK5WHIFmH+PDpHemm1p4xU/TW+5mf/SMIWEETpnOE8F2aPfJfesOwlHoTRoKqNGVF01hcvWDUWfazinariQkLJiKyLJ21F6/3f3Us+LlKkxFN7y0aYHaN8i5CFpXHAQGe7j50HM6iuMcCDTMIym1gD70cbcZu/tylWs8fQCT1n0BRRUm32V1D42hmivDZL87TkcRLM4StgoiLierR6YltVDSXx1iZWwLXSqBTZp15aODX5MOqf9aQF5CT+0LBhp6LyaR4R94ndNlxPlqjEI0p4umgVWNqgjxh1Knh721Jb9O1D7J8T7woKHL5NyZpEvWJerdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Or4vegJ37dm6vFkg9XIyhJHgngzh+8yUExNw16FJvCk=; b=BtlJYtMby7O2XD+zGAut/9JAw1zC8DL0UfKqxgCZtBS0Vu2jlLD/Tod8Jaj5q4GnvJuGqZdf5mQ+Ru9YFiGqpVdpB/x12uZ+wczzVgmZaTsABAim9C9XVSD45/paoabj4yLbr++zjNbcRgIOLNK+OU7ZGLZNvsRfhK9ebUjsLqjRyRBcS+dxz3LzobDqbv8CtYDyjfH5PIcNoNcl3KU9ncK1RpYdYN0/slhUfaXA4E8yOXOo9mKDZw1CWjXatzHk/zpiXCBg8tbs4sPEAbC6vrq2pvzxaBBh1p61N88/9pWCTyoe0IN3n7iHtnBGLF/n0r72QeYgRSFqqAqGQb8wYg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SN7PR12MB8059.namprd12.prod.outlook.com (2603:10b6:806:32b::7) by DS0PR12MB8574.namprd12.prod.outlook.com (2603:10b6:8:166::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9228.10; Thu, 16 Oct 2025 15:13:35 +0000 Received: from SN7PR12MB8059.namprd12.prod.outlook.com ([fe80::4ee2:654e:1fe8:4b91]) by SN7PR12MB8059.namprd12.prod.outlook.com ([fe80::4ee2:654e:1fe8:4b91%2]) with mapi id 15.20.9228.010; Thu, 16 Oct 2025 15:13:35 +0000 From: Joel Fernandes To: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , bjorn3_gh@protonmail.com, Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , joel@joelfernandes.org, Elle Rhumsaa , Yury Norov , Daniel Almeida , nouveau@lists.freedesktop.org, Edwin Peer Subject: [PATCH v7.1 4/4] gpu: nova-core: bitfield: Add support for custom visiblity Date: Thu, 16 Oct 2025 11:13:23 -0400 Message-Id: <20251016151323.1201196-5-joelagnelf@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251016151323.1201196-1-joelagnelf@nvidia.com> References: <20251016151323.1201196-1-joelagnelf@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9P223CA0005.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::10) To SN7PR12MB8059.namprd12.prod.outlook.com (2603:10b6:806:32b::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR12MB8059:EE_|DS0PR12MB8574:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e121e24-191e-402d-b283-08de0cc693a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ejUpBAx0DTn+QWn9Goy09encjtELeqNFG6gYu/CwYQACd+dkRJd9bNLkDNmc?= =?us-ascii?Q?QbSG+/nBrC45K8FLqwlkCJMSWdK2U9ShOtQXKFiwwfP8nw7FYTaKAw4eIW0w?= =?us-ascii?Q?m5n0ES+GIOvTaR2RoiVCVeLt+aErqR0AccFc9/S5vw7+2hUr+YgcQE3ANkbD?= =?us-ascii?Q?IAcGciY81URmLMtnMXueT4FexWjoDjHxFLBIcO+k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unjkrCqR23JZb4a++ngtibLA4gUjEsyzCqgO7CmstEUx89mgI2hee5V?= =?us-ascii?Q?6unTZmX3PeHw0nLh76qH6OM1BFkxPE+ZZj3jW4oJ5z39HdvUI2iS/OacYJXM?= =?us-ascii?Q?6jjeEev7UNXsiULX+578NFm5UZdVNG1MzZLoqauEqvlXB161Hek/KJytWU9V?= =?us-ascii?Q?XkjB5mqc1xIGqmlvvoz8z2ASzY6HGD9yfXKLuHK6DY2IjkNRMc4Z72rYhTd3?= =?us-ascii?Q?/FYBf+rH4oaFomKA3WKNU/7BzCUFDe2brNBNwdxlhTOnx4keiiWGWVY0I31m?= =?us-ascii?Q?sXoVvy+J9zg/U9SCuOfCM3uAgRdJatLi8UnKurrQ/bY4u4NigHznEpB8+1Bt?= =?us-ascii?Q?DOH1KTE/7xHykKvwErd5jeX+eBiR0XMA?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR12MB8059.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?I1HzMzx+7Fxmb0lqkwiI/BDeb0ljo2rkH4WXOvrN1pVTTL6MyLAeD7Ki5PWw?= =?us-ascii?Q?RGLmi8yr85LicHDwInHKedSJGaxKFlgfck2F8PVLV6J8qoBCGiSZinEMtnt6?= =?us-ascii?Q?5wOAmWx0sm6E75hgSj4vdMQysvI75KKL7Vh3IMBcebz5KruZSxjx/N7fjI83?= =?us-ascii?Q?TE6WSBblAs4s5hfrLCjOSLKjt7MXmwxB+1WTYEOPniJgSGazTQdxWhtzLhF9?= =?us-ascii?Q?eFtWVoRMrLk4TsHLj/KoAZYUGoPtg+SO3yHA/sdUG0t1LUuhCP4NFXy0ihQK?= =?us-ascii?Q?vkzS9h6myFdD0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Et1?= =?us-ascii?Q?Q3saQaAqc+0CMplHtojrtQ4qV/4+gF8LQU/puaHv/XfWisF0BB9ddjtR4uW5?= =?us-ascii?Q?LoR+dWDaQdnwoR4cFs95tUehh8Yk195B3IkhbXM9JAExcjcs93Yy0kRCf2uo?= =?us-ascii?Q?CFddWqaQ2So6879PSmQry4nTkigW4+eWkbFZyp4XVt0mQyhTapdsZR2LsaA1?= =?us-ascii?Q?KXA4YFFl+3EGpolSwM5BRnOIQ+1SRlPlKE1QyYcYPMF7r43bUhgFPNyS8Sjs?= =?us-ascii?Q?1uFW4JHMA4+T7LllLsy1DTa8HzpV6JlJZTcjCTNIVmg20gYug+hE3sfCLqiB?= =?us-ascii?Q?iYpu5IyqivelofVaGD1S41Z2kCVIZ2Zyqx22yJCx3wQBEnlsuOAXVpa4kxD0?= =?us-ascii?Q?5nE/KNhXkwVCmDkn41+QkLb7yu28xloG2jYEsews?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e121e24-191e-402d-b283-08de0cc693a2 X-MS-Exchange-CrossTenant-AuthSource: SN7PR12MB8059.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2025 15:13:35.4750 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jRUeB2sVVhsEU7r7qsFyO5MtCgI3iKYnq/C9G/GFkT/VaFTZ+SJzjdJPMRs0PoXQbxT6pqSu2oJdBhnZKfvA1A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8574 Content-Type: text/plain; charset="utf-8" Add support for custom visiblity to allow for users to control visibility of the structure and helpers. Reviewed-by: Alexandre Courbot Reviewed-by: Elle Rhumsaa Reviewed-by: Edwin Peer Signed-off-by: Joel Fernandes --- drivers/gpu/nova-core/bitfield.rs | 49 +++++++++++++++------------- drivers/gpu/nova-core/regs/macros.rs | 16 ++++----- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/nova-core/bitfield.rs b/drivers/gpu/nova-core/bitf= ield.rs index 998970ff0bbc..0994505393dd 100644 --- a/drivers/gpu/nova-core/bitfield.rs +++ b/drivers/gpu/nova-core/bitfield.rs @@ -60,7 +60,7 @@ /// } /// /// bitfield! { -/// struct ControlReg(u32) { +/// pub struct ControlReg(u32) { /// 3:0 mode as u8 ?=3D> Mode; /// 7:7 state as bool =3D> State; /// } @@ -74,6 +74,9 @@ /// struct's storage size. /// - Debug and Default implementations. /// +/// Note: Field accessors and setters inherit the same visibility as the s= truct itself. +/// In the example above, both `mode()` and `set_mode()` methods will be `= pub`. +/// /// Fields are defined as follows: /// /// - `as ` simply returns the field value casted to , typical= ly `u32`, `u16`, `u8` or @@ -84,21 +87,21 @@ /// and returns the result. This is useful with fields for which not all= values are valid. macro_rules! bitfield { // Main entry point - defines the bitfield struct with fields - (struct $name:ident($storage:ty) $(, $comment:literal)? { $($fields:tt= )* }) =3D> { - bitfield!(@core $name $storage $(, $comment)? { $($fields)* }); + ($vis:vis struct $name:ident($storage:ty) $(, $comment:literal)? { $($= fields:tt)* }) =3D> { + bitfield!(@core $vis $name $storage $(, $comment)? { $($fields)* }= ); }; =20 // All rules below are helpers. =20 // Defines the wrapper `$name` type, as well as its relevant implement= ations (`Debug`, // `Default`, `BitOr`, and conversion to the value type) and field acc= essor methods. - (@core $name:ident $storage:ty $(, $comment:literal)? { $($fields:tt)*= }) =3D> { + (@core $vis:vis $name:ident $storage:ty $(, $comment:literal)? { $($fi= elds:tt)* }) =3D> { $( #[doc=3D$comment] )? #[repr(transparent)] #[derive(Clone, Copy)] - pub(crate) struct $name($storage); + $vis struct $name($storage); =20 impl ::core::ops::BitOr for $name { type Output =3D Self; @@ -114,14 +117,14 @@ fn from(val: $name) -> $storage { } } =20 - bitfield!(@fields_dispatcher $name $storage { $($fields)* }); + bitfield!(@fields_dispatcher $vis $name $storage { $($fields)* }); }; =20 // Captures the fields and passes them to all the implementers that re= quire field information. // // Used to simplify the matching rules for implementers, so they don't= need to match the entire // complex fields rule even though they only make use of part of it. - (@fields_dispatcher $name:ident $storage:ty { + (@fields_dispatcher $vis:vis $name:ident $storage:ty { $($hi:tt:$lo:tt $field:ident as $type:tt $(?=3D> $try_into_type:ty)? $(=3D> $into_type:ty)? @@ -130,7 +133,7 @@ fn from(val: $name) -> $storage { )* } ) =3D> { - bitfield!(@field_accessors $name $storage { + bitfield!(@field_accessors $vis $name $storage { $( $hi:$lo $field as $type $(?=3D> $try_into_type)? @@ -145,7 +148,7 @@ fn from(val: $name) -> $storage { =20 // Defines all the field getter/setter methods for `$name`. ( - @field_accessors $name:ident $storage:ty { + @field_accessors $vis:vis $name:ident $storage:ty { $($hi:tt:$lo:tt $field:ident as $type:tt $(?=3D> $try_into_type:ty)? $(=3D> $into_type:ty)? @@ -161,7 +164,7 @@ fn from(val: $name) -> $storage { #[allow(dead_code)] impl $name { $( - bitfield!(@field_accessor $name $storage, $hi:$lo $field as $t= ype + bitfield!(@field_accessor $vis $name $storage, $hi:$lo $field = as $type $(?=3D> $try_into_type)? $(=3D> $into_type)? $(, $comment)? @@ -195,11 +198,11 @@ impl $name { =20 // Catches fields defined as `bool` and convert them into a boolean va= lue. ( - @field_accessor $name:ident $storage:ty, $hi:tt:$lo:tt $field:iden= t as bool =3D> $into_type:ty + @field_accessor $vis:vis $name:ident $storage:ty, $hi:tt:$lo:tt $f= ield:ident as bool =3D> $into_type:ty $(, $comment:literal)?; ) =3D> { bitfield!( - @leaf_accessor $name $storage, $hi:$lo $field + @leaf_accessor $vis $name $storage, $hi:$lo $field { |f| <$into_type>::from(if f !=3D 0 { true } else { false }) } bool $into_type =3D> $into_type $(, $comment)?; ); @@ -207,17 +210,17 @@ impl $name { =20 // Shortcut for fields defined as `bool` without the `=3D>` syntax. ( - @field_accessor $name:ident $storage:ty, $hi:tt:$lo:tt $field:iden= t as bool $(, $comment:literal)?; + @field_accessor $vis:vis $name:ident $storage:ty, $hi:tt:$lo:tt $f= ield:ident as bool $(, $comment:literal)?; ) =3D> { - bitfield!(@field_accessor $name $storage, $hi:$lo $field as bool = =3D> bool $(, $comment)?;); + bitfield!(@field_accessor $vis $name $storage, $hi:$lo $field as b= ool =3D> bool $(, $comment)?;); }; =20 // Catches the `?=3D>` syntax for non-boolean fields. ( - @field_accessor $name:ident $storage:ty, $hi:tt:$lo:tt $field:iden= t as $type:tt ?=3D> $try_into_type:ty + @field_accessor $vis:vis $name:ident $storage:ty, $hi:tt:$lo:tt $f= ield:ident as $type:tt ?=3D> $try_into_type:ty $(, $comment:literal)?; ) =3D> { - bitfield!(@leaf_accessor $name $storage, $hi:$lo $field + bitfield!(@leaf_accessor $vis $name $storage, $hi:$lo $field { |f| <$try_into_type>::try_from(f as $type) } $type $try_into= _type =3D> ::core::result::Result< $try_into_type, @@ -228,24 +231,24 @@ impl $name { =20 // Catches the `=3D>` syntax for non-boolean fields. ( - @field_accessor $name:ident $storage:ty, $hi:tt:$lo:tt $field:iden= t as $type:tt =3D> $into_type:ty + @field_accessor $vis:vis $name:ident $storage:ty, $hi:tt:$lo:tt $f= ield:ident as $type:tt =3D> $into_type:ty $(, $comment:literal)?; ) =3D> { - bitfield!(@leaf_accessor $name $storage, $hi:$lo $field + bitfield!(@leaf_accessor $vis $name $storage, $hi:$lo $field { |f| <$into_type>::from(f as $type) } $type $into_type =3D> $= into_type $(, $comment)?;); }; =20 // Shortcut for non-boolean fields defined without the `=3D>` or `?=3D= >` syntax. ( - @field_accessor $name:ident $storage:ty, $hi:tt:$lo:tt $field:iden= t as $type:tt + @field_accessor $vis:vis $name:ident $storage:ty, $hi:tt:$lo:tt $f= ield:ident as $type:tt $(, $comment:literal)?; ) =3D> { - bitfield!(@field_accessor $name $storage, $hi:$lo $field as $type = =3D> $type $(, $comment)?;); + bitfield!(@field_accessor $vis $name $storage, $hi:$lo $field as $= type =3D> $type $(, $comment)?;); }; =20 // Generates the accessor methods for a single field. ( - @leaf_accessor $name:ident $storage:ty, $hi:tt:$lo:tt $field:ident + @leaf_accessor $vis:vis $name:ident $storage:ty, $hi:tt:$lo:tt $fi= eld:ident { $process:expr } $prim_type:tt $to_type:ty =3D> $res_type:ty = $(, $comment:literal)?; ) =3D> { ::kernel::macros::paste!( @@ -268,7 +271,7 @@ impl $name { #[doc=3D$comment] )? #[inline(always)] - pub(crate) fn $field(self) -> $res_type { + $vis fn $field(self) -> $res_type { ::kernel::macros::paste!( const MASK: $storage =3D $name::[<$field:upper _MASK>]; const SHIFT: u32 =3D $name::[<$field:upper _SHIFT>]; @@ -284,7 +287,7 @@ pub(crate) fn $field(self) -> $res_type { #[doc=3D$comment] )? #[inline(always)] - pub(crate) fn [](mut self, value: $to_type) -> Self { + $vis fn [](mut self, value: $to_type) -> Self { const MASK: $storage =3D $name::[<$field:upper _MASK>]; const SHIFT: u32 =3D $name::[<$field:upper _SHIFT>]; let value =3D ($storage::from($prim_type::from(value)) << SHIF= T) & MASK; diff --git a/drivers/gpu/nova-core/regs/macros.rs b/drivers/gpu/nova-core/r= egs/macros.rs index ffd7d5cb73bb..c0a5194e8d97 100644 --- a/drivers/gpu/nova-core/regs/macros.rs +++ b/drivers/gpu/nova-core/regs/macros.rs @@ -276,25 +276,25 @@ pub(crate) trait RegisterBase { macro_rules! register { // Creates a register at a fixed offset of the MMIO space. ($name:ident @ $offset:literal $(, $comment:literal)? { $($fields:tt)*= } ) =3D> { - bitfield!(struct $name(u32) $(, $comment)? { $($fields)* } ); + bitfield!(pub(crate) struct $name(u32) $(, $comment)? { $($fields)= * } ); register!(@io_fixed $name @ $offset); }; =20 // Creates an alias register of fixed offset register `alias` with its= own fields. ($name:ident =3D> $alias:ident $(, $comment:literal)? { $($fields:tt)*= } ) =3D> { - bitfield!(struct $name(u32) $(, $comment)? { $($fields)* } ); + bitfield!(pub(crate) struct $name(u32) $(, $comment)? { $($fields)= * } ); register!(@io_fixed $name @ $alias::OFFSET); }; =20 // Creates a register at a relative offset from a base address provide= r. ($name:ident @ $base:ty [ $offset:literal ] $(, $comment:literal)? { $= ($fields:tt)* } ) =3D> { - bitfield!(struct $name(u32) $(, $comment)? { $($fields)* } ); + bitfield!(pub(crate) struct $name(u32) $(, $comment)? { $($fields)= * } ); register!(@io_relative $name @ $base [ $offset ]); }; =20 // Creates an alias register of relative offset register `alias` with = its own fields. ($name:ident =3D> $base:ty [ $alias:ident ] $(, $comment:literal)? { $= ($fields:tt)* }) =3D> { - bitfield!(struct $name(u32) $(, $comment)? { $($fields)* } ); + bitfield!(pub(crate) struct $name(u32) $(, $comment)? { $($fields)= * } ); register!(@io_relative $name @ $base [ $alias::OFFSET ]); }; =20 @@ -305,7 +305,7 @@ macro_rules! register { } ) =3D> { static_assert!(::core::mem::size_of::() <=3D $stride); - bitfield!(struct $name(u32) $(, $comment)? { $($fields)* } ); + bitfield!(pub(crate) struct $name(u32) $(, $comment)? { $($fields)= * } ); register!(@io_array $name @ $offset [ $size ; $stride ]); }; =20 @@ -326,7 +326,7 @@ macro_rules! register { $(, $comment:literal)? { $($fields:tt)* } ) =3D> { static_assert!(::core::mem::size_of::() <=3D $stride); - bitfield!(struct $name(u32) $(, $comment)? { $($fields)* } ); + bitfield!(pub(crate) struct $name(u32) $(, $comment)? { $($fields)= * } ); register!(@io_relative_array $name @ $base [ $offset [ $size ; $st= ride ] ]); }; =20 @@ -348,7 +348,7 @@ macro_rules! register { } ) =3D> { static_assert!($idx < $alias::SIZE); - bitfield!(struct $name(u32) $(, $comment)? { $($fields)* } ); + bitfield!(pub(crate) struct $name(u32) $(, $comment)? { $($fields)= * } ); register!(@io_relative $name @ $base [ $alias::OFFSET + $idx * $al= ias::STRIDE ] ); }; =20 @@ -357,7 +357,7 @@ macro_rules! register { // to avoid it being interpreted in place of the relative register arr= ay alias rule. ($name:ident =3D> $alias:ident [ $idx:expr ] $(, $comment:literal)? { = $($fields:tt)* }) =3D> { static_assert!($idx < $alias::SIZE); - bitfield!(struct $name(u32) $(, $comment)? { $($fields)* } ); + bitfield!(pub(crate) struct $name(u32) $(, $comment)? { $($fields)= * } ); register!(@io_fixed $name @ $alias::OFFSET + $idx * $alias::STRIDE= ); }; =20 --=20 2.34.1