[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260130-coherent-array-v1-4-bcd672dacc70@nvidia.com>
Date: Fri, 30 Jan 2026 17:34:07 +0900
From: Eliot Courtney <ecourtney@...dia.com>
To: Danilo Krummrich <dakr@...nel.org>,
Alexandre Courbot <acourbot@...dia.com>, Alice Ryhl <aliceryhl@...gle.com>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Abdiel Janulgue <abdiel.janulgue@...il.com>,
Daniel Almeida <daniel.almeida@...labora.com>,
Robin Murphy <robin.murphy@....com>,
Andreas Hindborg <a.hindborg@...nel.org>, Miguel Ojeda <ojeda@...nel.org>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Trevor Gross <tmgross@...ch.edu>
Cc: nouveau@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, driver-core@...ts.linux.dev,
rust-for-linux@...r.kernel.org, Eliot Courtney <ecourtney@...dia.com>
Subject: [PATCH 4/9] rust: dma: simplify try_dma_read! and try_dma_write!
Remove unnecessary branch and unify branch order.
Signed-off-by: Eliot Courtney <ecourtney@...dia.com>
---
rust/kernel/dma.rs | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs
index 43ed0dfdbc08..03fc001eb983 100644
--- a/rust/kernel/dma.rs
+++ b/rust/kernel/dma.rs
@@ -875,9 +875,6 @@ macro_rules! try_dma_read {
}
})()
}};
- ($dma:ident [ $idx:expr ] $($field:tt)* ) => {
- $crate::try_dma_read!($dma, $idx, $($field)*)
- };
($($dma:ident).* [ $idx:expr ] $($field:tt)* ) => {
$crate::try_dma_read!($($dma).*, $idx, $($field)*)
};
@@ -905,13 +902,7 @@ macro_rules! try_dma_read {
/// ```
#[macro_export]
macro_rules! try_dma_write {
- ($dma:ident [ $idx:expr ] $($field:tt)*) => {{
- $crate::try_dma_write!($dma, $idx, $($field)*)
- }};
- ($($dma:ident).* [ $idx:expr ] $($field:tt)* ) => {{
- $crate::try_dma_write!($($dma).*, $idx, $($field)*)
- }};
- ($dma:expr, $idx: expr, = $val:expr) => {
+ ($dma:expr, $idx:expr, = $val:expr) => {
(|| -> ::core::result::Result<_, $crate::error::Error> {
let item = $crate::dma::CoherentAllocation::try_item_from_index(&$dma, $idx)?;
// SAFETY: `try_item_from_index` ensures that `item` is always a valid item.
@@ -919,7 +910,7 @@ macro_rules! try_dma_write {
::core::result::Result::Ok(())
})()
};
- ($dma:expr, $idx: expr, $(.$field:ident)* = $val:expr) => {
+ ($dma:expr, $idx:expr, $(.$field:ident)* = $val:expr) => {
(|| -> ::core::result::Result<_, $crate::error::Error> {
let item = $crate::dma::CoherentAllocation::try_item_from_index(&$dma, $idx)?;
// SAFETY: `try_item_from_index` ensures that `item` is always a valid pointer
@@ -932,4 +923,7 @@ macro_rules! try_dma_write {
::core::result::Result::Ok(())
})()
};
+ ($($dma:ident).* [ $idx:expr ] $($field:tt)* ) => {{
+ $crate::try_dma_write!($($dma).*, $idx, $($field)*)
+ }};
}
--
2.52.0
Powered by blists - more mailing lists