From: Alexander Gordeev Subject: Re: [PATCH kvm-unit-tests 06/17] pci: introduce struct pci_dev Date: Tue, 8 Nov 2016 18:46:13 +0100 Message-ID: <20161108174613.GC10352@agordeev.lab.eng.brq.redhat.com> References: <1477468040-21034-1-git-send-email-peterx@redhat.com> <1477468040-21034-7-git-send-email-peterx@redhat.com> <20161104164101.ymyxzkjbbpsr4mbr@kamzik.brq.redhat.com> <20161108122730.GH10472@agordeev.lab.eng.brq.redhat.com> <20161108154832.GF2793@pxdev.xzpeter.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Andrew Jones , kvm@vger.kernel.org, rkrcmar@redhat.com, jan.kiszka@web.de, pbonzini@redhat.com To: Peter Xu Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58052 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbcKHRit (ORCPT ); Tue, 8 Nov 2016 12:38:49 -0500 Content-Disposition: inline In-Reply-To: <20161108154832.GF2793@pxdev.xzpeter.org> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Nov 08, 2016 at 10:48:32AM -0500, Peter Xu wrote: > > Both ways look strange to me. I would leave pci_find_dev() as is (low- > > level) and move pci_dev_init() outside - so a usage would be i.e.: > > > > dev = pci_find_dev(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_TEST); > > if (dev == PCIDEVADDR_INVALID) > > ... > > pci_dev_init(&pci_dev, dev); > > IMHO actually it'll be nicer with: > > struct pci_dev *pci_find_dev(uint16_t vendor_id, uint16_t device_id); I hesitated to propose this one, but IMO it is the most clear way everybody are accustomed to :) > But this needs dynamic allocation of memory, which might be an > overkill for kvm-unit-test. So I chose to allocate the pci_dev on > caller stack. Well, the dynamic allocation is implemented and utilized, so why not? > Anyway, I take the interface issue as a matter of taste. > > How about I take Drew's suggestion here with true/false? Then if we > have any better idea with solid reasons, we can post seperate patch > for it. As far as I am concerned in all disputed cases Drew's opinion prevails ;) > Thanks, > > -- peterx