[PATCH v6 3/8] rust: pwm: Add core 'Device' and 'Chip' object wrappers

Danilo Krummrich dakr at kernel.org
Tue Jul 1 10:14:37 PDT 2025


On 7/1/25 6:01 PM, Michal Wilczynski wrote:
> +    /// Returns a reference to the parent device of this PWM chip's device.
> +    pub fn parent_device(&self) -> Option<&device::Device> {
> +        self.device().parent()
> +    }

I know what you use this for, i.e. to provide a &Device<Bound> reference in your
class device callbacks -- that's great!

But please don't expose this to the public. I think what you want instead is a
private unsafe method that returns you the &Device<Bound> directly, since you
also know that you set a valid parent device, hence no need to mess with the
Option as well.

And again, sorry for not catching it right away.

- Danilo



More information about the linux-riscv mailing list