From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: Re: [PATCH kvm-unit-tests v2 11/17] pci: provide pci_enable_defaults() Date: Mon, 14 Nov 2016 15:42:38 -0500 Message-ID: <20161114204238.GF3125@pxdev.xzpeter.org> References: <1478704224-20472-1-git-send-email-peterx@redhat.com> <1478704224-20472-12-git-send-email-peterx@redhat.com> <20161110193342.yc3rv5grgfo26knu@hawk.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: kvm@vger.kernel.org, rkrcmar@redhat.com, agordeev@redhat.com, jan.kiszka@web.de, pbonzini@redhat.com To: Andrew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:57534 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbcKNUmk (ORCPT ); Mon, 14 Nov 2016 15:42:40 -0500 Content-Disposition: inline In-Reply-To: <20161110193342.yc3rv5grgfo26knu@hawk.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Nov 10, 2016 at 08:33:42PM +0100, Andrew Jones wrote: > On Wed, Nov 09, 2016 at 10:10:18AM -0500, Peter Xu wrote: > > Provide a function to do most of the common PCI init work. > > > > Suggested-by: Andrew Jones > > Signed-off-by: Peter Xu > > --- > > lib/pci.c | 8 ++++++++ > > lib/pci.h | 1 + > > 2 files changed, 9 insertions(+) > > > > diff --git a/lib/pci.c b/lib/pci.c > > index fd17ea5..971f02e 100644 > > --- a/lib/pci.c > > +++ b/lib/pci.c > > @@ -249,3 +249,11 @@ void pci_scan_bars(struct pci_dev *dev) > > dev->bar[i] = pci_bar_get_addr(dev, i); > > } > > } > > + > > +int pci_enable_defaults(struct pci_dev *dev) > > +{ > > + pci_scan_bars(dev); > > + /* Enable device DMA operations */ > > + pci_cmd_set_clr(dev, PCI_COMMAND_MASTER, 0); > > + return 0; > > Shouldn't this be a void function that just asserts on > any errors it detects? I'm not sure why we're [currently > unconditionally] returning zero. This is my intention since I think this function might grow in the future with lots of stuffs inside, and this function will need a return code as long as any one of the future small functions will return an error. However that's really not a strong reason to have it... will remove it for your r-b. :-) Thanks, -- peterx