qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] vfio: Fix BAR->VFIODevice translation in vfio_bar_r


From: Jan Kiszka
Subject: [Qemu-devel] [PATCH] vfio: Fix BAR->VFIODevice translation in vfio_bar_read/write
Date: Mon, 08 Oct 2012 12:45:12 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

DO_UPCAST is supposed to translate from the first member of a struct to
that struct, not from arbitrary ones. And it (usually) breaks the build
when neglecting this rule. Use container_of to fix the build breakage
and likely also the runtime behavior.

Signed-off-by: Jan Kiszka <address@hidden>
---
 hw/vfio_pci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c
index a1eeced..d36d50e 100644
--- a/hw/vfio_pci.c
+++ b/hw/vfio_pci.c
@@ -601,7 +601,7 @@ static void vfio_bar_write(void *opaque, target_phys_addr_t 
addr,
      * which access will service the interrupt, so we're potentially
      * getting quite a few host interrupts per guest interrupt.
      */
-    vfio_eoi(DO_UPCAST(VFIODevice, bars[bar->nr], bar));
+    vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
 }
 
 static uint64_t vfio_bar_read(void *opaque,
@@ -641,7 +641,7 @@ static uint64_t vfio_bar_read(void *opaque,
             __func__, bar->nr, addr, size, data);
 
     /* Same as write above */
-    vfio_eoi(DO_UPCAST(VFIODevice, bars[bar->nr], bar));
+    vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
 
     return data;
 }
-- 
1.7.3.4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]