All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	virtualization <virtualization@lists.linux-foundation.org>
Subject: Re: [PATCH] virtio_pci: use container_of replace type conversion
Date: Fri, 19 Aug 2022 14:30:12 +0800	[thread overview]
Message-ID: <CACGkMEsZrbbi6uWBWumrrfYzD+UySsK4ZTtoOZ0wOMZDAgfnmw@mail.gmail.com> (raw)
In-Reply-To: <20220816030559.111057-1-xuanzhuo@linux.alibaba.com>

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

      reply	other threads:[~2022-08-19  6:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  3:05 [PATCH] virtio_pci: use container_of replace type conversion Xuan Zhuo
2022-08-19  6:30 ` Jason Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACGkMEsZrbbi6uWBWumrrfYzD+UySsK4ZTtoOZ0wOMZDAgfnmw@mail.gmail.com \
    --to=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.