public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Jackey Shen <jackey.shen@amd.com>
To: linux-mmc@vger.kernel.org
Cc: Jackey Shen <jackey.shen@amd.com>
Subject: [PATCH] mmc: sdhci-pci: identify correct base addresses for slots
Date: Mon, 1 Jul 2013 17:22:15 +0800	[thread overview]
Message-ID: <1372670535-2778-1-git-send-email-jackey.shen@amd.com> (raw)

A PCI Based SD Host Controller can support up to a total of six SD Slots, and
the base addresses are specified by Slot Information Register of its PCI header.
Please refer to C.3.3 of SD Host Controller Standard Specification Version 3.0.

Signed-off-by: Jackey Shen <jackey.shen@amd.com>
---
 drivers/mmc/host/sdhci-pci.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index d7d6bc8..3a84e95 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -50,7 +50,8 @@
 #define  PCI_SLOT_INFO_SLOTS(x)		((x >> 4) & 7)
 #define  PCI_SLOT_INFO_FIRST_BAR_MASK	0x07
 
-#define MAX_SLOTS			8
+#define MAX_SLOTS			6
+#define MAX_BARS			6
 
 struct sdhci_pci_chip;
 struct sdhci_pci_slot;
@@ -1282,7 +1283,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 {
 	struct sdhci_pci_slot *slot;
 	struct sdhci_host *host;
-	int ret, bar = first_bar + slotno;
+	int ret, bar = (first_bar + slotno) % MAX_BARS;
 
 	if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
 		dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
@@ -1481,7 +1482,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
 
 	first_bar &= PCI_SLOT_INFO_FIRST_BAR_MASK;
 
-	if (first_bar > 5) {
+	if (first_bar > MAX_BARS - 1) {
 		dev_err(&pdev->dev, "Invalid first BAR. Aborting.\n");
 		return -ENODEV;
 	}
-- 
1.7.10.4



             reply	other threads:[~2013-07-01  9:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01  9:22 Jackey Shen [this message]
2013-10-22  8:24 ` [PATCH] mmc: sdhci-pci: identify correct base addresses for slots Shen, Jackey
2013-10-27  1:23 ` Chris Ball
2013-10-28  2:04   ` Shen, Jackey

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=1372670535-2778-1-git-send-email-jackey.shen@amd.com \
    --to=jackey.shen@amd.com \
    --cc=linux-mmc@vger.kernel.org \
    /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