From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLXy3-0002Qm-KI for qemu-devel@nongnu.org; Tue, 19 Jan 2016 10:13:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLXxx-0004gO-IQ for qemu-devel@nongnu.org; Tue, 19 Jan 2016 10:13:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60857) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLXxx-0004gJ-E8 for qemu-devel@nongnu.org; Tue, 19 Jan 2016 10:13:05 -0500 Date: Tue, 19 Jan 2016 13:13:02 -0200 From: Eduardo Habkost Message-ID: <20160119151302.GB3869@thinpad.lan.raisama.net> References: <1451994098-6972-1-git-send-email-kraxel@redhat.com> <1451994098-6972-6-git-send-email-kraxel@redhat.com> <1452095101.6096.55.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1452095101.6096.55.camel@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 05/11] igd: TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE: call parent realize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: igvt-g@ml01.01.org, xen-devel@lists.xensource.com, Stefano Stabellini , qemu-devel@nongnu.org, Cao jin , vfio-users@redhat.com On Wed, Jan 06, 2016 at 04:45:01PM +0100, Gerd Hoffmann wrote: > > > > > > +static void (*i440fx_realize)(PCIDevice *pci_dev, Error **errp); > > > static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp) > > > { > > > + Error *err = NULL; > > > uint32_t val = 0; > > > int rc, i, num; > > > int pos, len; > > > > Can't we get the parent PCIDeviceClass realize function from pci_dev? So > > that we don't have to introduce i440fx_realize? > > I don't think so ... > > > > > > > + i440fx_realize = k->realize; > > > k->realize = igd_pt_i440fx_realize; > > ... because we are overriding it right here. Many device classes have a parent_realize field so they can keep a pointer to the original realize function. It's better than a static variable. -- Eduardo From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eduardo Habkost Subject: Re: [PATCH v3 05/11] igd: TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE: call parent realize Date: Tue, 19 Jan 2016 13:13:02 -0200 Message-ID: <20160119151302.GB3869@thinpad.lan.raisama.net> References: <1451994098-6972-1-git-send-email-kraxel@redhat.com> <1451994098-6972-6-git-send-email-kraxel@redhat.com> <1452095101.6096.55.camel@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1452095101.6096.55.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: vfio-users-bounces-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org Errors-To: vfio-users-bounces-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org To: Gerd Hoffmann Cc: igvt-g-y27Ovi1pjclAfugRpC6u6w@public.gmane.org, xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.org, Stefano Stabellini , qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.org, Cao jin , vfio-users-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org List-Id: xen-devel@lists.xenproject.org On Wed, Jan 06, 2016 at 04:45:01PM +0100, Gerd Hoffmann wrote: > > > > > > +static void (*i440fx_realize)(PCIDevice *pci_dev, Error **errp); > > > static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp) > > > { > > > + Error *err = NULL; > > > uint32_t val = 0; > > > int rc, i, num; > > > int pos, len; > > > > Can't we get the parent PCIDeviceClass realize function from pci_dev? So > > that we don't have to introduce i440fx_realize? > > I don't think so ... > > > > > > > + i440fx_realize = k->realize; > > > k->realize = igd_pt_i440fx_realize; > > ... because we are overriding it right here. Many device classes have a parent_realize field so they can keep a pointer to the original realize function. It's better than a static variable. -- Eduardo