Re: [dpdk-dev] [PATCH 03/40] net/virtio: refactor virtio-user device
From: David Marchand <hidden>
Date: 2021-01-05 21:16:34
From: David Marchand <hidden>
Date: 2021-01-05 21:16:34
On Sun, Dec 20, 2020 at 10:14 PM Maxime Coquelin [off-list ref] wrote:
This patch moves the virtio_hw structure into the virtio_user_dev structure, with the goal of making virtio_hw bus-agnostic. Signed-off-by: Maxime Coquelin <redacted>
Just one comment, the rest lgtm.
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 516d0ee577..1f1f63a1a5 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c@@ -26,13 +26,13 @@ #include "virtio_user/virtio_user_dev.h" #include "virtio_user/vhost.h" -#define virtio_user_get_dev(hw) \ - ((struct virtio_user_dev *)(hw)->virtio_user_dev) +#define virtio_user_get_dev(hw) container_of(hw, struct virtio_user_dev, hw)
Since the hw parameter is expanded as both the object and the field name too, this macro prevents us from calling anything but virtio_user_get_dev(hw). -- David Marchand