Received: from eggs.gnu.org ([2001:4830:134:3::10]:54345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9YUB-0002KO-Ln for qemu-devel@nongnu.org; Mon, 29 Jun 2015 08:48:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9YU8-0002Ec-FH for qemu-devel@nongnu.org; Mon, 29 Jun 2015 08:48:31 -0400 Received: from mail-qk0-f172.google.com ([209.85.220.172]:34291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9YU8-0002Do-Bf for qemu-devel@nongnu.org; Mon, 29 Jun 2015 08:48:28 -0400 Received: by qkeo142 with SMTP id o142so93676057qke.1 for ; Mon, 29 Jun 2015 05:48:26 -0700 (PDT) Date: Mon, 29 Jun 2015 08:48:24 -0400 From: Kevin O'Connor Message-ID: <20150629124823.GA30040@morn.localdomain> References: <1435568020-8669-1-git-send-email-kraxel@redhat.com> <1435568020-8669-4-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1435568020-8669-4-git-send-email-kraxel@redhat.com> Subject: Re: [Qemu-devel] [SeaBIOS] [PATCH 03/18] virtio: add struct vp_device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: seabios@seabios.org, qemu-devel@nongnu.org, "Michael S. Tsirkin" On Mon, Jun 29, 2015 at 10:53:25AM +0200, Gerd Hoffmann wrote: > For virtio 1.0 support we will need more state than just the (legacy > mode) ioaddr for each virtio-pci device. Prepare for that by adding > a new struct for it. For now it carries the ioaddr only. > > Signed-off-by: Gerd Hoffmann > --- > src/hw/virtio-blk.c | 20 ++++++++++---------- > src/hw/virtio-pci.c | 15 +++++++++------ > src/hw/virtio-pci.h | 46 +++++++++++++++++++++++++++------------------- > src/hw/virtio-ring.c | 4 ++-- > src/hw/virtio-ring.h | 3 ++- > src/hw/virtio-scsi.c | 32 +++++++++++++++++--------------- > 6 files changed, 67 insertions(+), 53 deletions(-) > > diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c > index 15ac171..13cf09a 100644 > --- a/src/hw/virtio-blk.c > +++ b/src/hw/virtio-blk.c > @@ -25,7 +25,7 @@ > struct virtiodrive_s { > struct drive_s drive; > struct vring_virtqueue *vq; > - u16 ioaddr; > + struct vp_device *vp; > }; Is there a reason to make this a pointer as opposed to just placing the vp_device struct directly in struct virtiodrive_s? > -u16 vp_init_simple(u16 bdf) > +struct vp_device *vp_init_simple(u16 bdf) > { > - u16 ioaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0) & > + struct vp_device *vp = malloc_low(sizeof(*vp)); > + > + vp->ioaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0) & > PCI_BASE_ADDRESS_IO_MASK; If it has to be a pointer, then the result of malloc_low() has to be checked for NULL. Though, I don't think malloc_low() makes sense if it's a 32bit driver. -Kevin