This function returns a pointer, so rename it to be clearer about what
it is getting.

Signed-off-by: Eliot Courtney <[email protected]>
---
 rust/kernel/dma.rs | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs
index 03fc001eb983..e4bca7a18ac1 100644
--- a/rust/kernel/dma.rs
+++ b/rust/kernel/dma.rs
@@ -559,7 +559,7 @@ pub unsafe fn try_write(&mut self, src: &[T], offset: 
usize) -> Result {
     /// Public but hidden since it should only be used from [`try_dma_read`] 
and [`try_dma_write`]
     /// macros.
     #[doc(hidden)]
-    pub fn try_item_from_index(&self, offset: usize) -> Result<*mut T> {
+    pub fn try_ptr_at(&self, offset: usize) -> Result<*mut T> {
         if offset >= self.count {
             return Err(EINVAL);
         }
@@ -863,12 +863,12 @@ unsafe impl<T: AsBytes + FromBytes + Send, Size: 
AllocationSize> Send
 macro_rules! try_dma_read {
     ($dma:expr, $idx:expr, $($field:tt)*) => {{
         (|| -> ::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
-            // and can be dereferenced. The compiler also further validates 
the expression
-            // on whether `field` is a member of `item` when expanded by the 
macro.
+            let ptr = $crate::dma::CoherentAllocation::try_ptr_at(&$dma, 
$idx)?;
+            // SAFETY: `try_ptr_at` ensures that `ptr` is always a valid 
pointer and can be
+            // dereferenced. The compiler also further validates the 
expression on whether `field`
+            // is a member of `ptr` when expanded by the macro.
             unsafe {
-                let ptr_field = ::core::ptr::addr_of!((*item) $($field)*);
+                let ptr_field = ::core::ptr::addr_of!((*ptr) $($field)*);
                 ::core::result::Result::Ok(
                     $crate::dma::CoherentAllocation::field_read(&$dma, 
ptr_field)
                 )
@@ -904,20 +904,20 @@ macro_rules! try_dma_read {
 macro_rules! try_dma_write {
     ($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.
-            unsafe { $crate::dma::CoherentAllocation::field_write(&$dma, item, 
$val) }
+            let ptr = $crate::dma::CoherentAllocation::try_ptr_at(&$dma, 
$idx)?;
+            // SAFETY: `try_ptr_at` ensures that `ptr` is always a valid ptr.
+            unsafe { $crate::dma::CoherentAllocation::field_write(&$dma, ptr, 
$val) }
             ::core::result::Result::Ok(())
         })()
     };
     ($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
-            // and can be dereferenced. The compiler also further validates 
the expression
-            // on whether `field` is a member of `item` when expanded by the 
macro.
+            let ptr = $crate::dma::CoherentAllocation::try_ptr_at(&$dma, 
$idx)?;
+            // SAFETY: `try_ptr_at` ensures that `ptr` is always a valid 
pointer and can be
+            // dereferenced. The compiler also further validates the 
expression on whether `field`
+            // is a member of `ptr` when expanded by the macro.
             unsafe {
-                let ptr_field = ::core::ptr::addr_of_mut!((*item) $(.$field)*);
+                let ptr_field = ::core::ptr::addr_of_mut!((*ptr) $(.$field)*);
                 $crate::dma::CoherentAllocation::field_write(&$dma, ptr_field, 
$val)
             }
             ::core::result::Result::Ok(())

-- 
2.52.0

Reply via email to