All of lore.kernel.org
 help / color / mirror / Atom feed
From: marek.vasut@gmail.com
To: linux-pci@vger.kernel.org
Cc: Marek Vasut <marek.vasut+renesas@gmail.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Wolfram Sang <wsa@the-dreams.de>,
	linux-renesas-soc@vger.kernel.org
Subject: [PATCH] PCI: pcie-rcar: Cache PHY init function pointer
Date: Sun, 26 Apr 2020 14:31:47 +0200	[thread overview]
Message-ID: <20200426123148.56051-1-marek.vasut@gmail.com> (raw)

From: Marek Vasut <marek.vasut+renesas@gmail.com>

The PHY initialization function pointer does not change during the
lifetime of the driver instance, it is therefore sufficient to get
the pointer in .probe(), cache it in driver private data, and just
call the function through the cached pointer in .resume().

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-renesas-soc@vger.kernel.org
---
NOTE: Based on git://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git
      branch pci/rcar
NOTE: The driver tag is now 'pcie-rcar' to distinguish it from pci-rcar-gen2.c
---
 drivers/pci/controller/pcie-rcar.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c
index 1a0e74cad9bb..59e55f56e386 100644
--- a/drivers/pci/controller/pcie-rcar.c
+++ b/drivers/pci/controller/pcie-rcar.c
@@ -153,6 +153,7 @@ struct rcar_pcie {
 	int			root_bus_nr;
 	struct clk		*bus_clk;
 	struct			rcar_msi msi;
+	int			(*phy_init_fn)(struct rcar_pcie *pcie);
 };
 
 static void rcar_pci_write_reg(struct rcar_pcie *pcie, u32 val,
@@ -1147,7 +1148,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 	struct rcar_pcie *pcie;
 	u32 data;
 	int err;
-	int (*phy_init_fn)(struct rcar_pcie *);
 	struct pci_host_bridge *bridge;
 
 	bridge = pci_alloc_host_bridge(sizeof(*pcie));
@@ -1187,8 +1187,8 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 	if (err)
 		goto err_clk_disable;
 
-	phy_init_fn = of_device_get_match_data(dev);
-	err = phy_init_fn(pcie);
+	pcie->phy_init_fn = of_device_get_match_data(dev);
+	err = pcie->phy_init_fn(pcie);
 	if (err) {
 		dev_err(dev, "failed to init PCIe PHY\n");
 		goto err_clk_disable;
@@ -1253,7 +1253,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 static int __maybe_unused rcar_pcie_resume(struct device *dev)
 {
 	struct rcar_pcie *pcie = dev_get_drvdata(dev);
-	int (*hw_init_fn)(struct rcar_pcie *);
 	unsigned int data;
 	int err;
 
@@ -1262,8 +1261,7 @@ static int __maybe_unused rcar_pcie_resume(struct device *dev)
 		return 0;
 
 	/* Failure to get a link might just be that no cards are inserted */
-	hw_init_fn = of_device_get_match_data(dev);
-	err = hw_init_fn(pcie);
+	err = pcie->phy_init_fn(pcie);
 	if (err) {
 		dev_info(dev, "PCIe link down\n");
 		return 0;
-- 
2.25.1


             reply	other threads:[~2020-04-26 12:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26 12:31 marek.vasut [this message]
2020-04-27  7:19 ` [PATCH] PCI: pcie-rcar: Cache PHY init function pointer Geert Uytterhoeven
2020-04-28  8:32 ` Lorenzo Pieralisi
2020-05-01 20:42   ` Marek Vasut
2020-05-05 18:02     ` Lorenzo Pieralisi
2020-05-05 18:35       ` Marek Vasut
2020-05-06  8:57         ` Lorenzo Pieralisi
2020-05-06  9:02           ` Geert Uytterhoeven
2020-05-06  9:19             ` Lorenzo Pieralisi
2020-05-06 10:22               ` Geert Uytterhoeven
2020-05-06 15:33                 ` Lorenzo Pieralisi
2020-05-06 16:59                   ` Bjorn Helgaas
2020-05-01 21:52   ` 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=20200426123148.56051-1-marek.vasut@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=wsa@the-dreams.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.