[PATCH] virtio_pci: use container_of replace type conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace type conversion with container_of() in
vp_modern_set_queue_reset()/vp_modern_get_queue_reset() .
Also combine declarations and assignments.

Signed-off-by: Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx>
---
 drivers/virtio/virtio_pci_modern_dev.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio_pci_modern_dev.c
index 869cb46bef96..530c954439de 100644
--- a/drivers/virtio/virtio_pci_modern_dev.c
+++ b/drivers/virtio/virtio_pci_modern_dev.c
@@ -482,12 +482,12 @@ EXPORT_SYMBOL_GPL(vp_modern_set_status);
  */
 int vp_modern_get_queue_reset(struct virtio_pci_modern_device *mdev, u16 index)
 {
-	struct virtio_pci_modern_common_cfg __iomem *cfg;
-
-	cfg = (struct virtio_pci_modern_common_cfg __iomem *)mdev->common;
+	struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
+	struct virtio_pci_modern_common_cfg __iomem *mcfg =
+		container_of(cfg, struct virtio_pci_modern_common_cfg, cfg);
 
-	vp_iowrite16(index, &cfg->cfg.queue_select);
-	return vp_ioread16(&cfg->queue_reset);
+	vp_iowrite16(index, &cfg->queue_select);
+	return vp_ioread16(&mcfg->queue_reset);
 }
 EXPORT_SYMBOL_GPL(vp_modern_get_queue_reset);
 
@@ -498,17 +498,17 @@ EXPORT_SYMBOL_GPL(vp_modern_get_queue_reset);
  */
 void vp_modern_set_queue_reset(struct virtio_pci_modern_device *mdev, u16 index)
 {
-	struct virtio_pci_modern_common_cfg __iomem *cfg;
-
-	cfg = (struct virtio_pci_modern_common_cfg __iomem *)mdev->common;
+	struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
+	struct virtio_pci_modern_common_cfg __iomem *mcfg =
+		container_of(cfg, struct virtio_pci_modern_common_cfg, cfg);
 
-	vp_iowrite16(index, &cfg->cfg.queue_select);
-	vp_iowrite16(1, &cfg->queue_reset);
+	vp_iowrite16(index, &cfg->queue_select);
+	vp_iowrite16(1, &mcfg->queue_reset);
 
-	while (vp_ioread16(&cfg->queue_reset))
+	while (vp_ioread16(&mcfg->queue_reset))
 		msleep(1);
 
-	while (vp_ioread16(&cfg->cfg.queue_enable))
+	while (vp_ioread16(&cfg->queue_enable))
 		msleep(1);
 }
 EXPORT_SYMBOL_GPL(vp_modern_set_queue_reset);
-- 
2.31.0

_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux