]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
rust: qdev: make reset take a shared reference
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 2 Dec 2024 11:40:18 +0000 (12:40 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 28 Jan 2025 16:58:09 +0000 (17:58 +0100)
Because register reset is within a borrow_mut() call, reset
does not need anymore a mut reference to the PL011State.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/hw/char/pl011/src/device.rs
rust/qemu-api/src/qdev.rs

index bb6a6e4daf6053b8805df3d3c84595b1561adb06..8050ede9c85bfaf2c9aad4fff5bc173d1c4f3a33 100644 (file)
@@ -172,7 +172,7 @@ impl DeviceImpl for PL011State {
         Some(&device_class::VMSTATE_PL011)
     }
     const REALIZE: Option<fn(&Self)> = Some(Self::realize);
-    const RESET: Option<fn(&mut Self)> = Some(Self::reset);
+    const RESET: Option<fn(&Self)> = Some(Self::reset);
 }
 
 impl PL011Registers {
@@ -631,7 +631,7 @@ impl PL011State {
         }
     }
 
-    pub fn reset(&mut self) {
+    pub fn reset(&self) {
         self.regs.borrow_mut().reset();
     }
 
index 42429903aaec24f7d6fb2a52c7e78b47c1c9cc7c..f4c75c752f1733c01e6485d99b00f7ddbbcb2283 100644 (file)
@@ -30,7 +30,7 @@ pub trait DeviceImpl {
     ///
     /// Rust does not yet support the three-phase reset protocol; this is
     /// usually okay for leaf classes.
-    const RESET: Option<fn(&mut Self)> = None;
+    const RESET: Option<fn(&Self)> = None;
 
     /// An array providing the properties that the user can set on the
     /// device.  Not a `const` because referencing statics in constants