diff mbox series

[RFC,1/9] pci: pcie: Drop priv_data from struct pcie_device and use dev_get/set_drvdata() instead.

Message ID 20240529164103.31671-2-Jonathan.Cameron@huawei.com
State New, archived
Headers show
Series pci: portdrv: Add auxiliary bus and register CXL PMUs (and aer) | expand

Commit Message

Jonathan Cameron May 29, 2024, 4:40 p.m. UTC
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 mbox series

Patch

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);