]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
rust/hpet: Reduce unnecessary mutable self argument
authorZhao Liu <zhao1.liu@intel.com>
Thu, 13 Nov 2025 05:19:22 +0000 (13:19 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 27 Dec 2025 09:11:10 +0000 (10:11 +0100)
Methods of Timer and InterruptSource have been made as safe, so make the
related methods of HPETTimer to accept immutable self reference.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20251113051937.4017675-8-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/hw/timer/hpet/src/device.rs

index a2c5b7d04c6048a1a3127bf07b924a330f58b506..ddfdf5185ad63cfc9b78e4c86826df408c3074ed 100644 (file)
@@ -318,7 +318,7 @@ impl HPETTimer {
         }
     }
 
-    fn set_irq(&mut self, set: bool) {
+    fn set_irq(&self, set: bool) {
         let route = self.get_int_route();
 
         if set && self.is_int_enabled() && self.get_state().is_hpet_enabled() {
@@ -344,7 +344,7 @@ impl HPETTimer {
         }
     }
 
-    fn update_irq(&mut self, set: bool) {
+    fn update_irq(&self, set: bool) {
         // If Timer N Interrupt Enable bit is 0, "the timer will
         // still operate and generate appropriate status bits, but
         // will not cause an interrupt"
@@ -382,7 +382,7 @@ impl HPETTimer {
         self.arm_timer(self.cmp64);
     }
 
-    fn del_timer(&mut self) {
+    fn del_timer(&self) {
         // Just remove the timer from the timer_list without destroying
         // this timer instance.
         self.qemu_timer.delete();
@@ -656,7 +656,7 @@ impl HPETState {
             self.counter.set(self.get_ticks());
 
             for timer in self.timers.iter().take(self.num_timers) {
-                timer.borrow_mut().del_timer();
+                timer.borrow().del_timer();
             }
         }
 
@@ -680,7 +680,7 @@ impl HPETState {
 
         for (index, timer) in self.timers.iter().take(self.num_timers).enumerate() {
             if cleared & (1 << index) != 0 {
-                timer.borrow_mut().update_irq(false);
+                timer.borrow().update_irq(false);
             }
         }
     }