PCI: iproc: platform: use device functions instead of OF.
PATCH 1/1 PCI: iproc: platform: use device functions instead of OF.
Since this is supposed to be the higher layer file, use higher layer than OF to handle this. Remove OF headers as a result.
--- drivers/pci/controller/pcie-iproc-platform.c | 31 ++++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-)
drivers/pci/controller/pcie-iproc-platform.c +12 -19
@@ -10,12 +10,8 @@#include <linux/slab.h> #include <linux/interrupt.h> #include <linux/platform_device.h> -#include <linux/of_address.h> -#include <linux/of_pci.h> -#include <linux/of_platform.h> #include <linux/phy/phy.h> -#include "../pci.h" #include "pcie-iproc.h" static const struct of_device_id iproc_pcie_of_match_table[] = {
@@ -40,11 +36,14 @@ static int iproc_pltfm_pcie_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct iproc_pcie *pcie; -struct device_node *np = dev->of_node; -struct resource reg; +struct resource *reg;struct pci_host_bridge *bridge;int ret; + reg =platform_get_resource (pdev,0 ,IORESOURCE_MEM ); +if (!reg) +return -ENODEV ; + bridge =devm_pci_alloc_host_bridge (dev,sizeof (*pcie));if (!bridge)return -ENOMEM ;
@@ -52,26 +51,20 @@ static int iproc_pltfm_pcie_probe(struct platform_device *pdev) pcie =pci_host_bridge_priv (bridge); pcie->dev = dev; - pcie->type = (uintptr_t )of_device_get_match_data (dev); - - ret =of_address_to_resource (np,0 , ®); -if (ret <0 ) { -dev_err (dev,"unable to obtain controller resources\n" ); -return ret; - } + pcie->type = (uintptr_t )device_get_match_data (dev); - pcie->base =devm_pci_remap_cfgspace (dev, reg.start, -resource_size (®)); + pcie->base =devm_pci_remap_cfgspace (dev, reg->start, +resource_size (reg));if (!pcie->base) {dev_err (dev,"unable to map controller registers\n" );return -ENOMEM ; } - pcie->base_addr = reg.start; + pcie->base_addr = reg->start; -if (of_property_read_bool (np,"brcm,pcie-ob" )) { +if (device_property_present (dev,"brcm,pcie-ob" )) {u32 val; - ret =of_property_read_u32 (np,"brcm,pcie-ob-axi-offset" , + ret =device_property_read_u32 (dev,"brcm,pcie-ob-axi-offset" , &val);if (ret) { dev_err(dev,
@@ -87,7 +80,7 @@ static int iproc_pltfm_pcie_probe(struct platform_device *pdev)* core driver. For platforms that require explicit inbound mapping * configuration, "dma-ranges" would have been present in DT */ - pcie->need_ib_cfg =of_property_read_bool (np,"dma-ranges" ); + pcie->need_ib_cfg =device_property_present (dev,"dma-ranges" );/* PHY use is optional */ pcie->phy =devm_phy_optional_get (dev,"pcie-phy" );
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The arguments `type` and `num` are swapped in the call to `platform_get_resource`, causing it to…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The arguments type and num are swapped in the call to platform_get_resource, causing it to always return NULL. --
--- Patch [1]: [PATCH] PCI: iproc: platform: use device functions instead of OF. --- commit 2f0a3f1eb1db2f4c07d6f4eed3d9de0ee3b5177e
Author: Rosen Penev <[email protected]>
PCI: iproc: platform: use device functions instead of OF.
This commit updates the iProc PCIe platform driver to use generic device properties and functions instead of relying directly on OF-specific APIs. The corresponding OF header inclusions are also removed.
Quoted 4 lines
drivers/pci/controller/pcie-iproc-platform.c +0
-0
[ ... ]
drivers/pci/controller/pcie-iproc-platform.c static int iproc_pltfm_pcie_probe(struct platform_device *pdev) · line 43
Quoted 11 lines
drivers/pci/controller/pcie-iproc-platform.c +2
-2@@ -40,11 +36,14 @@ static int iproc_pltfm_pcie_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct iproc_pcie *pcie; -struct device_node *np = dev->of_node; -struct resource reg; +struct resource *reg;struct pci_host_bridge *bridge;int ret; + reg =platform_get_resource (pdev,0 ,IORESOURCE_MEM );
[Severity: High]
Are the type and num arguments swapped in this call to platform_get_resource()?
Looking at platform_get_resource(), its signature expects the resource type followed by the resource index:
struct resource *platform_get_resource(struct platform_device *dev,
unsigned int type, unsigned int num)
Passing 0 as the type and IORESOURCE_MEM as the num means this will attempt to retrieve the 512th resource of type 0. This will consistently return NULL and cause the driver probe to unconditionally fail with -ENODEV.
Would it be correct to use platform_get_resource(pdev, IORESOURCE_MEM, 0) here instead?
Quoted 4 lines
drivers/pci/controller/pcie-iproc-platform.c +3
-0+if (!reg) +return -ENODEV ; + bridge =devm_pci_alloc_host_bridge (dev,sizeof (*pcie));
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1