From: Thierry Reding <thierry.reding@gmail.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Tomasz Nowicki <tn@semihalf.com>,
Liviu Dudau <liviu.dudau@arm.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Vidya Sagar <vidyas@nvidia.com>,
linux-pci@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: [PATCH v4 02/10] PCI: Allow driver-specific data in host bridge
Date: Fri, 25 Nov 2016 11:57:10 +0100 [thread overview]
Message-ID: <20161125105718.3866-2-thierry.reding@gmail.com> (raw)
In-Reply-To: <20161125105718.3866-1-thierry.reding@gmail.com>
From: Thierry Reding <treding@nvidia.com>
Provide a way to allocate driver-specific data along with a PCI host
bridge structure. The bridge's ->private field points to this data.
Changes in v4:
- use zero-sized, cache-aligned structure field to store private data
- provide static inline functions to obtain private data and upcast from
private data to struct pci_host_bridge
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/pci/probe.c | 6 +++---
include/linux/pci.h | 11 +++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 99f503c3ab81..912b22ed96dd 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -521,11 +521,11 @@ static void pci_release_host_bridge_dev(struct device *dev)
kfree(bridge);
}
-static struct pci_host_bridge *pci_alloc_host_bridge(void)
+static struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
{
struct pci_host_bridge *bridge;
- bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
+ bridge = kzalloc(sizeof(*bridge) + priv, GFP_KERNEL);
if (!bridge)
return NULL;
@@ -2279,7 +2279,7 @@ static struct pci_bus *pci_create_root_bus_msi(struct device *parent,
int error;
struct pci_host_bridge *bridge;
- bridge = pci_alloc_host_bridge();
+ bridge = pci_alloc_host_bridge(0);
if (!bridge)
return NULL;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index ff16e44d8f84..e9ba95cbfd62 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -434,10 +434,21 @@ struct pci_host_bridge {
resource_size_t start,
resource_size_t size,
resource_size_t align);
+ unsigned long private[0] ____cacheline_aligned;
};
#define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
+static inline void *pci_host_bridge_priv(struct pci_host_bridge *bridge)
+{
+ return (void *)bridge->private;
+}
+
+static inline struct pci_host_bridge *pci_host_bridge_from_priv(void *priv)
+{
+ return container_of(priv, struct pci_host_bridge, private);
+}
+
struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
--
2.10.2
next prev parent reply other threads:[~2016-11-25 10:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-25 10:57 [PATCH v4 01/10] PCI: Add new method for registering PCI hosts Thierry Reding
2016-11-25 10:57 ` Thierry Reding [this message]
2016-11-25 10:57 ` [PATCH v4 03/10] PCI: Make host bridge interface publicly available Thierry Reding
2016-11-25 10:57 ` [PATCH v4 04/10] PCI: tegra: Use new pci_register_host_bridge() interface Thierry Reding
2016-12-09 10:11 ` Tomasz Nowicki
2016-11-25 10:57 ` [PATCH v4 05/10] dt-bindings: pci: tegra: Add Tegra210 support Thierry Reding
2016-11-25 10:57 ` [PATCH v4 06/10] PCI: tegra: Implement PCA enable workaround Thierry Reding
2016-11-25 10:57 ` [PATCH v4 07/10] PCI: tegra: Add Tegra210 support Thierry Reding
2016-11-25 10:57 ` [PATCH v4 08/10] PCI: tegra: Enable the driver on 64-bit ARM Thierry Reding
2016-11-25 10:57 ` [PATCH v4 09/10] arm64: tegra: Add PCIe host bridge on Tegra210 Thierry Reding
2016-11-25 10:57 ` [PATCH v4 10/10] arm64: tegra: Enable PCIe on Jetson TX1 Thierry Reding
2016-11-28 16:54 ` Mikko Perttunen
2016-11-29 6:25 ` Vidya Sagar
2016-11-30 17:48 ` Thierry Reding
2016-11-30 18:06 ` Mikko Perttunen
2016-11-30 18:14 ` Thierry Reding
2016-11-30 18:39 ` Vidya Sagar
2016-11-30 19:38 ` Mikko Perttunen
2016-12-02 12:29 ` Mikko Perttunen
2016-12-07 17:58 ` [PATCH v4 01/10] PCI: Add new method for registering PCI hosts Bjorn Helgaas
2016-12-08 20:34 ` 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=20161125105718.3866-2-thierry.reding@gmail.com \
--to=thierry.reding@gmail.com \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=lorenzo.pieralisi@arm.com \
--cc=tn@semihalf.com \
--cc=vidyas@nvidia.com \
/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).