From nobody Fri Oct 3 08:50:31 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2085.outbound.protection.outlook.com [40.107.93.85]) (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 DBC8F2EE5F0; Wed, 3 Sep 2025 21:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756936489; cv=fail; b=dJSpTEitmBFJX6+mU/mHkX+J6EQcQ/5Wsit1a3jLVMJJHb9/z9gxLPf4z+71rA1NFOeNAJuACiuRmz2uSXNhfMzwyfLAFO9gT+2IolOLB/VtGX3uwbxOePFf7M3Sg0NVkYVpn5pTHRdhJP0d4vUey9BbwuzMQ1INl7uDKNaKt0Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756936489; c=relaxed/simple; bh=3MYVIZiipK8jVtMbJKoKK4G24H4103f+g+GmGs51HGA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fpHSosODEIvahTGNnQiA2S3W0tt4J+YH02HiFQtOytw42EVCCnD7NSW3ygXICp3Z0CuClFxBPGpIfCY7KkZ+Dd3R/oHx1sHxkETCW4jE0O6WiPt85Knb0HhjNETyb/zOX5Tbe1Kk/Jc23oqq9FNFrwozWUPVHE9wSO24uEr50OI= 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=h8pcFQF/; arc=fail smtp.client-ip=40.107.93.85 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="h8pcFQF/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YfXTSp2Kv8WkkPCJhhx0CEEilgXWx8iVZ1/NEt+lYn1IIqJsrP1s1KrUkaxOBoLk4NQeDNVcz3G9X9UHSgzpqt4fJ/KOO5LZxrDfda/wqew7SOihA8tqzmdVxFNWebch+Fu5cdj9dJtbCw2G6KOqm0ZXURjTecELCbxUmsMxfyT2hkn8SBjTsBkzc6zemFhYKeUjqWQen00VcfJmQd+KWRblya3clAeJOuardzareJfyHef6ZGaHRciW93Au24zJLT5Lrt/Gb72KtlCTX660HOC0W1OudZMO/Dg6YoANs6xwqGa1frt/8Dl7KYZKAymfNYWwdULvhCwVT/MWfg9IJQ== 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=mNqVMI3dCkNEhp/x5pJyhEVtxtutIwF7FKIT5r03P8s=; b=ZkzF87qc9VmOC3KuGks84zp+g7dhdEwtXhMpZQZVfCz2M7R4iDR0ApPXpXlm4tAS5BS0K2J2uH+2ezZ6rl2+hemmBiugVl3n0nY91g2hTMgoxFZzLVW/0R53fNVHLKG78IKAArSHpW11CQx4tIKiKvYeWtYprnIYTywBoti/RJyozTlEjJ6uimxHsgbtolbpPcsNl5Arq9JBaQiryFB+C5/MR1QaWvMkF4YNTTSj9gH1ehE/5fNGwnrvL9xEJ2YvrFC+ruoMpODNUpAZRT4OphR8ePqvKZ5YA/QJvlShMe8O+192a3NZ6qm4cSxHXRVBqWR8Spb1FaPa9uLqksULAQ== 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=mNqVMI3dCkNEhp/x5pJyhEVtxtutIwF7FKIT5r03P8s=; b=h8pcFQF/wthbxyYnP70qR8jS0QQaSDlq7DuL+9rGGXQSCaaAFjy2F7djW6Gfhq5Hbg0WM+7n/QHkKDzVB6cnHNrZK8MUpbfv7oLsrUSlgGIL2zvNxjzodybSuz//1zrgt+7DPlzQ+JL1OVkSam9k/AW84KyeTj3HI91pyYjUOj1tEpCF3lx+fVH+qQoL4og8OUtMLv0C83EzeRUAp/1asstis40VHbMZUwZ3OIoIqx+YwvTmlIlWkIgzIE+YHO2GCCPxgo8Uk7+5O2GK8K2AbuuoeZHN/gJaFnzUruihGHZlPUVcD09v09IxsFwMksydPeKp+k8pph1TQFMJNfgXeQ== 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 DS2PR12MB9589.namprd12.prod.outlook.com (2603:10b6:8:279::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9073.27; Wed, 3 Sep 2025 21:54:38 +0000 Received: from SN7PR12MB8059.namprd12.prod.outlook.com ([fe80::4ee2:654e:1fe8:4b91]) by SN7PR12MB8059.namprd12.prod.outlook.com ([fe80::4ee2:654e:1fe8:4b91%3]) with mapi id 15.20.9073.021; Wed, 3 Sep 2025 21:54:38 +0000 From: Joel Fernandes To: linux-kernel@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 , Daniel Almeida , nouveau@lists.freedesktop.org, rust-for-linux@vger.kernel.org Subject: [PATCH v2 3/4] nova-core: bitstruct: Add support for custom visiblity Date: Wed, 3 Sep 2025 17:54:27 -0400 Message-Id: <20250903215428.1296517-4-joelagnelf@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250903215428.1296517-1-joelagnelf@nvidia.com> References: <20250903215428.1296517-1-joelagnelf@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MN2PR01CA0038.prod.exchangelabs.com (2603:10b6:208:23f::7) 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_|DS2PR12MB9589:EE_ X-MS-Office365-Filtering-Correlation-Id: d8c5a2b7-74d8-4169-22e7-08ddeb347a57 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?HbzXuo+//DJQcp7rasYksci1Pht/oqrCh0YHs4tgo0/1D8q8NNHyEYj4hG2v?= =?us-ascii?Q?uXFS3x9gnJdO1hDv3KnLK150NXYNRRCElEU5wBoBPb+eyRGkS9JJ7pLDJeXv?= =?us-ascii?Q?JDcLKPzxA/sDLloPmc7pCAdot9ELbg19ELkszl87AODMWoKpdMBksCz1xQRL?= =?us-ascii?Q?0Xrhpw4u2o+vh93HzlRSo8hxzeFO9/GxkbBvxAmUiKbmBu6W+D0Oh5Mn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tDmyu2+/Bnt9Em0EgUS70SsHByJGvIEAv41VP?= =?us-ascii?Q?Kspjshsx7yeYyUfCsFEpL3W623oXLzlx/yYhVVP0ugL2lxyad7BnYM/FuJP2?= =?us-ascii?Q?4LRDPRRH4xn6oXmR+JYeKHLVadrABeJ5i9MGGtol0NUUqDmHUSSmI/JqMD5u?= =?us-ascii?Q?kRusEjOh2i2xmiQoyKWYsWiFqrSbvx8QRzjbPWgwyd/89wffCR8h1JJwhAZS?= =?us-ascii?Q?XROkH5vK1qZA4xWJsmH8HSTaOfpE/NsJV1E8cID2XOzs1xERdg604NBB+ZRy?= =?us-ascii?Q?p+rRguKzh7/45ZiL59arkVxBSjmfPADhDro4dOzbzymjbTXqgQ=3D=3D?= 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)(366016)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?tC0LLSTREHTKM5HArnWVG2AbN9jWmrjEv+pYlACcfSlFcm6icdhS65tdREo+?= =?us-ascii?Q?Kmv52hFYsGAfzwjDe7p1hFdIOL2Z6HWTQyaOveH8gqaf1eYb4eR74X3KLE/z?= =?us-ascii?Q?vsR0vV54I38Fe120bldEqravOQ/7hv78FRYgqtlaBN2/KRzgHoNFQy1w3CVw?= =?us-ascii?Q?06SE77ac8yZoapNWavNQ9ARgdCxtHvMFJzCjgSDeL/H98R0nC0O9xEUyeX75?= =?us-ascii?Q?zYc+/al5Ho9eN3YmyKBRb7imeWgm5kMb1SO8USUPx+dNyexhYxF4wcuOODCW?= =?us-ascii?Q?HFDtDwcR4R5Xt0Fg+JhO40ftG3dGF6WAdGZhHZurustVwFOk+7J9ZX1r8u9V?= =?us-ascii?Q?MX2/rW7wDwL3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weGVqT?= =?us-ascii?Q?vaY9N1WMuRUWpOTQhv3Qy7a6E7u5EtLd2BDoka3zoMGxwRfEYUErueeW3hMQ?= =?us-ascii?Q?lRvFjYdJSi8SaicUsO+4WjDlBTiySvz6N452gp2k+2CF14Vw+SmCjtlXcBCx?= =?us-ascii?Q?WiB+meNsQVHjJ46UFbqjjSdZStdGVl5TfTDFbHKRDM9Y8n18v30XUVNATjy0?= =?us-ascii?Q?zkDsbDEWDQAMaoAQCgoEIZl14g/aw7a6xpC6AZJZzfl7NRbnPBU2OgdqVdY3?= =?us-ascii?Q?13D4U5OXUZ9/WEbTGyhURx5gbb5tcPwxtzkpkn/82ph4yQa13N5SonIK8GmV?= =?us-ascii?Q?RGzrv8Zv0rf1GKj8QAl/+SVFGHovY+4pF0Wvz3Qw?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8c5a2b7-74d8-4169-22e7-08ddeb347a57 X-MS-Exchange-CrossTenant-AuthSource: SN7PR12MB8059.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2025 21:54:38.1510 (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: GrwMvbMfBKV6l5VLiZa+FLj80Y7tUa/3pG/MAYVVS0xmTBV4svFSMd5qy8XjUqVHZcUOAFtVNZN5q3ALy9Wzbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS2PR12MB9589 Content-Type: text/plain; charset="utf-8" Add support for custom visiblity to allow for users to control visibility of the structure and helpers. Signed-off-by: Joel Fernandes Reviewed-by: Elle Rhumsaa --- drivers/gpu/nova-core/bitstruct.rs | 46 ++++++++++++++-------------- drivers/gpu/nova-core/regs/macros.rs | 16 +++++----- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/nova-core/bitstruct.rs b/drivers/gpu/nova-core/bit= struct.rs index 068334c86981..1047c5c17e2d 100644 --- a/drivers/gpu/nova-core/bitstruct.rs +++ b/drivers/gpu/nova-core/bitstruct.rs @@ -9,7 +9,7 @@ /// /// ```rust /// bitstruct! { -/// struct ControlReg: u32 { +/// pub struct ControlReg: u32 { /// 3:0 mode as u8 ?=3D> Mode; /// 7:4 state as u8 =3D> State; /// } @@ -34,21 +34,21 @@ /// and returns the result. This is useful with fields for which not all= values are valid. macro_rules! bitstruct { // Main entry point - defines the bitfield struct with fields - (struct $name:ident : $storage:ty $(, $comment:literal)? { $($fields:t= t)* }) =3D> { - bitstruct!(@core $name $storage $(, $comment)? { $($fields)* }); + ($vis:vis struct $name:ident : $storage:ty $(, $comment:literal)? { $(= $fields:tt)* }) =3D> { + bitstruct!(@core $name $vis $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 $name:ident $vis:vis $storage:ty $(, $comment:literal)? { $($fi= elds:tt)* }) =3D> { $( #[doc=3D$comment] )? #[repr(transparent)] #[derive(Clone, Copy)] - pub(crate) struct $name($storage); + $vis struct $name($vis $storage); =20 impl ::core::ops::BitOr for $name { type Output =3D Self; @@ -64,14 +64,14 @@ fn from(val: $name) -> $storage { } } =20 - bitstruct!(@fields_dispatcher $name $storage { $($fields)* }); + bitstruct!(@fields_dispatcher $name $vis $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 $name:ident $vis:vis $storage:ty { $($hi:tt:$lo:tt $field:ident as $type:tt $(?=3D> $try_into_type:ty)? $(=3D> $into_type:ty)? @@ -80,7 +80,7 @@ fn from(val: $name) -> $storage { )* } ) =3D> { - bitstruct!(@field_accessors $name $storage { + bitstruct!(@field_accessors $name $vis $storage { $( $hi:$lo $field as $type $(?=3D> $try_into_type)? @@ -95,7 +95,7 @@ fn from(val: $name) -> $storage { =20 // Defines all the field getter/setter methods for `$name`. ( - @field_accessors $name:ident $storage:ty { + @field_accessors $name:ident $vis:vis $storage:ty { $($hi:tt:$lo:tt $field:ident as $type:tt $(?=3D> $try_into_type:ty)? $(=3D> $into_type:ty)? @@ -111,7 +111,7 @@ fn from(val: $name) -> $storage { #[allow(dead_code)] impl $name { $( - bitstruct!(@field_accessor $name $storage, $hi:$lo $field as $= type + bitstruct!(@field_accessor $name $vis $storage, $hi:$lo $field= as $type $(?=3D> $try_into_type)? $(=3D> $into_type)? $(, $comment)? @@ -145,11 +145,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 $name:ident $vis:vis $storage:ty, $hi:tt:$lo:tt $f= ield:ident as bool =3D> $into_type:ty $(, $comment:literal)?; ) =3D> { bitstruct!( - @leaf_accessor $name $storage, $hi:$lo $field + @leaf_accessor $name $vis $storage, $hi:$lo $field { |f| <$into_type>::from(if f !=3D 0 { true } else { false }) } $into_type =3D> $into_type $(, $comment)?; ); @@ -157,17 +157,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 $name:ident $vis:vis $storage:ty, $hi:tt:$lo:tt $f= ield:ident as bool $(, $comment:literal)?; ) =3D> { - bitstruct!(@field_accessor $name $storage, $hi:$lo $field as bool = =3D> bool $(, $comment)?;); + bitstruct!(@field_accessor $name $vis $storage, $hi:$lo $field as = bool =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 $name:ident $vis:vis $storage:ty, $hi:tt:$lo:tt $f= ield:ident as $type:tt ?=3D> $try_into_type:ty $(, $comment:literal)?; ) =3D> { - bitstruct!(@leaf_accessor $name $storage, $hi:$lo $field + bitstruct!(@leaf_accessor $name $vis $storage, $hi:$lo $field { |f| <$try_into_type>::try_from(f as $type) } $try_into_type = =3D> ::core::result::Result< $try_into_type, @@ -178,24 +178,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 $name:ident $vis:vis $storage:ty, $hi:tt:$lo:tt $f= ield:ident as $type:tt =3D> $into_type:ty $(, $comment:literal)?; ) =3D> { - bitstruct!(@leaf_accessor $name $storage, $hi:$lo $field + bitstruct!(@leaf_accessor $name $vis $storage, $hi:$lo $field { |f| <$into_type>::from(f as $type) } $into_type =3D> $into_t= ype $(, $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 $name:ident $vis:vis $storage:ty, $hi:tt:$lo:tt $f= ield:ident as $type:tt $(, $comment:literal)?; ) =3D> { - bitstruct!(@field_accessor $name $storage, $hi:$lo $field as $type= =3D> $type $(, $comment)?;); + bitstruct!(@field_accessor $name $vis $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 $name:ident $vis:vis $storage:ty, $hi:tt:$lo:tt $fi= eld:ident { $process:expr } $to_type:ty =3D> $res_type:ty $(, $comment:l= iteral)?; ) =3D> { ::kernel::macros::paste!( @@ -218,7 +218,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>]; @@ -234,7 +234,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(value) << SHIFT) & MASK; diff --git a/drivers/gpu/nova-core/regs/macros.rs b/drivers/gpu/nova-core/r= egs/macros.rs index bbfeab147c9f..22a53a73b765 100644 --- a/drivers/gpu/nova-core/regs/macros.rs +++ b/drivers/gpu/nova-core/regs/macros.rs @@ -284,25 +284,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> { - bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); + bitstruct!(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> { - bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); + bitstruct!(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> { - bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); + bitstruct!(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> { - bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); + bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields= )* } ); register!(@io_relative $name @ $base [ $alias::OFFSET ]); }; =20 @@ -313,7 +313,7 @@ macro_rules! register { } ) =3D> { static_assert!(::core::mem::size_of::() <=3D $stride); - bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); + bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields= )* } ); register!(@io_array $name @ $offset [ $size ; $stride ]); }; =20 @@ -334,7 +334,7 @@ macro_rules! register { $(, $comment:literal)? { $($fields:tt)* } ) =3D> { static_assert!(::core::mem::size_of::() <=3D $stride); - bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); + bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields= )* } ); register!(@io_relative_array $name @ $base [ $offset [ $size ; $st= ride ] ]); }; =20 @@ -356,7 +356,7 @@ macro_rules! register { } ) =3D> { static_assert!($idx < $alias::SIZE); - bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); + bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields= )* } ); register!(@io_relative $name @ $base [ $alias::OFFSET + $idx * $al= ias::STRIDE ] ); }; =20 @@ -365,7 +365,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); - bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); + bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields= )* } ); register!(@io_fixed $name @ $alias::OFFSET + $idx * $alias::STRIDE= ); }; =20 --=20 2.34.1