From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=55389 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7jN4-0007Z3-R1 for qemu-devel@nongnu.org; Mon, 18 Oct 2010 02:38:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P7jN3-0008Eq-NS for qemu-devel@nongnu.org; Mon, 18 Oct 2010 02:38:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P7jN3-0008Ek-Fz for qemu-devel@nongnu.org; Mon, 18 Oct 2010 02:38:57 -0400 Date: Mon, 18 Oct 2010 08:32:37 +0200 From: "Michael S. Tsirkin" Message-ID: <20101018063237.GC19214@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] Re: [PATCH v4 02/15] pci: introduce helper functions to clear/set bits in configuration space List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: skandasa@cisco.com, adnan@khaleel.us, etmartin@cisco.com, qemu-devel@nongnu.org, wexu2@cisco.com On Mon, Oct 18, 2010 at 12:17:43PM +0900, Isaku Yamahata wrote: > This patch introduces helper functions to clear/set bits in configuration > space. pci_{clear_set, clear, set}_bit_{byte, word, long, quad}(). > They will be used later. > > Signed-off-by: Isaku Yamahata I am not very happy with the names we came up with. pci_clear_bit_byte - it sounds like this clears bit *and* byte. Also, this gets a mask, not a bit number as the name implies. How about pci_word_set_mask pci_word_clear_mask Other ideas? > --- > hw/pci.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 72 insertions(+), 0 deletions(-) > > diff --git a/hw/pci.h b/hw/pci.h > index d8b399f..eafa9f3 100644 > --- a/hw/pci.h > +++ b/hw/pci.h > @@ -323,6 +323,78 @@ pci_config_set_interrupt_pin(uint8_t *pci_config, uint8_t val) > pci_set_byte(&pci_config[PCI_INTERRUPT_PIN], val); > } > > +static inline void > +pci_clear_set_bit_byte(uint8_t *config, uint8_t clear, uint8_t set) > +{ > + pci_set_byte(config, (pci_get_byte(config) & ~clear) | set); > +} > + > +static inline void > +pci_clear_bit_byte(uint8_t *config, uint8_t clear) > +{ > + pci_clear_set_bit_byte(config, clear, 0); > +} > + > +static inline void > +pci_set_bit_byte(uint8_t *config, uint8_t set) > +{ > + pci_clear_set_bit_byte(config, 0, set); > +} > + > +static inline void > +pci_clear_set_bit_word(uint8_t *config, uint16_t clear, uint16_t set) > +{ > + pci_set_word(config, (pci_get_word(config) & ~clear) | set); > +} > + > +static inline void > +pci_clear_bit_word(uint8_t *config, uint16_t clear) > +{ > + pci_clear_set_bit_word(config, clear, 0); > +} > + > +static inline void > +pci_set_bit_word(uint8_t *config, uint16_t set) > +{ > + pci_clear_set_bit_word(config, 0, set); > +} > + > +static inline void > +pci_clear_set_bit_long(uint8_t *config, uint32_t clear, uint32_t set) > +{ > + pci_set_long(config, (pci_get_long(config) & ~clear) | set); > +} > + > +static inline void > +pci_clear_bit_long(uint8_t *config, uint32_t clear) > +{ > + pci_clear_set_bit_long(config, clear, 0); > +} > + > +static inline void > +pci_set_bit_long(uint8_t *config, uint32_t set) > +{ > + pci_clear_set_bit_long(config, 0, set); > +} > + > +static inline void > +pci_clear_set_bit_quad(uint8_t *config, uint64_t clear, uint64_t set) > +{ > + pci_set_quad(config, (pci_get_quad(config) & ~clear) | set); > +} > + > +static inline void > +pci_clear_bit_quad(uint8_t *config, uint64_t clear) > +{ > + pci_clear_set_bit_quad(config, clear, 0); > +} > + > +static inline void > +pci_set_bit_quad(uint8_t *config, uint64_t set) > +{ > + pci_clear_set_bit_quad(config, 0, set); > +} > + > typedef int (*pci_qdev_initfn)(PCIDevice *dev); > typedef struct { > DeviceInfo qdev; > -- > 1.7.1.1