From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M8sOq-0001XW-K3 for qemu-devel@nongnu.org; Tue, 26 May 2009 04:52:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M8sOl-0001Ue-P8 for qemu-devel@nongnu.org; Tue, 26 May 2009 04:52:43 -0400 Received: from [199.232.76.173] (port=43677 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M8sOl-0001Ub-HA for qemu-devel@nongnu.org; Tue, 26 May 2009 04:52:39 -0400 Received: from mx2.redhat.com ([66.187.237.31]:38845) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M8sOk-00029Q-Ve for qemu-devel@nongnu.org; Tue, 26 May 2009 04:52:39 -0400 Date: Tue, 26 May 2009 11:49:29 +0300 From: "Michael S. Tsirkin" Subject: Re: [Qemu-devel] [PATCH 04/11] qemu: helper routines for pci access. Message-ID: <20090526084929.GA8588@redhat.com> References: <20090525122533.GE5046@redhat.com> <20090526023337.GF13076%yamahata@valinux.co.jp> <20090526064152.GH6856@redhat.com> <4A1BA345.3040104@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4A1BA345.3040104@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Carsten Otte , kvm@vger.kernel.org, Christian Borntraeger , Rusty Russell , qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, Blue Swirl , Isaku Yamahata , Paul Brook On Tue, May 26, 2009 at 11:07:33AM +0300, Avi Kivity wrote: > Michael S. Tsirkin wrote: >> On Tue, May 26, 2009 at 11:33:37AM +0900, Isaku Yamahata wrote: >> >>> On Mon, May 25, 2009 at 03:25:33PM +0300, Michael S. Tsirkin wrote: >>> >>>> Add inline routines for convenient access to pci devices >>>> with correct (little) endianness. Will be used by MSI-X support. >>>> >>> Just a minor comment. >>> How about to add pci_[sg]et_byte() for consistency? >>> >> >> I don't see that it makes sense - pci_set_long(config, value) >> is shorter than *((uint32_t *)config) = cpu_to_le32(value), >> but single bytes don't have endianness, and *config = value >> is shorter. >> > > It's nice to have consistent APIs though. Well, if enough people feel so ... qemu: add pci_get/set_byte Add pci_get/set_byte to keep *_word and *_long access functions company. They are unused for now. Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/pci.h b/hw/pci.h index 4072f16..e1e4fb4 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -263,6 +263,18 @@ PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did, pci_map_irq_fn map_irq, const char *name); static inline void +pci_set_byte(uint8_t *config, uint8_t val) +{ + *config = val; +} + +static inline uint8_t +pci_get_byte(uint8_t *config) +{ + return *config; +} + +static inline void pci_set_word(uint8_t *config, uint16_t val) { cpu_to_le16wu((uint16_t *)config, val); -- MST