linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fan Fei <ffclaire1224@gmail.com>
To: bjorn@helgaas.com
Cc: Fan Fei <ffclaire1224@gmail.com>, linux-pci@vger.kernel.org
Subject: [PATCH 06/13] PCI: brcmstb: Replace device * with platform_device *
Date: Sat, 27 Nov 2021 15:11:14 +0100	[thread overview]
Message-ID: <fd50e5903c6cdb2e8d7bc9460e47cb848da4badb.1638022049.git.ffclaire1224@gmail.com> (raw)
In-Reply-To: <cover.1638022048.git.ffclaire1224@gmail.com>

Some PCI controller struct contain "device *", while others contain
"platform_device *". Unify "device *dev" to "platform_device *pdev" in
struct brcmstb_pcie, because PCI controllers interact with platform_device
directly, not device, to enumerate the controlled device.

Signed-off-by: Fan Fei <ffclaire1224@gmail.com>
---
 drivers/pci/controller/pcie-brcmstb.c | 35 ++++++++++++++-------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index 1fc7bd49a7ad..e6f0c3e561b6 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -278,7 +278,7 @@ struct brcm_msi {
 
 /* Internal PCIe Host Controller Information.*/
 struct brcm_pcie {
-	struct device		*dev;
+	struct platform_device		*pdev;
 	void __iomem		*base;
 	struct clk		*clk;
 	struct device_node	*np;
@@ -641,7 +641,7 @@ static int brcm_pcie_enable_msi(struct brcm_pcie *pcie)
 {
 	struct brcm_msi *msi;
 	int irq, ret;
-	struct device *dev = pcie->dev;
+	struct device *dev = &pcie->pdev->dev;
 
 	irq = irq_of_parse_and_map(dev->of_node, 1);
 	if (irq <= 0) {
@@ -780,7 +780,7 @@ static inline int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie,
 {
 	struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
 	struct resource_entry *entry;
-	struct device *dev = pcie->dev;
+	struct device *dev = &pcie->pdev->dev;
 	u64 lowest_pcie_addr = ~(u64)0;
 	int ret, i = 0;
 	u64 size = 0;
@@ -866,7 +866,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
 	struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
 	u64 rc_bar2_offset, rc_bar2_size;
 	void __iomem *base = pcie->base;
-	struct device *dev = pcie->dev;
+	struct device *dev = &pcie->pdev->dev;
 	struct resource_entry *entry;
 	bool ssc_good = false;
 	struct resource *res;
@@ -984,7 +984,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
 			continue;
 
 		if (num_out_wins >= BRCM_NUM_PCIE_OUT_WINS) {
-			dev_err(pcie->dev, "too many outbound wins\n");
+			dev_err(dev, "too many outbound wins\n");
 			return -EINVAL;
 		}
 
@@ -1067,7 +1067,7 @@ static void brcm_pcie_enter_l23(struct brcm_pcie *pcie)
 	}
 
 	if (!l23)
-		dev_err(pcie->dev, "failed to enter low-power link state\n");
+		dev_err(&pcie->pdev->dev, "failed to enter low-power link state\n");
 }
 
 static int brcm_phy_cntl(struct brcm_pcie *pcie, const int start)
@@ -1101,7 +1101,7 @@ static int brcm_phy_cntl(struct brcm_pcie *pcie, const int start)
 
 	ret = (tmp & combined_mask) == val ? 0 : -EIO;
 	if (ret)
-		dev_err(pcie->dev, "failed to %s phy\n", (start ? "start" : "stop"));
+		dev_err(&pcie->pdev->dev, "failed to %s phy\n", (start ? "start" : "stop"));
 
 	return ret;
 }
@@ -1231,24 +1231,25 @@ static const struct of_device_id brcm_pcie_match[] = {
 
 static int brcm_pcie_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct device_node *np = pdev->dev.of_node, *msi_np;
 	struct pci_host_bridge *bridge;
 	const struct pcie_cfg_data *data;
 	struct brcm_pcie *pcie;
 	int ret;
 
-	bridge = devm_pci_alloc_host_bridge(&pdev->dev, sizeof(*pcie));
+	bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
 	if (!bridge)
 		return -ENOMEM;
 
-	data = of_device_get_match_data(&pdev->dev);
+	data = of_device_get_match_data(dev);
 	if (!data) {
 		pr_err("failed to look up compatible string\n");
 		return -EINVAL;
 	}
 
 	pcie = pci_host_bridge_priv(bridge);
-	pcie->dev = &pdev->dev;
+	pcie->pdev = pdev;
 	pcie->np = np;
 	pcie->reg_offsets = data->offsets;
 	pcie->type = data->type;
@@ -1259,7 +1260,7 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 	if (IS_ERR(pcie->base))
 		return PTR_ERR(pcie->base);
 
-	pcie->clk = devm_clk_get_optional(&pdev->dev, "sw_pcie");
+	pcie->clk = devm_clk_get_optional(dev, "sw_pcie");
 	if (IS_ERR(pcie->clk))
 		return PTR_ERR(pcie->clk);
 
@@ -1270,15 +1271,15 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 
 	ret = clk_prepare_enable(pcie->clk);
 	if (ret) {
-		dev_err(&pdev->dev, "could not enable clock\n");
+		dev_err(dev, "could not enable clock\n");
 		return ret;
 	}
-	pcie->rescal = devm_reset_control_get_optional_shared(&pdev->dev, "rescal");
+	pcie->rescal = devm_reset_control_get_optional_shared(dev, "rescal");
 	if (IS_ERR(pcie->rescal)) {
 		clk_disable_unprepare(pcie->clk);
 		return PTR_ERR(pcie->rescal);
 	}
-	pcie->perst_reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "perst");
+	pcie->perst_reset = devm_reset_control_get_optional_exclusive(dev, "perst");
 	if (IS_ERR(pcie->perst_reset)) {
 		clk_disable_unprepare(pcie->clk);
 		return PTR_ERR(pcie->perst_reset);
@@ -1286,7 +1287,7 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 
 	ret = reset_control_reset(pcie->rescal);
 	if (ret)
-		dev_err(&pdev->dev, "failed to deassert 'rescal'\n");
+		dev_err(dev, "failed to deassert 'rescal'\n");
 
 	ret = brcm_phy_start(pcie);
 	if (ret) {
@@ -1301,7 +1302,7 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 
 	pcie->hw_rev = readl(pcie->base + PCIE_MISC_REVISION);
 	if (pcie->type == BCM4908 && pcie->hw_rev >= BRCM_PCIE_HW_REV_3_20) {
-		dev_err(pcie->dev, "hardware revision with unsupported PERST# setup\n");
+		dev_err(dev, "hardware revision with unsupported PERST# setup\n");
 		ret = -ENODEV;
 		goto fail;
 	}
@@ -1310,7 +1311,7 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 	if (pci_msi_enabled() && msi_np == pcie->np) {
 		ret = brcm_pcie_enable_msi(pcie);
 		if (ret) {
-			dev_err(pcie->dev, "probe of internal MSI failed");
+			dev_err(dev, "probe of internal MSI failed");
 			goto fail;
 		}
 	}
-- 
2.25.1


  parent reply	other threads:[~2021-11-27 14:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-27 14:11 [PATCH 00/13] Unify device * to platform_device * Fan Fei
2021-11-27 14:11 ` [PATCH 01/13] PCI: xilinx: Replace device * with " Fan Fei
2021-11-27 14:11 ` [PATCH 02/13] PCI: mediatek: " Fan Fei
2021-11-27 14:11 ` [PATCH 03/13] PCI: tegra: " Fan Fei
2021-11-27 14:11 ` [PATCH 04/13] PCI: xegene: " Fan Fei
2021-11-27 14:11 ` [PATCH 05/13] PCI: microchip: " Fan Fei
2021-11-27 14:11 ` Fan Fei [this message]
2021-11-27 14:11 ` [PATCH 07/13] PCI: mediatek-gen3: " Fan Fei
2021-11-27 14:11 ` [PATCH 08/13] PCI: rcar-gen2: " Fan Fei
2021-11-27 14:11 ` [PATCH 09/13] PCI: ftpci100: " Fan Fei
2021-11-27 14:11 ` [PATCH 10/13] PCI: v3-semi: " Fan Fei
2021-11-27 14:11 ` [PATCH 11/13] PCI: ixp4xx: " Fan Fei
2021-11-27 14:11 ` [PATCH 12/13] PCI: xilinx-nwl: " Fan Fei
2021-11-27 14:11 ` [PATCH 13/13] PCI: rcar: " Fan Fei
2021-12-23  0:43 ` [PATCH 00/13] Unify device * to " Bjorn Helgaas
2021-12-28 19:38   ` Fan Fei
2021-12-29 17:14     ` 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=fd50e5903c6cdb2e8d7bc9460e47cb848da4badb.1638022049.git.ffclaire1224@gmail.com \
    --to=ffclaire1224@gmail.com \
    --cc=bjorn@helgaas.com \
    --cc=linux-pci@vger.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;
as well as URLs for NNTP newsgroup(s).