* [PATCH] virtio_pci: use container_of replace type conversion
@ 2022-08-16 3:05 Xuan Zhuo
2022-08-19 6:30 ` Jason Wang
0 siblings, 1 reply; 2+ messages in thread
From: Xuan Zhuo @ 2022-08-16 3:05 UTC (permalink / raw)
To: virtualization; +Cc: Michael S. Tsirkin
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@linux.alibaba.com>
---
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@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] virtio_pci: use container_of replace type conversion
2022-08-16 3:05 [PATCH] virtio_pci: use container_of replace type conversion Xuan Zhuo
@ 2022-08-19 6:30 ` Jason Wang
0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2022-08-19 6:30 UTC (permalink / raw)
To: Xuan Zhuo; +Cc: Michael S. Tsirkin, virtualization
On Tue, Aug 16, 2022 at 11:06 AM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
>
> 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@linux.alibaba.com>
Acked-by: Jason Wang <jasowang@redhat.com>
> ---
> 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@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-19 6:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16 3:05 [PATCH] virtio_pci: use container_of replace type conversion Xuan Zhuo
2022-08-19 6:30 ` Jason Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.