public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: linux-pci@vger.kernel.org, linux-arch@vger.kernel.org,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Russell King <rmk@arm.linux.org.uk>,
	Ralf Baechle <ralf@linux-mips.org>,
	Paul Mundt <lethal@linux-sh.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	hpa@zytor.com
Subject: [PATCH 1/6] PCI: add pci_common_swizzle() for INTx swizzling
Date: Tue, 16 Dec 2008 21:36:55 -0700	[thread overview]
Message-ID: <20081217043655.8372.52729.stgit@bob.kio> (raw)
In-Reply-To: <20081217043443.8372.28890.stgit@bob.kio>

This patch adds pci_common_swizzle(), which swizzles INTx values all the
way up to a root bridge.

This common implementation can replace several architecture-specific
ones.  This should someday be combined with pci_get_interrupt_pin(),
but I left it separate for now to make reviewing easier.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
---
 drivers/pci/pci.c   |   20 ++++++++++++++++++++
 include/linux/pci.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 388a32a..6988089 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1369,6 +1369,26 @@ pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
 }
 
 /**
+ * pci_common_swizzle - swizzle INTx all the way to root bridge
+ * @dev: the PCI device
+ * @pinp: pointer to the INTx pin value (1=INTA, 2=INTB, 3=INTD, 4=INTD)
+ *
+ * Perform INTx swizzling for a device.  This traverses through all PCI-to-PCI
+ * bridges all the way up to a PCI root bus.
+ */
+u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp)
+{
+	u8 pin = *pinp;
+
+	while (dev->bus->self) {
+		pin = pci_swizzle_interrupt_pin(dev, pin);
+		dev = dev->bus->self;
+	}
+	*pinp = pin;
+	return PCI_SLOT(dev->devfn);
+}
+
+/**
  *	pci_release_region - Release a PCI bar
  *	@pdev: PCI device whose resources were previously reserved by pci_request_region
  *	@bar: BAR to release
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 4be596f..e89d0b7 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -529,6 +529,7 @@ struct resource *pci_find_parent_resource(const struct pci_dev *dev,
 					  struct resource *res);
 u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin);
 int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
+u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp);
 extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
 extern void pci_dev_put(struct pci_dev *dev);
 extern void pci_remove_bus(struct pci_bus *b);

  reply	other threads:[~2008-12-17  4:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-17  4:36 [PATCH 0/6] PCI: use common INTx swizzling loop Bjorn Helgaas
2008-12-17  4:36 ` Bjorn Helgaas [this message]
2009-01-05 18:53   ` [PATCH 1/6] PCI: add pci_common_swizzle() for INTx swizzling Jesse Barnes
2009-01-05 18:53     ` Jesse Barnes
2008-12-17  4:37 ` [PATCH 2/6] PCI: alpha: use generic INTx swizzle from PCI core Bjorn Helgaas
2008-12-17  4:37 ` [PATCH 3/6] PCI: arm: " Bjorn Helgaas
2008-12-17  4:37 ` [PATCH 4/6] PCI: mips: " Bjorn Helgaas
2008-12-17  4:37 ` [PATCH 5/6] PCI: sh: " Bjorn Helgaas
2008-12-17  4:37   ` Bjorn Helgaas
2008-12-17  4:37 ` [PATCH 6/6] PCI: x86/visws: " Bjorn Helgaas
2008-12-17  4:37   ` Bjorn Helgaas

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=20081217043655.8372.52729.stgit@bob.kio \
    --to=bjorn.helgaas@hp.com \
    --cc=hpa@zytor.com \
    --cc=ink@jurassic.park.msu.ru \
    --cc=jbarnes@virtuousgeek.org \
    --cc=lethal@linux-sh.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=ralf@linux-mips.org \
    --cc=rmk@arm.linux.org.uk \
    --cc=tglx@linutronix.de \
    /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