From: Danilo Krummrich <dakr@kernel.org>
To: Ayush Singh <ayush@beagleboard.org>
Cc: "Jason Kridner" <jkridner@beagleboard.org>,
"Deepak Khatri" <lorforlinux@beagleboard.org>,
"Robert Nelson" <robertcnelson@beagleboard.org>,
"Dhruva Gole" <d-gole@ti.com>, "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: kernel: device: Add of_platform_populate/depopulate
Date: Mon, 28 Apr 2025 20:39:28 +0200 [thread overview]
Message-ID: <aA_LYKhbQ0iKM7n2@cassiopeiae> (raw)
In-Reply-To: <20250428-rust-of-populate-v1-1-1d33777427c4@beagleboard.org>
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
prev parent reply other threads:[~2025-04-28 18:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-28 14:22 [PATCH] rust: kernel: device: Add of_platform_populate/depopulate Ayush Singh
2025-04-28 16:57 ` Greg Kroah-Hartman
2025-04-28 18:39 ` Danilo Krummrich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aA_LYKhbQ0iKM7n2@cassiopeiae \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=ayush@beagleboard.org \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=d-gole@ti.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=jkridner@beagleboard.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorforlinux@beagleboard.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robertcnelson@beagleboard.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox