PCI: iproc: platform: use device functions instead of OF.
PATCH v2 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.
---
v2: fix platform_get_resource() parameters.
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,IORESOURCE_MEM ,0 ); +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 reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
Since this is supposed to be the higher layer file, use higher layer than OF to handle this. Remove OF headers as a result.
Signed-off-by Rosen Penev <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Rob Herring
reviewerQuoted 60 lines · Rosen Penev
Since this is supposed to be the higher layer file, use higher layer than OF to handle this. Remove OF headers as a result.
Signed-off-by Rosen Penev <[email protected]>---
v2: fixplatform_get_resource()parameters.drivers/pci/controller/pcie-iproc-platform.c | 31 ++++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-)drivers/pci/controller/pcie-iproc-platform.c +7
-15@@ -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,IORESOURCE_MEM ,0 ); +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,
drivers/pci/controller/pcie-iproc-platform.c static int iproc_pltfm_pcie_probe(struct platform_device *pdev) · line 64
Quoted 10 lines
drivers/pci/controller/pcie-iproc-platform.c +3
-2+ 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" )) {
If the property is boolean, it should use read_bool and vice-versa.
drivers/pci/controller/pcie-iproc-platform.c static int iproc_pltfm_pcie_probe(struct platform_device *pdev) · line 83
Quoted 13 lines
drivers/pci/controller/pcie-iproc-platform.c +2
-2u32 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" );
This is correct as dma-ranges may not be bool.
Rob
Quoted 70 lines · Rob Herring
Quoted 68 lines · Rosen Penev
Since this is supposed to be the higher layer file, use higher layer than OF to handle this. Remove OF headers as a result.
Signed-off-by Rosen Penev <[email protected]>---
v2: fixplatform_get_resource()parameters.drivers/pci/controller/pcie-iproc-platform.c | 31 ++++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-)drivers/pci/controller/pcie-iproc-platform.c +9
-16@@ -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,IORESOURCE_MEM ,0 ); +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;
Quoted 4 lines
drivers/pci/controller/pcie-iproc-platform.c static int iproc_pltfm_pcie_probe(struct platform_device *pdev) · line 64
Quoted 2 lines
drivers/pci/controller/pcie-iproc-platform.c +1
-1-if (of_property_read_bool (np,"brcm,pcie-ob" )) { +if (device_property_present (dev,"brcm,pcie-ob" )) {If the property is boolean, it should use
read_booland vice-versa.
I don't see it as a boolean in dtsi.
Quoted 18 lines
Quoted 9 lines
drivers/pci/controller/pcie-iproc-platform.c +1
-1u32 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,drivers/pci/controller/pcie-iproc-platform.c static int iproc_pltfm_pcie_probe(struct platform_device *pdev) · line 83
Quoted 5 lines
drivers/pci/controller/pcie-iproc-platform.c +1
-1@@ -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" );This is correct as dma-ranges may not be bool.
Rob
Rob Herring
reviewerQuoted 72 lines · Rosen Penev
Quoted 70 lines · Rob Herring
Quoted 68 lines · Rosen Penev
Since this is supposed to be the higher layer file, use higher layer than OF to handle this. Remove OF headers as a result.
Signed-off-by Rosen Penev <[email protected]>---
v2: fixplatform_get_resource()parameters.drivers/pci/controller/pcie-iproc-platform.c | 31 ++++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-)drivers/pci/controller/pcie-iproc-platform.c +9
-16@@ -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,IORESOURCE_MEM ,0 ); +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;
Quoted 5 lines
Quoted 4 lines
drivers/pci/controller/pcie-iproc-platform.c static int iproc_pltfm_pcie_probe(struct platform_device *pdev) · line 64
Quoted 2 lines
drivers/pci/controller/pcie-iproc-platform.c +1
-1-if (of_property_read_bool (np,"brcm,pcie-ob" )) { +if (device_property_present (dev,"brcm,pcie-ob" )) {If the property is boolean, it should use
read_booland vice-versa.I don't see it as a boolean in dtsi.
Looks like boolean to me:
arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi:156: brcm,pcie-ob;arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi:185: brcm,pcie-ob;
Rob
Manivannan Sadhasivam
maintainerQuoted 3 lines · Rosen Penev
Since this is supposed to be the higher layer file, use higher layer than OF to handle this. Remove OF headers as a result.
What do you mean by 'higher layer'? This is a OF only driver. So what's the point in switching to generic APIs? Please stop doing these not-so-useful conversions.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்