diff options
Diffstat (limited to 'samples/rust/rust_dma.rs')
| -rw-r--r-- | samples/rust/rust_dma.rs | 28 | 
1 files changed, 15 insertions, 13 deletions
| diff --git a/samples/rust/rust_dma.rs b/samples/rust/rust_dma.rs index 12370bca97bc..c5e7cce68654 100644 --- a/samples/rust/rust_dma.rs +++ b/samples/rust/rust_dma.rs @@ -66,13 +66,9 @@ impl pci::Driver for DmaSampleDriver {          let ca: CoherentAllocation<MyStruct> =              CoherentAllocation::alloc_coherent(pdev.as_ref(), TEST_VALUES.len(), GFP_KERNEL)?; -        || -> Result { -            for (i, value) in TEST_VALUES.into_iter().enumerate() { -                kernel::dma_write!(ca[i] = MyStruct::new(value.0, value.1)); -            } - -            Ok(()) -        }()?; +        for (i, value) in TEST_VALUES.into_iter().enumerate() { +            kernel::dma_write!(ca[i] = MyStruct::new(value.0, value.1))?; +        }          let drvdata = KBox::new(              Self { @@ -90,13 +86,19 @@ impl Drop for DmaSampleDriver {      fn drop(&mut self) {          dev_info!(self.pdev.as_ref(), "Unload DMA test driver.\n"); -        let _ = || -> Result { -            for (i, value) in TEST_VALUES.into_iter().enumerate() { -                assert_eq!(kernel::dma_read!(self.ca[i].h), value.0); -                assert_eq!(kernel::dma_read!(self.ca[i].b), value.1); +        for (i, value) in TEST_VALUES.into_iter().enumerate() { +            let val0 = kernel::dma_read!(self.ca[i].h); +            let val1 = kernel::dma_read!(self.ca[i].b); +            assert!(val0.is_ok()); +            assert!(val1.is_ok()); + +            if let Ok(val0) = val0 { +                assert_eq!(val0, value.0); +            } +            if let Ok(val1) = val1 { +                assert_eq!(val1, value.1);              } -            Ok(()) -        }(); +        }      }  } | 
