From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 02/16] pci: add 'self' member to struct pci_bus
Date: Tue, 26 Mar 2024 11:07:32 +0100 [thread overview]
Message-ID: <20240326100746.471532-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20240326100746.471532-1-s.hauer@pengutronix.de>
In Linux struct pci_bus has a 'parent' member which is a pointer to the
parent pci_bus. In barebox we also have a 'parent' member, but it is
of type struct device *. To be closer to Linux remove the parent member
and replace its usage with a struct pci_dev *self member (which also
exists in Linux).
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/pci/pci.c | 10 ++++++----
include/linux/pci.h | 3 ++-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 84678e40a9..8b96ac78df 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -48,7 +48,6 @@ void register_pci_controller(struct pci_controller *hose)
bus = pci_alloc_bus();
hose->bus = bus;
- bus->parent = hose->parent;
bus->host = hose;
bus->resource[PCI_BUS_RESOURCE_MEM] = hose->mem_resource;
bus->resource[PCI_BUS_RESOURCE_MEM_PREF] = hose->mem_pref_resource;
@@ -599,6 +598,8 @@ static unsigned int pci_scan_bus(struct pci_bus *bus)
max = bus->secondary;
for (devfn = 0; devfn < 0xff; ++devfn) {
+ struct device *parent;
+
if (PCI_FUNC(devfn) && !is_multi) {
/* not a multi-function device */
continue;
@@ -618,8 +619,9 @@ static unsigned int pci_scan_bus(struct pci_bus *bus)
dev->devfn = devfn;
dev->vendor = l & 0xffff;
dev->device = (l >> 16) & 0xffff;
- dev->dev.parent = bus->parent;
- dev->dev.of_node = pci_of_match_device(bus->parent, devfn);
+ parent = bus->self ? &bus->self->dev : bus->host->parent;
+ dev->dev.parent = parent;
+ dev->dev.of_node = pci_of_match_device(parent, devfn);
if (dev->dev.of_node)
pr_debug("found DT node %pOF for device %04x:%04x\n",
dev->dev.of_node,
@@ -668,7 +670,7 @@ static unsigned int pci_scan_bus(struct pci_bus *bus)
child_bus->resource[PCI_BUS_RESOURCE_IO] =
bus->resource[PCI_BUS_RESOURCE_IO];
- child_bus->parent = &dev->dev;
+ child_bus->self = dev;
if (pcibios_assign_all_busses()) {
child_bus->number = bus_index++;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index aa29ff5d17..c4ae53a235 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -139,9 +139,10 @@ enum {
PCI_BUS_RESOURCE_MEM_PREF = 2,
PCI_BUS_RESOURCE_BUSN = 3,
};
+
struct pci_bus {
struct pci_controller *host; /* associated host controller */
- struct device *parent;
+ struct pci_dev *self;
struct pci_bus *parent_bus; /* parent bus */
struct list_head node; /* node in list of buses */
struct list_head children; /* list of child buses */
--
2.39.2
next prev parent reply other threads:[~2024-03-26 10:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-26 10:07 [PATCH 00/16] PCI: support non 1:1 mappings Sascha Hauer
2024-03-26 10:07 ` [PATCH 01/16] net: phy: realtek: add phy for RTL8168 internal phy Sascha Hauer
2024-03-26 10:07 ` Sascha Hauer [this message]
2024-03-26 10:07 ` [PATCH 03/16] pci: rename parent_bus to parent Sascha Hauer
2024-03-26 10:07 ` [PATCH 04/16] add support for resource lists Sascha Hauer
2024-03-26 10:07 ` [PATCH 05/16] pci: pcie-designware: remove unused variable Sascha Hauer
2024-03-26 10:07 ` [PATCH 06/16] pci: dwc: Drop support for config space in 'ranges' Sascha Hauer
2024-03-26 10:07 ` [PATCH 07/16] pci: add pci_controller_init() Sascha Hauer
2024-03-26 10:07 ` [PATCH 08/16] pci: support non 1:1 mappings Sascha Hauer
2024-03-26 10:07 ` [PATCH 09/16] pci: pcie-designware: Speed up waiting for link Sascha Hauer
2024-03-26 10:07 ` [PATCH 10/16] pci: pcie-dw-rockchip: wait " Sascha Hauer
2024-03-26 10:07 ` [PATCH 11/16] pci: drop resources from struct pci_bus Sascha Hauer
2024-03-26 10:07 ` [PATCH 12/16] pci: add of_pci_bridge_init() Sascha Hauer
2024-04-04 6:18 ` [PATCH v2] " Sascha Hauer
2024-03-26 10:07 ` [PATCH 13/16] pci: pcie-designware: drop duplicate resource assigning Sascha Hauer
2024-03-26 10:07 ` [PATCH 14/16] pci: pcie-designware: remove dra7xx quirks Sascha Hauer
2024-03-26 10:07 ` [PATCH 15/16] pci: pcie-designware: iterate over windows Sascha Hauer
2024-03-26 10:07 ` [PATCH 16/16] ARM: dts: rk3588-rock-5b: remove pci ranges quirks Sascha Hauer
2024-04-02 8:39 ` [PATCH 00/16] PCI: support non 1:1 mappings Sascha Hauer
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=20240326100746.471532-3-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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