qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Zhao Liu <zhao1.liu@intel.com>
To: chenmiao <chenmiao@openatom.club>
Cc: pbonzini@redhat.com, manos.pitsidianakis@linaro.org,
	richard.henderson@linaro.org, philmd@linaro.org,
	qemu-rust@nongnu.org, qemu-devel@nongnu.org,
	hust-os-kernel-patches@googlegroups.com
Subject: Re: [RFC 1/5] rust: hw: core: Add the BusState of rust version
Date: Mon, 27 Oct 2025 14:23:20 +0800	[thread overview]
Message-ID: <aP8P2H0qk0yJMPe3@intel.com> (raw)
In-Reply-To: <20251025123853.63139-2-chenmiao@openatom.club>

On Sat, Oct 25, 2025 at 12:38:49PM +0000, chenmiao wrote:
> Date: Sat, 25 Oct 2025 12:38:49 +0000
> From: chenmiao <chenmiao@openatom.club>
> Subject: [RFC 1/5] rust: hw: core: Add the BusState of rust version
> X-Mailer: git-send-email 2.43.0
> 
> A Rust version implementation has been designed for BusState,
> which will be used for the subsequent I2CBus implementation.
> 
> Signed-off-by: chenmiao <chenmiao@openatom.club>
> ---
>  rust/hw/core/meson.build |  1 +
>  rust/hw/core/src/bus.rs  | 51 ++++++++++++++++++++++++++++++++++++++++
>  rust/hw/core/src/lib.rs  |  3 +++
>  3 files changed, 55 insertions(+)
>  create mode 100644 rust/hw/core/src/bus.rs

After a quick glance, I think this BusState is implemented quite well.

Only a few minor nits inline:

...

> +pub trait BusStateImpl: DeviceImpl + IsA<BusState> {}
> +
> +impl BusClass {
> +    pub fn class_init<T: BusStateImpl>(self: &mut BusClass) {
> +        self.parent_class.class_init::<T>();
> +    }
> +}
> +
> +pub trait BusStateMethods: ObjectDeref

This can be named BusMethods - just like DeviceMethods did.

> +where
> +    Self::Target: IsA<BusState>,
> +{
> +    fn bus_realize(&self) {

"bus_" prefix is not needed:

dummy_bus.realize() is clear and enough.

> +        assert!(bql::is_locked());

It's better to add safety comment from beginning (// SAFETY: xxx).

> +        unsafe {
> +            bindings::qbus_realize(
> +                self.upcast().as_mut_ptr(),
> +                addr_of_mut!(util::bindings::error_fatal),
> +            );
> +        }
> +    }
> +}

Regards,
Zhao




  reply	other threads:[~2025-10-27  6:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-25 12:38 [RFC 1/5] rust: hw: core: Add the BusState of rust version chenmiao
2025-10-27  6:23 ` Zhao Liu [this message]
2025-10-27  6:13   ` Chen Miao
2025-10-27  6:51   ` Chao Liu

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=aP8P2H0qk0yJMPe3@intel.com \
    --to=zhao1.liu@intel.com \
    --cc=chenmiao@openatom.club \
    --cc=hust-os-kernel-patches@googlegroups.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-rust@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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).