* [PATCH 0/2] PCI: Simplify few things
@ 2025-01-12 13:39 Krzysztof Kozlowski
2025-01-12 13:39 ` [PATCH 1/2] PCI: dwc: dra7xx: Use syscon_regmap_lookup_by_phandle_args Krzysztof Kozlowski
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-12 13:39 UTC (permalink / raw)
To: Vignesh Raghavendra, Siddharth Vadapalli, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Minghuan Lian, Mingkai Hu, Roy Zang
Cc: linux-omap, linux-pci, linux-arm-kernel, linux-kernel,
linuxppc-dev, imx, Krzysztof Kozlowski
Few code simplifications without functional impact. Not tested on
hardware.
Best regards,
Krzysztof
---
Krzysztof Kozlowski (2):
PCI: dwc: dra7xx: Use syscon_regmap_lookup_by_phandle_args
PCI: dwc: layerscape: Use syscon_regmap_lookup_by_phandle_args
drivers/pci/controller/dwc/pci-dra7xx.c | 27 ++++++---------------------
drivers/pci/controller/dwc/pci-layerscape.c | 10 ++++------
2 files changed, 10 insertions(+), 27 deletions(-)
---
base-commit: 2ddfbff29a2d45551e8c3e4f0c6b7c4618de24b7
change-id: 20250112-syscon-phandle-args-pci-d97537922ddd
Best regards,
--
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] PCI: dwc: dra7xx: Use syscon_regmap_lookup_by_phandle_args
2025-01-12 13:39 [PATCH 0/2] PCI: Simplify few things Krzysztof Kozlowski
@ 2025-01-12 13:39 ` Krzysztof Kozlowski
2025-01-15 23:04 ` Bjorn Helgaas
2025-01-12 13:39 ` [PATCH 2/2] PCI: dwc: layerscape: " Krzysztof Kozlowski
2025-01-15 12:03 ` [PATCH 0/2] PCI: Simplify few things Krzysztof Wilczyński
2 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-12 13:39 UTC (permalink / raw)
To: Vignesh Raghavendra, Siddharth Vadapalli, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Minghuan Lian, Mingkai Hu, Roy Zang
Cc: linux-omap, linux-pci, linux-arm-kernel, linux-kernel,
linuxppc-dev, imx, Krzysztof Kozlowski
Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over
syscon_regmap_lookup_by_phandle() combined with getting the syscon
argument. Except simpler code this annotates within one line that given
phandle has arguments, so grepping for code would be easier.
There is also no real benefit in printing errors on missing syscon
argument, because this is done just too late: runtime check on
static/build-time data. Dtschema and Devicetree bindings offer the
static/build-time check for this already.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/pci/controller/dwc/pci-dra7xx.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
index 5c62e1a3ba52919afe96fbcbc6edaf70775a69cb..33d6bf460ffe5bb724a061558dd93ec7bdadc336 100644
--- a/drivers/pci/controller/dwc/pci-dra7xx.c
+++ b/drivers/pci/controller/dwc/pci-dra7xx.c
@@ -635,30 +635,20 @@ static int dra7xx_pcie_unaligned_memaccess(struct device *dev)
{
int ret;
struct device_node *np = dev->of_node;
- struct of_phandle_args args;
+ unsigned int args[2];
struct regmap *regmap;
- regmap = syscon_regmap_lookup_by_phandle(np,
- "ti,syscon-unaligned-access");
+ regmap = syscon_regmap_lookup_by_phandle_args(np, "ti,syscon-unaligned-access",
+ 2, args);
if (IS_ERR(regmap)) {
dev_dbg(dev, "can't get ti,syscon-unaligned-access\n");
return -EINVAL;
}
- ret = of_parse_phandle_with_fixed_args(np, "ti,syscon-unaligned-access",
- 2, 0, &args);
- if (ret) {
- dev_err(dev, "failed to parse ti,syscon-unaligned-access\n");
- return ret;
- }
-
- ret = regmap_update_bits(regmap, args.args[0], args.args[1],
- args.args[1]);
+ ret = regmap_update_bits(regmap, args[0], args[1], args[1]);
if (ret)
dev_err(dev, "failed to enable unaligned access\n");
- of_node_put(args.np);
-
return ret;
}
@@ -671,18 +661,13 @@ static int dra7xx_pcie_configure_two_lane(struct device *dev,
u32 mask;
u32 val;
- pcie_syscon = syscon_regmap_lookup_by_phandle(np, "ti,syscon-lane-sel");
+ pcie_syscon = syscon_regmap_lookup_by_phandle_args(np, "ti,syscon-lane-sel",
+ 1, &pcie_reg);
if (IS_ERR(pcie_syscon)) {
dev_err(dev, "unable to get ti,syscon-lane-sel\n");
return -EINVAL;
}
- if (of_property_read_u32_index(np, "ti,syscon-lane-sel", 1,
- &pcie_reg)) {
- dev_err(dev, "couldn't get lane selection reg offset\n");
- return -EINVAL;
- }
-
mask = b1co_mode_sel_mask | PCIE_B0_B1_TSYNCEN;
val = PCIE_B1C0_MODE_SEL | PCIE_B0_B1_TSYNCEN;
regmap_update_bits(pcie_syscon, pcie_reg, mask, val);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] PCI: dwc: layerscape: Use syscon_regmap_lookup_by_phandle_args
2025-01-12 13:39 [PATCH 0/2] PCI: Simplify few things Krzysztof Kozlowski
2025-01-12 13:39 ` [PATCH 1/2] PCI: dwc: dra7xx: Use syscon_regmap_lookup_by_phandle_args Krzysztof Kozlowski
@ 2025-01-12 13:39 ` Krzysztof Kozlowski
2025-01-13 16:02 ` Frank Li
2025-01-15 1:15 ` Roy Zang
2025-01-15 12:03 ` [PATCH 0/2] PCI: Simplify few things Krzysztof Wilczyński
2 siblings, 2 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-12 13:39 UTC (permalink / raw)
To: Vignesh Raghavendra, Siddharth Vadapalli, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Minghuan Lian, Mingkai Hu, Roy Zang
Cc: linux-omap, linux-pci, linux-arm-kernel, linux-kernel,
linuxppc-dev, imx, Krzysztof Kozlowski
Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over
syscon_regmap_lookup_by_phandle() combined with getting the syscon
argument. Except simpler code this annotates within one line that given
phandle has arguments, so grepping for code would be easier.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/pci/controller/dwc/pci-layerscape.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c
index ee6f5256813374bdf656bef4f9b96e1b8760d1b5..239a05b36e8e6291b195f1253289af79f4a86d36 100644
--- a/drivers/pci/controller/dwc/pci-layerscape.c
+++ b/drivers/pci/controller/dwc/pci-layerscape.c
@@ -329,7 +329,6 @@ static int ls_pcie_probe(struct platform_device *pdev)
struct ls_pcie *pcie;
struct resource *dbi_base;
u32 index[2];
- int ret;
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
if (!pcie)
@@ -355,16 +354,15 @@ static int ls_pcie_probe(struct platform_device *pdev)
pcie->pf_lut_base = pci->dbi_base + pcie->drvdata->pf_lut_off;
if (pcie->drvdata->scfg_support) {
- pcie->scfg = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,pcie-scfg");
+ pcie->scfg =
+ syscon_regmap_lookup_by_phandle_args(dev->of_node,
+ "fsl,pcie-scfg", 2,
+ index);
if (IS_ERR(pcie->scfg)) {
dev_err(dev, "No syscfg phandle specified\n");
return PTR_ERR(pcie->scfg);
}
- ret = of_property_read_u32_array(dev->of_node, "fsl,pcie-scfg", index, 2);
- if (ret)
- return ret;
-
pcie->index = index[1];
}
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] PCI: dwc: layerscape: Use syscon_regmap_lookup_by_phandle_args
2025-01-12 13:39 ` [PATCH 2/2] PCI: dwc: layerscape: " Krzysztof Kozlowski
@ 2025-01-13 16:02 ` Frank Li
2025-01-15 1:15 ` Roy Zang
1 sibling, 0 replies; 7+ messages in thread
From: Frank Li @ 2025-01-13 16:02 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Vignesh Raghavendra, Siddharth Vadapalli, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Minghuan Lian, Mingkai Hu, Roy Zang, linux-omap,
linux-pci, linux-arm-kernel, linux-kernel, linuxppc-dev, imx
On Sun, Jan 12, 2025 at 02:39:03PM +0100, Krzysztof Kozlowski wrote:
> Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over
> syscon_regmap_lookup_by_phandle() combined with getting the syscon
> argument. Except simpler code this annotates within one line that given
> phandle has arguments, so grepping for code would be easier.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/pci/controller/dwc/pci-layerscape.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c
> index ee6f5256813374bdf656bef4f9b96e1b8760d1b5..239a05b36e8e6291b195f1253289af79f4a86d36 100644
> --- a/drivers/pci/controller/dwc/pci-layerscape.c
> +++ b/drivers/pci/controller/dwc/pci-layerscape.c
> @@ -329,7 +329,6 @@ static int ls_pcie_probe(struct platform_device *pdev)
> struct ls_pcie *pcie;
> struct resource *dbi_base;
> u32 index[2];
> - int ret;
>
> pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
> if (!pcie)
> @@ -355,16 +354,15 @@ static int ls_pcie_probe(struct platform_device *pdev)
> pcie->pf_lut_base = pci->dbi_base + pcie->drvdata->pf_lut_off;
>
> if (pcie->drvdata->scfg_support) {
> - pcie->scfg = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,pcie-scfg");
> + pcie->scfg =
> + syscon_regmap_lookup_by_phandle_args(dev->of_node,
> + "fsl,pcie-scfg", 2,
> + index);
> if (IS_ERR(pcie->scfg)) {
> dev_err(dev, "No syscfg phandle specified\n");
> return PTR_ERR(pcie->scfg);
> }
>
> - ret = of_property_read_u32_array(dev->of_node, "fsl,pcie-scfg", index, 2);
> - if (ret)
> - return ret;
> -
> pcie->index = index[1];
> }
>
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH 2/2] PCI: dwc: layerscape: Use syscon_regmap_lookup_by_phandle_args
2025-01-12 13:39 ` [PATCH 2/2] PCI: dwc: layerscape: " Krzysztof Kozlowski
2025-01-13 16:02 ` Frank Li
@ 2025-01-15 1:15 ` Roy Zang
1 sibling, 0 replies; 7+ messages in thread
From: Roy Zang @ 2025-01-15 1:15 UTC (permalink / raw)
To: Krzysztof Kozlowski, Vignesh Raghavendra, Siddharth Vadapalli,
Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, M.H. Lian,
Mingkai Hu
Cc: linux-omap@vger.kernel.org, linux-pci@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
imx@lists.linux.dev
[-- Attachment #1: Type: text/plain, Size: 577 bytes --]
> From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over
> syscon_regmap_lookup_by_phandle() combined with getting the syscon
> argument. Except simpler code this annotates within one line that given
> phandle has arguments, so grepping for code would be easier.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/pci/controller/dwc/pci-layerscape.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
Acked-by: Roy Zang <Roy.Zang@nxp.com>
Roy
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 9794 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] PCI: Simplify few things
2025-01-12 13:39 [PATCH 0/2] PCI: Simplify few things Krzysztof Kozlowski
2025-01-12 13:39 ` [PATCH 1/2] PCI: dwc: dra7xx: Use syscon_regmap_lookup_by_phandle_args Krzysztof Kozlowski
2025-01-12 13:39 ` [PATCH 2/2] PCI: dwc: layerscape: " Krzysztof Kozlowski
@ 2025-01-15 12:03 ` Krzysztof Wilczyński
2 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Wilczyński @ 2025-01-15 12:03 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Vignesh Raghavendra, Siddharth Vadapalli, Lorenzo Pieralisi,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Minghuan Lian,
Mingkai Hu, Roy Zang, linux-omap, linux-pci, linux-arm-kernel,
linux-kernel, linuxppc-dev, imx
Hello,
> Few code simplifications without functional impact. Not tested on
> hardware.
Applied to controller/dwc for v6.14, thank you!
Krzysztof
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] PCI: dwc: dra7xx: Use syscon_regmap_lookup_by_phandle_args
2025-01-12 13:39 ` [PATCH 1/2] PCI: dwc: dra7xx: Use syscon_regmap_lookup_by_phandle_args Krzysztof Kozlowski
@ 2025-01-15 23:04 ` Bjorn Helgaas
0 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2025-01-15 23:04 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Vignesh Raghavendra, Siddharth Vadapalli, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Minghuan Lian, Mingkai Hu, Roy Zang, linux-omap,
linux-pci, linux-arm-kernel, linux-kernel, linuxppc-dev, imx
On Sun, Jan 12, 2025 at 02:39:02PM +0100, Krzysztof Kozlowski wrote:
> Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over
> syscon_regmap_lookup_by_phandle() combined with getting the syscon
> argument. Except simpler code this annotates within one line that given
> phandle has arguments, so grepping for code would be easier.
>
> There is also no real benefit in printing errors on missing syscon
> argument, because this is done just too late: runtime check on
> static/build-time data. Dtschema and Devicetree bindings offer the
> static/build-time check for this already.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/pci/controller/dwc/pci-dra7xx.c | 27 ++++++---------------------
> 1 file changed, 6 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
> index 5c62e1a3ba52919afe96fbcbc6edaf70775a69cb..33d6bf460ffe5bb724a061558dd93ec7bdadc336 100644
> --- a/drivers/pci/controller/dwc/pci-dra7xx.c
> +++ b/drivers/pci/controller/dwc/pci-dra7xx.c
> @@ -635,30 +635,20 @@ static int dra7xx_pcie_unaligned_memaccess(struct device *dev)
> {
> int ret;
> struct device_node *np = dev->of_node;
> - struct of_phandle_args args;
> + unsigned int args[2];
> struct regmap *regmap;
>
> - regmap = syscon_regmap_lookup_by_phandle(np,
> - "ti,syscon-unaligned-access");
> + regmap = syscon_regmap_lookup_by_phandle_args(np, "ti,syscon-unaligned-access",
> + 2, args);
> if (IS_ERR(regmap)) {
> dev_dbg(dev, "can't get ti,syscon-unaligned-access\n");
> return -EINVAL;
> }
>
> - ret = of_parse_phandle_with_fixed_args(np, "ti,syscon-unaligned-access",
> - 2, 0, &args);
> - if (ret) {
> - dev_err(dev, "failed to parse ti,syscon-unaligned-access\n");
> - return ret;
> - }
> -
> - ret = regmap_update_bits(regmap, args.args[0], args.args[1],
> - args.args[1]);
> + ret = regmap_update_bits(regmap, args[0], args[1], args[1]);
> if (ret)
> dev_err(dev, "failed to enable unaligned access\n");
>
> - of_node_put(args.np);
> -
> return ret;
> }
>
> @@ -671,18 +661,13 @@ static int dra7xx_pcie_configure_two_lane(struct device *dev,
> u32 mask;
> u32 val;
>
> - pcie_syscon = syscon_regmap_lookup_by_phandle(np, "ti,syscon-lane-sel");
> + pcie_syscon = syscon_regmap_lookup_by_phandle_args(np, "ti,syscon-lane-sel",
> + 1, &pcie_reg);
> if (IS_ERR(pcie_syscon)) {
> dev_err(dev, "unable to get ti,syscon-lane-sel\n");
> return -EINVAL;
> }
>
> - if (of_property_read_u32_index(np, "ti,syscon-lane-sel", 1,
> - &pcie_reg)) {
> - dev_err(dev, "couldn't get lane selection reg offset\n");
> - return -EINVAL;
> - }
Wow. I believe you that syscon_regmap_lookup_by_phandle_args() is
equivalent to both:
- syscon_regmap_lookup_by_phandle() followed by
of_parse_phandle_with_fixed_args(), and
- syscon_regmap_lookup_by_phandle() followed by
of_property_read_u32_index()
but I can't say it's obvious to this syscon- and OF-naive reviewer,
even after tracing a few layers in :)
Bjorn
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-01-15 23:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-12 13:39 [PATCH 0/2] PCI: Simplify few things Krzysztof Kozlowski
2025-01-12 13:39 ` [PATCH 1/2] PCI: dwc: dra7xx: Use syscon_regmap_lookup_by_phandle_args Krzysztof Kozlowski
2025-01-15 23:04 ` Bjorn Helgaas
2025-01-12 13:39 ` [PATCH 2/2] PCI: dwc: layerscape: " Krzysztof Kozlowski
2025-01-13 16:02 ` Frank Li
2025-01-15 1:15 ` Roy Zang
2025-01-15 12:03 ` [PATCH 0/2] PCI: Simplify few things Krzysztof Wilczyński
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).