diff mbox series

drivers: pcie_xilinx: Fix "reg" not found error

Message ID 20231102082303.354944-1-mchitale@ventanamicro.com
State Superseded
Delegated to: Michal Simek
Headers show
Series drivers: pcie_xilinx: Fix "reg" not found error | expand

Commit Message

Mayuresh Chitale Nov. 2, 2023, 8:23 a.m. UTC
Fix the driver to use the dev_read_addr_size API to fetch the reg
property from the DT.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
---
 drivers/pci/pcie_xilinx.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

Comments

Michal Simek Nov. 2, 2023, 9:05 a.m. UTC | #1
On 11/2/23 09:23, Mayuresh Chitale wrote:
> Fix the driver to use the dev_read_addr_size API to fetch the reg
> property from the DT.
> 
> Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> ---
>   drivers/pci/pcie_xilinx.c | 22 ++++++++--------------
>   1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/pci/pcie_xilinx.c b/drivers/pci/pcie_xilinx.c
> index 53fd121e90..20b630027f 100644
> --- a/drivers/pci/pcie_xilinx.c
> +++ b/drivers/pci/pcie_xilinx.c
> @@ -140,20 +140,14 @@ static int pcie_xilinx_write_config(struct udevice *bus, pci_dev_t bdf,
>   static int pcie_xilinx_of_to_plat(struct udevice *dev)
>   {
>   	struct xilinx_pcie *pcie = dev_get_priv(dev);
> -	struct fdt_resource reg_res;
> -	DECLARE_GLOBAL_DATA_PTR;
> -	int err;
> -
> -	err = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), "reg",

I don't have HW to test this but here you are removing reference to GD that's 
why I think you should also remove

#include <asm/global_data.h>




> -			       0, &reg_res);
> -	if (err < 0) {
> -		pr_err("\"reg\" resource not found\n");
> -		return err;
> -	}
> -
> -	pcie->cfg_base = map_physmem(reg_res.start,
> -				     fdt_resource_size(&reg_res),
> -				     MAP_NOCACHE);
> +	fdt_addr_t addr;
> +	fdt_size_t size;
> +
> +	addr = dev_read_addr_size(dev, &size);
> +	if (addr == FDT_ADDR_T_NONE)
> +		return -EINVAL;
> +
> +	pcie->cfg_base = map_physmem(addr, size, MAP_NOCACHE);

Definitely it is better then what was there before.

But can't use use devm_ioremap() instead?

Thanks,
Michal
Mayuresh Chitale Nov. 11, 2023, 1:25 p.m. UTC | #2
Hi Michal,

On Thu, 2023-11-02 at 10:05 +0100, Michal Simek wrote:
> 
> On 11/2/23 09:23, Mayuresh Chitale wrote:
> > Fix the driver to use the dev_read_addr_size API to fetch the reg
> > property from the DT.
> > 
> > Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> > ---
> >   drivers/pci/pcie_xilinx.c | 22 ++++++++--------------
> >   1 file changed, 8 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/pci/pcie_xilinx.c b/drivers/pci/pcie_xilinx.c
> > index 53fd121e90..20b630027f 100644
> > --- a/drivers/pci/pcie_xilinx.c
> > +++ b/drivers/pci/pcie_xilinx.c
> > @@ -140,20 +140,14 @@ static int pcie_xilinx_write_config(struct
> > udevice *bus, pci_dev_t bdf,
> >   static int pcie_xilinx_of_to_plat(struct udevice *dev)
> >   {
> >   	struct xilinx_pcie *pcie = dev_get_priv(dev);
> > -	struct fdt_resource reg_res;
> > -	DECLARE_GLOBAL_DATA_PTR;
> > -	int err;
> > -
> > -	err = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), "reg",
> 
> I don't have HW to test this but here you are removing reference to
> GD that's 
> why I think you should also remove
> 
> #include <asm/global_data.h>
Ok.
> 
> 
> 
> 
> > -			       0, &reg_res);
> > -	if (err < 0) {
> > -		pr_err("\"reg\" resource not found\n");
> > -		return err;
> > -	}
> > -
> > -	pcie->cfg_base = map_physmem(reg_res.start,
> > -				     fdt_resource_size(&reg_res),
> > -				     MAP_NOCACHE);
> > +	fdt_addr_t addr;
> > +	fdt_size_t size;
> > +
> > +	addr = dev_read_addr_size(dev, &size);
> > +	if (addr == FDT_ADDR_T_NONE)
> > +		return -EINVAL;
> > +
> > +	pcie->cfg_base = map_physmem(addr, size, MAP_NOCACHE);
> 
> Definitely it is better then what was there before.
> 
> But can't use use devm_ioremap() instead?
Ok.
> 
> Thanks,
> Michal
diff mbox series

Patch

diff --git a/drivers/pci/pcie_xilinx.c b/drivers/pci/pcie_xilinx.c
index 53fd121e90..20b630027f 100644
--- a/drivers/pci/pcie_xilinx.c
+++ b/drivers/pci/pcie_xilinx.c
@@ -140,20 +140,14 @@  static int pcie_xilinx_write_config(struct udevice *bus, pci_dev_t bdf,
 static int pcie_xilinx_of_to_plat(struct udevice *dev)
 {
 	struct xilinx_pcie *pcie = dev_get_priv(dev);
-	struct fdt_resource reg_res;
-	DECLARE_GLOBAL_DATA_PTR;
-	int err;
-
-	err = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), "reg",
-			       0, &reg_res);
-	if (err < 0) {
-		pr_err("\"reg\" resource not found\n");
-		return err;
-	}
-
-	pcie->cfg_base = map_physmem(reg_res.start,
-				     fdt_resource_size(&reg_res),
-				     MAP_NOCACHE);
+	fdt_addr_t addr;
+	fdt_size_t size;
+
+	addr = dev_read_addr_size(dev, &size);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	pcie->cfg_base = map_physmem(addr, size, MAP_NOCACHE);
 
 	return 0;
 }