On Tue, Aug 16, 2022 at 11:06 AM Xuan Zhuo <[email protected]> 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 <[email protected]>

Acked-by: Jason Wang <[email protected]>

> ---
>  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
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Reply via email to