From: "Michael S. Tsirkin" <mst@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: skandasa@cisco.com, adnan@khaleel.us, etmartin@cisco.com,
qemu-devel@nongnu.org, wexu2@cisco.com
Subject: [Qemu-devel] Re: [PATCH v4 02/15] pci: introduce helper functions to clear/set bits in configuration space
Date: Mon, 18 Oct 2010 07:42:37 +0200 [thread overview]
Message-ID: <20101018054237.GD18366@redhat.com> (raw)
In-Reply-To: <a1909c1c84166be63b37e2c8bd733cf40fe0e014.1287371107.git.yamahata@valinux.co.jp>
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 <yamahata@valinux.co.jp>
I don't think we want clear_set variant.
It is just confusing, simply calling
clear and then set will be better.
> ---
> 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);
> +}
> +
Let's just open-code this.
> +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);
> +}
> +
and this
> +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);
> +}
> +
and this.
> +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
next prev parent reply other threads:[~2010-10-18 5:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-18 3:17 [Qemu-devel] [PATCH v4 00/15] pcie port switch emulators Isaku Yamahata
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 01/15] pci: make pci_del_capability() update for w1cmask Isaku Yamahata
2010-10-18 6:06 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 02/15] pci: introduce helper functions to clear/set bits in configuration space Isaku Yamahata
2010-10-18 5:42 ` Michael S. Tsirkin [this message]
2010-10-18 6:32 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 03/15] pci: use pci_clear_bit_word() in pci_device_reset() Isaku Yamahata
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 04/15] pci: record which is written into pci configuration space Isaku Yamahata
2010-10-18 5:38 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18 7:17 ` Isaku Yamahata
2010-10-18 7:32 ` Michael S. Tsirkin
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 05/15] pci/bridge: fix pci_bridge_reset() Isaku Yamahata
2010-10-18 6:22 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18 7:10 ` Isaku Yamahata
2010-10-18 7:08 ` Michael S. Tsirkin
2010-10-18 7:44 ` Isaku Yamahata
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 06/15] msi: implements msi Isaku Yamahata
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 07/15] pcie: add pcie constants to pcie_regs.h Isaku Yamahata
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 08/15] pcie: helper functions for pcie capability and extended capability Isaku Yamahata
2010-10-18 5:38 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 09/15] pcie/aer: helper functions for pcie aer capability Isaku Yamahata
2010-10-18 5:45 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 10/15] pcie port: define struct PCIEPort/PCIESlot and helper functions Isaku Yamahata
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 11/15] ioh3420: pcie root port in X58 ioh Isaku Yamahata
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 12/15] x3130: pcie upstream port Isaku Yamahata
2010-10-18 4:59 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 13/15] x3130: pcie downstream port Isaku Yamahata
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 14/15] pcie/hotplug: introduce pushing attention button command Isaku Yamahata
2010-10-18 3:17 ` [Qemu-devel] [PATCH v4 15/15] pcie/aer: glue aer error injection into qemu monitor Isaku Yamahata
2010-10-18 6:24 ` [Qemu-devel] Re: [PATCH v4 00/15] pcie port switch emulators Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101018054237.GD18366@redhat.com \
--to=mst@redhat.com \
--cc=adnan@khaleel.us \
--cc=etmartin@cisco.com \
--cc=qemu-devel@nongnu.org \
--cc=skandasa@cisco.com \
--cc=wexu2@cisco.com \
--cc=yamahata@valinux.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).