From d99f294281a0c84d269289801fc4058c4eacb514 Mon Sep 17 00:00:00 2001
From: Wei Liu <liuwe@microsoft.com>
Date: Sat, 27 Apr 2024 01:31:37 +0000
Subject: [PATCH] pci: rename as_any to as_any_mut

That trait function returns a mutable reference. Rename it to follow
Rust's convention.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
 devices/src/pvmemcontrol.rs                | 2 +-
 devices/src/pvpanic.rs                     | 2 +-
 pci/src/bus.rs                             | 2 +-
 pci/src/device.rs                          | 2 +-
 pci/src/vfio.rs                            | 2 +-
 pci/src/vfio_user.rs                       | 2 +-
 virtio-devices/src/transport/pci_device.rs | 2 +-
 vmm/src/device_manager.rs                  | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/devices/src/pvmemcontrol.rs b/devices/src/pvmemcontrol.rs
index 5721ed65e..f28e1b257 100644
--- a/devices/src/pvmemcontrol.rs
+++ b/devices/src/pvmemcontrol.rs
@@ -708,7 +708,7 @@ impl PciDevice for PvmemcontrolPciDevice {
         self.configuration.read_config_register(reg_idx)
     }
 
-    fn as_any(&mut self) -> &mut dyn std::any::Any {
+    fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
         self
     }
 
diff --git a/devices/src/pvpanic.rs b/devices/src/pvpanic.rs
index 0142e3725..ca86a4ae0 100644
--- a/devices/src/pvpanic.rs
+++ b/devices/src/pvpanic.rs
@@ -237,7 +237,7 @@ impl PciDevice for PvPanicDevice {
         data[0] = self.events;
     }
 
-    fn as_any(&mut self) -> &mut dyn Any {
+    fn as_any_mut(&mut self) -> &mut dyn Any {
         self
     }
 
diff --git a/pci/src/bus.rs b/pci/src/bus.rs
index 976b0a249..aa0bc9547 100644
--- a/pci/src/bus.rs
+++ b/pci/src/bus.rs
@@ -90,7 +90,7 @@ impl PciDevice for PciRoot {
         self.config.read_reg(reg_idx)
     }
 
-    fn as_any(&mut self) -> &mut dyn Any {
+    fn as_any_mut(&mut self) -> &mut dyn Any {
         self
     }
 
diff --git a/pci/src/device.rs b/pci/src/device.rs
index 87dc6da84..d74b46f73 100644
--- a/pci/src/device.rs
+++ b/pci/src/device.rs
@@ -115,7 +115,7 @@ pub trait PciDevice: Send {
     }
     /// Provides a mutable reference to the Any trait. This is useful to let
     /// the caller have access to the underlying type behind the trait.
-    fn as_any(&mut self) -> &mut dyn Any;
+    fn as_any_mut(&mut self) -> &mut dyn Any;
 
     /// Optionally returns a unique identifier.
     fn id(&self) -> Option<String>;
diff --git a/pci/src/vfio.rs b/pci/src/vfio.rs
index 63feab37a..77f8c3183 100644
--- a/pci/src/vfio.rs
+++ b/pci/src/vfio.rs
@@ -1893,7 +1893,7 @@ impl PciDevice for VfioPciDevice {
         Ok(())
     }
 
-    fn as_any(&mut self) -> &mut dyn Any {
+    fn as_any_mut(&mut self) -> &mut dyn Any {
         self
     }
 
diff --git a/pci/src/vfio_user.rs b/pci/src/vfio_user.rs
index 1cd481421..f2c723b10 100644
--- a/pci/src/vfio_user.rs
+++ b/pci/src/vfio_user.rs
@@ -422,7 +422,7 @@ impl PciDevice for VfioUserPciDevice {
             .free_bars(allocator, mmio32_allocator, mmio64_allocator)
     }
 
-    fn as_any(&mut self) -> &mut dyn Any {
+    fn as_any_mut(&mut self) -> &mut dyn Any {
         self
     }
 
diff --git a/virtio-devices/src/transport/pci_device.rs b/virtio-devices/src/transport/pci_device.rs
index 0a12dcc4f..d96e78bd4 100644
--- a/virtio-devices/src/transport/pci_device.rs
+++ b/virtio-devices/src/transport/pci_device.rs
@@ -1249,7 +1249,7 @@ impl PciDevice for VirtioPciDevice {
         None
     }
 
-    fn as_any(&mut self) -> &mut dyn Any {
+    fn as_any_mut(&mut self) -> &mut dyn Any {
         self
     }
 
diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs
index 8b3c20e57..e2ac0d236 100644
--- a/vmm/src/device_manager.rs
+++ b/vmm/src/device_manager.rs
@@ -644,7 +644,7 @@ impl DeviceRelocation for AddressManager {
             }
         }
 
-        let any_dev = pci_dev.as_any();
+        let any_dev = pci_dev.as_any_mut();
         if let Some(virtio_pci_dev) = any_dev.downcast_ref::<VirtioPciDevice>() {
             let bar_addr = virtio_pci_dev.config_bar_addr();
             if bar_addr == new_base {