From patchwork Tue May 26 08:49:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 25951 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4Q8qjfu029329 for ; Tue, 26 May 2009 08:52:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753456AbZEZIwl (ORCPT ); Tue, 26 May 2009 04:52:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753295AbZEZIwl (ORCPT ); Tue, 26 May 2009 04:52:41 -0400 Received: from mx2.redhat.com ([66.187.237.31]:34772 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752105AbZEZIwl (ORCPT ); Tue, 26 May 2009 04:52:41 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4Q8oW2h004835; Tue, 26 May 2009 04:50:32 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4Q8oVLe018242; Tue, 26 May 2009 04:50:31 -0400 Received: from redhat.com (dhcp-0-223.tlv.redhat.com [10.35.0.223]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n4Q8oOQ9028462; Tue, 26 May 2009 04:50:25 -0400 Date: Tue, 26 May 2009 11:49:29 +0300 From: "Michael S. Tsirkin" To: Avi Kivity Cc: Isaku Yamahata , Paul Brook , qemu-devel@nongnu.org, Carsten Otte , kvm@vger.kernel.org, Rusty Russell , virtualization@lists.linux-foundation.org, Christian Borntraeger , Blue Swirl 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-Disposition: inline In-Reply-To: <4A1BA345.3040104@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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);