On Wed Feb 4, 2026 at 5:04 AM CET, Link Mauve wrote:
> +impl Device {
> +    /// Register a managed nvmem provider on the given device.
> +    pub fn nvmem_register<T>(&self, mut config: NvmemConfig<T>, priv_: 
> &T::Priv)
> +    where
> +        T: NvmemProvider + Default,
> +    {
> +        // FIXME: The last cast to mut indicates some unsoundness here.
> +        config.inner.priv_ = 
> core::ptr::from_ref(priv_).cast::<c_void>().cast_mut();
> +        config.inner.dev = self.as_raw();
> +        config.inner.reg_read = Some(NvmemConfig::<T>::reg_read);
> +        config.inner.reg_write = Some(NvmemConfig::<T>::reg_write);
> +        // SAFETY: Both self and config can’t be null here, and should have 
> the correct type.
> +        unsafe { bindings::devm_nvmem_register(self.as_raw(), &config.inner) 
> };
> +    }
> +}

This should not be a method on the generic device type. Typically we use a
Registration struct for this, i.e. this would become
nvmem::Registration::register().

Reply via email to