mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	"Maciej W. Rozycki" <macro@orcam.me.uk>,
	linux-kernel@vger.kernel.org
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH 11/11] PCI: Move CardBus resource names to setup-cardbus.c
Date: Mon,  9 Nov 2026 23:07:11 +0200	[thread overview]
Message-ID: <20261109210714.3862-12-ilpo.jarvinen@linux.intel.com> (raw)
In-Reply-To: <20261109210714.3862-1-ilpo.jarvinen@linux.intel.com>

pci_resource_name() contains a table of resource names specific to
CardBus bridges. Move the CardBus-specific part into
pci_cardbus_resource_name() in setup-cardbus.c to make the core code
cleaner.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/pci/pci.c           | 26 ++------------------------
 drivers/pci/pci.h           |  5 +++++
 drivers/pci/setup-cardbus.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 24 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 46da873c9aac..e6c5a2d28abf 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -832,31 +832,9 @@ const char *pci_resource_name(struct pci_dev *dev, unsigned int i)
 		"bridge window",	/* "mem" included in %pR */
 		"bridge window",	/* "mem pref" included in %pR */
 	};
-	static const char * const cardbus_name[] = {
-		"BAR 1",
-		"unknown",
-		"unknown",
-		"unknown",
-		"unknown",
-		"unknown",
-		"unknown",
-#ifdef CONFIG_PCI_IOV
-		"unknown",
-		"unknown",
-		"unknown",
-		"unknown",
-		"unknown",
-		"unknown",
-#endif
-		"CardBus bridge window 0",	/* I/O */
-		"CardBus bridge window 1",	/* I/O */
-		"CardBus bridge window 0",	/* mem */
-		"CardBus bridge window 1",	/* mem */
-	};
 
-	if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS &&
-	    i < ARRAY_SIZE(cardbus_name))
-		return cardbus_name[i];
+	if (pci_is_cardbus_bridge(dev))
+		return pci_cardbus_resource_name(i);
 
 	if (i < ARRAY_SIZE(bar_name))
 		return bar_name[i];
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 057c8a2c7ee7..eefa5a2937c1 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -426,6 +426,7 @@ static inline bool pci_is_cardbus_bridge(const struct pci_dev *dev)
 #ifdef CONFIG_CARDBUS
 unsigned long pci_cardbus_resource_alignment(const struct resource *res);
 int pci_setup_cardbus_device(struct pci_dev *dev);
+const char *pci_cardbus_resource_name(unsigned int resno);
 int pci_bus_size_cardbus_bridge(struct pci_bus *bus,
 				struct list_head *realloc_head);
 int pci_cardbus_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
@@ -442,6 +443,10 @@ static inline int pci_setup_cardbus_device(struct pci_dev *dev)
 {
 	return -EOPNOTSUPP;
 }
+static inline const char *pci_cardbus_resource_name(unsigned int resno)
+{
+	return "unsupported";
+}
 static inline int pci_bus_size_cardbus_bridge(struct pci_bus *bus,
 					      struct list_head *realloc_head)
 {
diff --git a/drivers/pci/setup-cardbus.c b/drivers/pci/setup-cardbus.c
index 33aca7b28354..9acbf299c3a3 100644
--- a/drivers/pci/setup-cardbus.c
+++ b/drivers/pci/setup-cardbus.c
@@ -44,6 +44,36 @@ int pci_setup_cardbus_device(struct pci_dev *dev)
 	return 0;
 }
 
+const char *pci_cardbus_resource_name(unsigned int resno)
+{
+	static const char * const cardbus_name[] = {
+		"BAR 1",
+		"unknown",
+		"unknown",
+		"unknown",
+		"unknown",
+		"unknown",
+		"unknown",
+#ifdef CONFIG_PCI_IOV
+		"unknown",
+		"unknown",
+		"unknown",
+		"unknown",
+		"unknown",
+		"unknown",
+#endif
+		"CardBus bridge window 0",	/* I/O */
+		"CardBus bridge window 1",	/* I/O */
+		"CardBus bridge window 0",	/* mem */
+		"CardBus bridge window 1",	/* mem */
+	};
+
+	if (resno < ARRAY_SIZE(cardbus_name))
+		return cardbus_name[resno];
+
+	return "unknown";
+}
+
 int pci_bus_size_cardbus_bridge(struct pci_bus *bus,
 				struct list_head *realloc_head)
 {
-- 
2.47.3


      parent reply	other threads:[~2026-11-09 21:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 21:07 [PATCH 00/11] PCI/CardBus: Disable properly when CARDBUS=n & fix some issues along the way Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 01/11] PCI: Free device name when pci_setup_device() fails Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 02/11] PCI: Use Header Type in __pci_bridge_assign_resources() Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 03/11] PCI: Use Header Type to detect CardBus bridges in pci_resource_alignment() Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 04/11] PCI: Fix off-by-one in CardBus resource names Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 05/11] PCI: Move pci_read_bases() wrapper with BUILD_BUG_ON() to pci.h Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 06/11] mmc: sdricoh_cs: Depend on CARDBUS Ilpo Järvinen
2026-11-09 21:07 ` [RFC PATCH 07/11] pcmcia: yenta_socket: Always select CARDBUS Ilpo Järvinen
2026-11-09 21:07 ` [RFC PATCH 08/11] PCI: Move CardBus device setup to setup-cardbus.c Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 09/11] PCI: Move CardBus legacy mode quirk " Ilpo Järvinen
2026-11-09 21:07 ` [RFC PATCH 10/11] PCI: Move Ricoh RL5C476 MMC " Ilpo Järvinen
2026-11-09 21:07 ` Ilpo Järvinen [this message]

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=20261109210714.3862-12-ilpo.jarvinen@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    /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

all inboxes | Powered by JetHome®