Thank you for your contribution! Sashiko AI review found 2 potential issue(s) 
to consider:
- [Low] Missing generic lifetime parameter on Generic Associated Type (GAT) 
`Self::Data`.
- [Low] Type mismatch between `&pci::Device<Core<'_>>` and 
`&pci::Device<Bound>` in struct field initialization.
--

commit e990389a909f2dd12217de05acd654c0fd95ac40
Author: Danilo Krummrich <[email protected]>

samples: rust_dma: separate driver type from driver data

This commit splits the DmaSampleDriver into a driver type and a separate
DmaSampleData struct for device private data. It updates the associated Data
type to carry a lifetime bound, preparing for future changes to
dma::Coherent.

> diff --git a/samples/rust/rust_dma.rs b/samples/rust/rust_dma.rs
> index bd60034ded23a..0fac9d4ae566e 100644
> --- a/samples/rust/rust_dma.rs
> +++ b/samples/rust/rust_dma.rs
[ ... ]
> @@ -67,13 +71,13 @@ unsafe impl kernel::transmute::FromBytes for MyStruct {}
>  
>  impl pci::Driver for DmaSampleDriver {
>      type IdInfo = ();
> -    type Data<'bound> = Self;
> +    type Data<'bound> = DmaSampleData<'bound>;
>      const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;
>  
>      fn probe<'bound>(
>          pdev: &'bound pci::Device<Core<'_>>,
>          _info: Option<&'bound Self::IdInfo>,
> -    ) -> impl PinInit<Self, Error> + 'bound {
> +    ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
>          pin_init::pin_init_scope(move || {
>              dev_info!(pdev, "Probe DMA test driver.\n");
>  
> @@ -94,8 +98,8 @@ fn probe<'bound>(
>  
>              let sgt = SGTable::new(pdev.as_ref(), pages, 
> DataDirection::ToDevice, GFP_KERNEL);
>  
> -            Ok(try_pin_init!(Self {
> -                pdev: pdev.into(),
> +            Ok(try_pin_init!(Self::Data {

[Severity: Low]
Does this code build without explicitly providing the lifetime parameter
for the Generic Associated Type (GAT)? 

Rust typically requires explicit generic parameters for GATs used in paths,
so using Self::Data here might trigger a missing generics build error.

> +                pdev,

[Severity: Low]
Is there a type mismatch during the struct initialization here?

The probe() function receives pdev as &'bound pci::Device<Core<'_>>, but
the DmaSampleData struct definition expects &'bound pci::Device<Bound>:

struct DmaSampleData<'bound> {
    pdev: &'bound pci::Device<Bound>,
    ...
}

Since implicit Deref coercions do not apply to struct field initializations,
this direct assignment could cause a compilation failure.

>                  ca,
>                  sgt <- sgt,
>              }))

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=3

Reply via email to