From: Wei Liu <wei.liu@kernel.org>
To: Antonio Martorana <amartora@codeaurora.org>
Cc: Miguel Ojeda <ojeda@kernel.org>,
Alex Gaynor <alex.gaynor@gmail.com>,
Wedson Almeida Filho <wedsonaf@google.com>,
rust-for-linux@vger.kernel.org,
Trilok Soni <tsoni@codeaurora.org>,
Elliot Berman <quic_eberman@quicinc.com>,
Wei Liu <wei.liu@kernel.org>
Subject: Re: [RFC] soc: qcom: socinfo.rs: Add Rust Socinfo Driver implementation
Date: Wed, 18 Aug 2021 09:36:39 +0000 [thread overview]
Message-ID: <20210818093639.lyse46v5wern2jem@liuwe-devbox-debian-v2> (raw)
In-Reply-To: <1629163412-157074-1-git-send-email-amartora@codeaurora.org>
On Mon, Aug 16, 2021 at 06:23:32PM -0700, Antonio Martorana wrote:
[...]
> new file mode 100644
> index 0000000..8af697a
> --- /dev/null
> +++ b/drivers/soc/qcom/socinfo_rust.rs
> @@ -0,0 +1,464 @@
> +//! Qualcomm support for socinfo.c
> +
> +#![no_std]
> +#![feature(allocator_api,global_asm)]
Not really related to this patch, but I wish there was a more ergonomic
way to specify these crate level features. I think these two lines are
c&p in a lot of places.
[...]
> +/*
> + * SoC version type with major number in the upper 16 bits and minor
> + * number in the lower 16 bits.
> + */
> +const fn socinfo_major(ver: u32) -> u32{
> + let major: u32 = (ver >> 16) & 0xFFFF;
> + return major;
This can be simplified as
const fn socinfo_major(ver: u32) -> u32 {
(ver >> 16) & 0xFFFF
}
> +}
> +
> +const fn socinfo_minor(ver: u32) -> u32{
> + let minor: u32 = ver & 0xFFFF;
> + return minor;
> +}
> +
> +const fn socinfo_version(maj: u32, min: u32) -> u32{
> + let version: u32 = ((maj & 0xFFFF) << 16) | (min & 0xFFFF);
> + return version;
> +}
Same for these two functions. They can be simplified as well.
I have one further question: why aren't these helpers implemented as
methods of SocInfo? Like:
impl SocInfo {
fn major(&self) -> u32 {
(self.ver >> 16) & 0xFFFF
}
}
Thanks,
Wei.
next prev parent reply other threads:[~2021-08-18 9:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 1:23 [RFC] soc: qcom: socinfo.rs: Add Rust Socinfo Driver implementation Antonio Martorana
2021-08-17 16:43 ` Miguel Ojeda
2021-08-18 9:36 ` Wei Liu [this message]
2021-08-20 19:38 ` [RFC v2] " Antonio Martorana
2021-08-20 22:18 ` Miguel Ojeda
2021-08-20 23:05 ` amartora
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=20210818093639.lyse46v5wern2jem@liuwe-devbox-debian-v2 \
--to=wei.liu@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=amartora@codeaurora.org \
--cc=ojeda@kernel.org \
--cc=quic_eberman@quicinc.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tsoni@codeaurora.org \
--cc=wedsonaf@google.com \
/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;
as well as URLs for NNTP newsgroup(s).