[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aA_LYKhbQ0iKM7n2@cassiopeiae>
Date: Mon, 28 Apr 2025 20:39:28 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Ayush Singh <ayush@...gleboard.org>
Cc: Jason Kridner <jkridner@...gleboard.org>,
Deepak Khatri <lorforlinux@...gleboard.org>,
Robert Nelson <robertcnelson@...gleboard.org>,
Dhruva Gole <d-gole@...com>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rust: kernel: device: Add of_platform_populate/depopulate
On Mon, Apr 28, 2025 at 07:52:29PM +0530, Ayush Singh wrote:
> Open Questions
> ***************
>
> 1. Function names
>
> The rust implementations are based on devm_* versions of these
> functions, i.e of_platform_depopulate() is called when the device is
> unbound. Since in case of Rust, these are methods on the Device struct,
> I am not sure if the `devm_` prefix is required.
Please add the 'devm' prefix.
> 2. Maybe should be functions instead of methods?
Making those methods is the correct thing.
> + /// Populate platform_devices from device tree data
> + pub fn of_platform_populate(&self) -> crate::error::Result<()> {
> + crate::error::to_result(unsafe { bindings::devm_of_platform_populate(self.as_raw()) })
As Greg mentioned, please add the missing safety comments. Additionally, I
suggest to import to_result().
Please also make sure to go through [1].
> + }
> +
> + /// Remove devices populated from device tree
> + pub fn of_platform_depopulate(&self) {
> + unsafe { bindings::devm_of_platform_depopulate(self.as_raw()) }
> + }
> }
Please move both of those methods into
impl Device<Bound> {
which ensures that those methods can only be called for a bound device, which is
required by devres.
The impl block does not exist for Device yet, so you have to create it with your
patch.
- Danilo
[1] https://rust-for-linux.com/contributing#submit-checklist-addendum
Powered by blists - more mailing lists