aboutsummaryrefslogtreecommitdiff
path: root/rust/hw
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-11-24 18:51:34 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2024-12-11 15:57:19 +0100
commit166e8a1fd15bfa527b25fc15ca315e572c0556d2 (patch)
treed72f812798ea3ded3bda9130b0469175f49d3381 /rust/hw
parent7bd8e3ef63330e870cf4644d21c285cce35c703d (diff)
downloadqemu-166e8a1fd15bfa527b25fc15ca315e572c0556d2.zip
qemu-166e8a1fd15bfa527b25fc15ca315e572c0556d2.tar.gz
qemu-166e8a1fd15bfa527b25fc15ca315e572c0556d2.tar.bz2
rust: qom: change the parent type to an associated type
Avoid duplicated code to retrieve the QOM type strings from the Rust type. Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/hw')
-rw-r--r--rust/hw/char/pl011/src/device.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs
index 0ab825b..3e29442 100644
--- a/rust/hw/char/pl011/src/device.rs
+++ b/rust/hw/char/pl011/src/device.rs
@@ -113,7 +113,8 @@ unsafe impl ObjectType for PL011State {
}
impl ObjectImpl for PL011State {
- const PARENT_TYPE_NAME: Option<&'static CStr> = Some(<SysBusDevice as ObjectType>::TYPE_NAME);
+ type ParentType = SysBusDevice;
+
const INSTANCE_INIT: Option<unsafe fn(&mut Self)> = Some(Self::init);
}
@@ -650,7 +651,8 @@ unsafe impl ObjectType for PL011Luminary {
}
impl ObjectImpl for PL011Luminary {
- const PARENT_TYPE_NAME: Option<&'static CStr> = Some(<PL011State as ObjectType>::TYPE_NAME);
+ type ParentType = PL011State;
+
const INSTANCE_INIT: Option<unsafe fn(&mut Self)> = Some(Self::init);
}