On 10/27/2025 2:23 PM, Zhao Liu wrote: > On Sat, Oct 25, 2025 at 12:38:49PM +0000, chenmiao wrote: >> Date: Sat, 25 Oct 2025 12:38:49 +0000 >> From: chenmiao <[email protected]> >> 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 <[email protected]> >> --- >> 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
Hi Zhao, Thanks for your review, I'll revisions based on your suggestions after all the patches reviewed. Regards, Chen Miao
