qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH v4 02/15] pci: introduce helper functions to cle


From: Michael S. Tsirkin
Subject: [Qemu-devel] Re: [PATCH v4 02/15] pci: introduce helper functions to clear/set bits in configuration space
Date: Mon, 18 Oct 2010 08:32:37 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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 <address@hidden>

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]