From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Mahesh J Salgaonkar <mahesh@linux.ibm.com>,
Bjorn Helgaas <bhelgaas@google.com>, <linux-cxl@vger.kernel.org>,
<linux-pci@vger.kernel.org>
Cc: "Davidlohr Bueso" <dave@stgolabs.net>,
"Dave Jiang" <dave.jiang@intel.com>,
"Alison Schofield" <alison.schofield@intel.com>,
"Vishal Verma" <vishal.l.verma@intel.com>,
"Ira Weiny" <ira.weiny@intel.com>,
"Dan Williams" <dan.j.williams@intel.com>,
"Will Deacon" <will@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
linuxarm@huawei.com, terry.bowman@amd.com,
"Kuppuswamy Sathyanarayanan"
<sathyanarayanan.kuppuswamy@linux.intel.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [RFC PATCH 1/9] pci: pcie: Drop priv_data from struct pcie_device and use dev_get/set_drvdata() instead.
Date: Wed, 29 May 2024 17:40:55 +0100 [thread overview]
Message-ID: <20240529164103.31671-2-Jonathan.Cameron@huawei.com> (raw)
In-Reply-To: <20240529164103.31671-1-Jonathan.Cameron@huawei.com>
struct device has a driver_data pointer for the same purpose
as the priv_data in struct pcie_device, so use that via the
embedded struct device instead.
This will simplify moving to a different approach to the
pcie_device handling.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
drivers/pci/hotplug/pciehp_core.c | 12 ++++++------
drivers/pci/hotplug/pciehp_hpc.c | 2 +-
drivers/pci/pcie/aer.c | 8 ++++----
drivers/pci/pcie/pme.c | 13 +++++++------
drivers/pci/pcie/portdrv.h | 11 -----------
5 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index ddd55ad97a58..8e8d88f0d501 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -202,7 +202,7 @@ static int pciehp_probe(struct pcie_device *dev)
pci_err(dev->port, "Controller initialization failed\n");
return -ENODEV;
}
- set_service_data(dev, ctrl);
+ dev_set_drvdata(&dev->device, ctrl);
/* Setup the slot information structures */
rc = init_slot(ctrl);
@@ -243,7 +243,7 @@ static int pciehp_probe(struct pcie_device *dev)
static void pciehp_remove(struct pcie_device *dev)
{
- struct controller *ctrl = get_service_data(dev);
+ struct controller *ctrl = dev_get_drvdata(&dev->device);
pci_hp_del(&ctrl->hotplug_slot);
pcie_shutdown_notification(ctrl);
@@ -267,7 +267,7 @@ static void pciehp_disable_interrupt(struct pcie_device *dev)
* immediately when the downstream link goes down.
*/
if (pme_is_native(dev))
- pcie_disable_interrupt(get_service_data(dev));
+ pcie_disable_interrupt(dev_get_drvdata(&dev->device));
}
#ifdef CONFIG_PM_SLEEP
@@ -286,7 +286,7 @@ static int pciehp_suspend(struct pcie_device *dev)
static int pciehp_resume_noirq(struct pcie_device *dev)
{
- struct controller *ctrl = get_service_data(dev);
+ struct controller *ctrl = dev_get_drvdata(&dev->device);
/* pci_restore_state() just wrote to the Slot Control register */
ctrl->cmd_started = jiffies;
@@ -302,7 +302,7 @@ static int pciehp_resume_noirq(struct pcie_device *dev)
static int pciehp_resume(struct pcie_device *dev)
{
- struct controller *ctrl = get_service_data(dev);
+ struct controller *ctrl = dev_get_drvdata(&dev->device);
if (pme_is_native(dev))
pcie_enable_interrupt(ctrl);
@@ -320,7 +320,7 @@ static int pciehp_runtime_suspend(struct pcie_device *dev)
static int pciehp_runtime_resume(struct pcie_device *dev)
{
- struct controller *ctrl = get_service_data(dev);
+ struct controller *ctrl = dev_get_drvdata(&dev->device);
/* pci_restore_state() just wrote to the Slot Control register */
ctrl->cmd_started = jiffies;
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index b1d0a1b3917d..3e12ec4a2671 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -871,7 +871,7 @@ void pcie_disable_interrupt(struct controller *ctrl)
*/
int pciehp_slot_reset(struct pcie_device *dev)
{
- struct controller *ctrl = get_service_data(dev);
+ struct controller *ctrl = dev_get_drvdata(&dev->device);
if (ctrl->state != ON_STATE)
return 0;
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index ac6293c24976..189b50e4bc8d 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -1328,7 +1328,7 @@ static void aer_isr_one_error(struct aer_rpc *rpc,
static irqreturn_t aer_isr(int irq, void *context)
{
struct pcie_device *dev = (struct pcie_device *)context;
- struct aer_rpc *rpc = get_service_data(dev);
+ struct aer_rpc *rpc = dev_get_drvdata(&dev->device);
struct aer_err_source e_src;
if (kfifo_is_empty(&rpc->aer_fifo))
@@ -1349,7 +1349,7 @@ static irqreturn_t aer_isr(int irq, void *context)
static irqreturn_t aer_irq(int irq, void *context)
{
struct pcie_device *pdev = (struct pcie_device *)context;
- struct aer_rpc *rpc = get_service_data(pdev);
+ struct aer_rpc *rpc = dev_get_drvdata(&pdev->device);
struct pci_dev *rp = rpc->rpd;
int aer = rp->aer_cap;
struct aer_err_source e_src = {};
@@ -1448,7 +1448,7 @@ static void aer_disable_rootport(struct aer_rpc *rpc)
*/
static void aer_remove(struct pcie_device *dev)
{
- struct aer_rpc *rpc = get_service_data(dev);
+ struct aer_rpc *rpc = dev_get_drvdata(&dev->device);
aer_disable_rootport(rpc);
}
@@ -1482,7 +1482,7 @@ static int aer_probe(struct pcie_device *dev)
rpc->rpd = port;
INIT_KFIFO(rpc->aer_fifo);
- set_service_data(dev, rpc);
+ dev_set_drvdata(&dev->device, rpc);
status = devm_request_threaded_irq(device, dev->irq, aer_irq, aer_isr,
IRQF_SHARED, "aerdrv", dev);
diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c
index a2daebd9806c..2e23f131ed3e 100644
--- a/drivers/pci/pcie/pme.c
+++ b/drivers/pci/pcie/pme.c
@@ -265,13 +265,14 @@ static void pcie_pme_work_fn(struct work_struct *work)
*/
static irqreturn_t pcie_pme_irq(int irq, void *context)
{
+ struct pcie_device *srv = context;
struct pci_dev *port;
struct pcie_pme_service_data *data;
u32 rtsta;
unsigned long flags;
- port = ((struct pcie_device *)context)->port;
- data = get_service_data((struct pcie_device *)context);
+ port = srv->port;
+ data = dev_get_drvdata(&srv->device);
spin_lock_irqsave(&data->lock, flags);
pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta);
@@ -342,7 +343,7 @@ static int pcie_pme_probe(struct pcie_device *srv)
spin_lock_init(&data->lock);
INIT_WORK(&data->work, pcie_pme_work_fn);
data->srv = srv;
- set_service_data(srv, data);
+ dev_set_drvdata(&srv->device, data);
pcie_pme_interrupt_enable(port, false);
pcie_clear_root_pme_status(port);
@@ -391,7 +392,7 @@ static void pcie_pme_disable_interrupt(struct pci_dev *port,
*/
static int pcie_pme_suspend(struct pcie_device *srv)
{
- struct pcie_pme_service_data *data = get_service_data(srv);
+ struct pcie_pme_service_data *data = dev_get_drvdata(&srv->device);
struct pci_dev *port = srv->port;
bool wakeup;
int ret;
@@ -422,7 +423,7 @@ static int pcie_pme_suspend(struct pcie_device *srv)
*/
static int pcie_pme_resume(struct pcie_device *srv)
{
- struct pcie_pme_service_data *data = get_service_data(srv);
+ struct pcie_pme_service_data *data = dev_get_drvdata(&srv->device);
spin_lock_irq(&data->lock);
if (data->noirq) {
@@ -445,7 +446,7 @@ static int pcie_pme_resume(struct pcie_device *srv)
*/
static void pcie_pme_remove(struct pcie_device *srv)
{
- struct pcie_pme_service_data *data = get_service_data(srv);
+ struct pcie_pme_service_data *data = dev_get_drvdata(&srv->device);
pcie_pme_disable_interrupt(srv->port, data);
free_irq(srv->irq, srv);
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h
index 12c89ea0313b..344b796a8579 100644
--- a/drivers/pci/pcie/portdrv.h
+++ b/drivers/pci/pcie/portdrv.h
@@ -58,21 +58,10 @@ struct pcie_device {
int irq; /* Service IRQ/MSI/MSI-X Vector */
struct pci_dev *port; /* Root/Upstream/Downstream Port */
u32 service; /* Port service this device represents */
- void *priv_data; /* Service Private Data */
struct device device; /* Generic Device Interface */
};
#define to_pcie_device(d) container_of(d, struct pcie_device, device)
-static inline void set_service_data(struct pcie_device *dev, void *data)
-{
- dev->priv_data = data;
-}
-
-static inline void *get_service_data(struct pcie_device *dev)
-{
- return dev->priv_data;
-}
-
struct pcie_port_service_driver {
const char *name;
int (*probe)(struct pcie_device *dev);
--
2.39.2
next prev parent reply other threads:[~2024-05-29 16:41 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 16:40 [RFC PATCH 0/9] pci: portdrv: Add auxiliary bus and register CXL PMUs (and aer) Jonathan Cameron
2024-05-29 16:40 ` Jonathan Cameron [this message]
2024-05-29 16:40 ` [RFC PATCH 2/9] pci: portdrv: Drop driver field for port type Jonathan Cameron
2024-05-29 16:40 ` [RFC PATCH 3/9] pci: pcie: portdrv: Use managed device handling to simplify error and remove flows Jonathan Cameron
2024-05-29 16:40 ` [RFC PATCH 4/9] auxiliary_bus: expose auxiliary_bus_type Jonathan Cameron
2024-05-29 16:40 ` [RFC PATCH 5/9] pci: pcie: portdrv: Add a auxiliary_bus Jonathan Cameron
2024-05-29 16:41 ` [RFC PATCH 6/9] cxl: Move CPMU register definitions to header Jonathan Cameron
2024-05-29 16:41 ` [RFC PATCH 7/9] pci: pcie/cxl: Register an auxiliary device for each CPMU instance Jonathan Cameron
2024-05-29 16:41 ` [RFC PATCH 8/9] perf: cxl: Make the cpmu driver also work with auxiliary_devices Jonathan Cameron
2024-05-29 16:41 ` [RFC PATCH 9/9] pci: pcie: portdrv: aer: Switch to auxiliary_bus Jonathan Cameron
2024-06-05 18:04 ` [RFC PATCH 0/9] pci: portdrv: Add auxiliary bus and register CXL PMUs (and aer) Bjorn Helgaas
2024-06-05 19:44 ` Jonathan Cameron
2024-06-06 12:57 ` Jonathan Cameron
2024-06-06 13:21 ` Lukas Wunner
2024-08-23 11:05 ` Jonathan Cameron
2024-08-28 21:11 ` Thomas Gleixner
2024-08-29 12:17 ` Jonathan Cameron
2024-09-05 11:23 ` Jonathan Cameron
2024-09-06 10:11 ` Thomas Gleixner
2024-09-06 17:18 ` Jonathan Cameron
2024-09-10 16:47 ` Jonathan Cameron
2024-09-10 17:37 ` Jonathan Cameron
2024-09-10 20:04 ` Thomas Gleixner
2024-09-12 16:37 ` Jonathan Cameron
2024-09-12 17:34 ` Jonathan Cameron
2024-09-13 16:24 ` Thomas Gleixner
2024-06-17 7:03 ` Ilpo Järvinen
2024-07-04 16:14 ` Jonathan Cameron
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=20240529164103.31671-2-Jonathan.Cameron@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=bhelgaas@google.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=lpieralisi@kernel.org \
--cc=mahesh@linux.ibm.com \
--cc=mark.rutland@arm.com \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=terry.bowman@amd.com \
--cc=vishal.l.verma@intel.com \
--cc=will@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