* [PATCH] PCI: Use of_property_present() for testing DT property presence
@ 2023-03-10 14:47 Rob Herring
2023-03-13 8:43 ` AngeloGioacchino Del Regno
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rob Herring @ 2023-03-10 14:47 UTC (permalink / raw)
To: Thierry Reding, Lorenzo Pieralisi, Krzysztof Wilczyński,
Bjorn Helgaas, Jonathan Hunter, Ryder Lee, Jianjun Wang,
Tyrel Datwyler, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Matthias Brugger, AngeloGioacchino Del Regno
Cc: devicetree, linux-tegra, linux-pci, linux-kernel, linux-mediatek,
linuxppc-dev, linux-arm-kernel
It is preferred to use typed property access functions (i.e.
of_property_read_<type> functions) rather than low-level
of_get_property/of_find_property functions for reading properties. As
part of this, convert of_get_property/of_find_property calls to the
recently added of_property_present() helper when we just want to test
for presence of a property and nothing more.
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/pci/controller/pci-tegra.c | 4 ++--
drivers/pci/controller/pcie-mediatek.c | 2 +-
drivers/pci/hotplug/rpaphp_core.c | 4 ++--
drivers/pci/of.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
index 74c109f14ff0..79630885b9c8 100644
--- a/drivers/pci/controller/pci-tegra.c
+++ b/drivers/pci/controller/pci-tegra.c
@@ -1375,7 +1375,7 @@ static int tegra_pcie_phys_get(struct tegra_pcie *pcie)
struct tegra_pcie_port *port;
int err;
- if (!soc->has_gen2 || of_find_property(np, "phys", NULL) != NULL)
+ if (!soc->has_gen2 || of_property_present(np, "phys"))
return tegra_pcie_phys_get_legacy(pcie);
list_for_each_entry(port, &pcie->ports, list) {
@@ -1944,7 +1944,7 @@ static bool of_regulator_bulk_available(struct device_node *np,
for (i = 0; i < num_supplies; i++) {
snprintf(property, 32, "%s-supply", supplies[i].supply);
- if (of_find_property(np, property, NULL) == NULL)
+ if (!of_property_present(np, property))
return false;
}
diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
index ae5ad05ddc1d..31de7a29192c 100644
--- a/drivers/pci/controller/pcie-mediatek.c
+++ b/drivers/pci/controller/pcie-mediatek.c
@@ -643,7 +643,7 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port,
return err;
}
- if (of_find_property(dev->of_node, "interrupt-names", NULL))
+ if (of_property_present(dev->of_node, "interrupt-names"))
port->irq = platform_get_irq_byname(pdev, "pcie_irq");
else
port->irq = platform_get_irq(pdev, port->slot);
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 491986197c47..2316de0fd198 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -278,7 +278,7 @@ int rpaphp_check_drc_props(struct device_node *dn, char *drc_name,
return -EINVAL;
}
- if (of_find_property(dn->parent, "ibm,drc-info", NULL))
+ if (of_property_present(dn->parent, "ibm,drc-info"))
return rpaphp_check_drc_props_v2(dn, drc_name, drc_type,
be32_to_cpu(*my_index));
else
@@ -440,7 +440,7 @@ int rpaphp_add_slot(struct device_node *dn)
if (!of_node_name_eq(dn, "pci"))
return 0;
- if (of_find_property(dn, "ibm,drc-info", NULL))
+ if (of_property_present(dn, "ibm,drc-info"))
return rpaphp_drc_info_add_slot(dn);
else
return rpaphp_drc_add_slot(dn);
diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index 196834ed44fe..e085f2eca372 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -447,7 +447,7 @@ static int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *
return -ENODEV;
/* Local interrupt-map in the device node? Use it! */
- if (of_get_property(dn, "interrupt-map", NULL)) {
+ if (of_property_present(dn, "interrupt-map")) {
pin = pci_swizzle_interrupt_pin(pdev, pin);
ppnode = dn;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: Use of_property_present() for testing DT property presence
2023-03-10 14:47 [PATCH] PCI: Use of_property_present() for testing DT property presence Rob Herring
@ 2023-03-13 8:43 ` AngeloGioacchino Del Regno
2023-04-18 16:27 ` Rob Herring
2023-04-18 21:03 ` Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-03-13 8:43 UTC (permalink / raw)
To: Rob Herring, Thierry Reding, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bjorn Helgaas, Jonathan Hunter,
Ryder Lee, Jianjun Wang, Tyrel Datwyler, Michael Ellerman,
Nicholas Piggin, Christophe Leroy, Matthias Brugger
Cc: devicetree, linux-tegra, linux-pci, linux-kernel, linux-mediatek,
linuxppc-dev, linux-arm-kernel
Il 10/03/23 15:47, Rob Herring ha scritto:
> It is preferred to use typed property access functions (i.e.
> of_property_read_<type> functions) rather than low-level
> of_get_property/of_find_property functions for reading properties. As
> part of this, convert of_get_property/of_find_property calls to the
> recently added of_property_present() helper when we just want to test
> for presence of a property and nothing more.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #
pcie-mediatek
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: Use of_property_present() for testing DT property presence
2023-03-10 14:47 [PATCH] PCI: Use of_property_present() for testing DT property presence Rob Herring
2023-03-13 8:43 ` AngeloGioacchino Del Regno
@ 2023-04-18 16:27 ` Rob Herring
2023-04-18 21:03 ` Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2023-04-18 16:27 UTC (permalink / raw)
To: Thierry Reding, Lorenzo Pieralisi, Krzysztof Wilczyński,
Bjorn Helgaas, Jonathan Hunter, Ryder Lee, Jianjun Wang,
Tyrel Datwyler, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Matthias Brugger, AngeloGioacchino Del Regno
Cc: devicetree, linux-pci, linux-kernel, linux-mediatek, linux-tegra,
linuxppc-dev, linux-arm-kernel
On Fri, Mar 10, 2023 at 08:47:19AM -0600, Rob Herring wrote:
> It is preferred to use typed property access functions (i.e.
> of_property_read_<type> functions) rather than low-level
> of_get_property/of_find_property functions for reading properties. As
> part of this, convert of_get_property/of_find_property calls to the
> recently added of_property_present() helper when we just want to test
> for presence of a property and nothing more.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> drivers/pci/controller/pci-tegra.c | 4 ++--
> drivers/pci/controller/pcie-mediatek.c | 2 +-
> drivers/pci/hotplug/rpaphp_core.c | 4 ++--
> drivers/pci/of.c | 2 +-
> 4 files changed, 6 insertions(+), 6 deletions(-)
Ping!
>
> diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
> index 74c109f14ff0..79630885b9c8 100644
> --- a/drivers/pci/controller/pci-tegra.c
> +++ b/drivers/pci/controller/pci-tegra.c
> @@ -1375,7 +1375,7 @@ static int tegra_pcie_phys_get(struct tegra_pcie *pcie)
> struct tegra_pcie_port *port;
> int err;
>
> - if (!soc->has_gen2 || of_find_property(np, "phys", NULL) != NULL)
> + if (!soc->has_gen2 || of_property_present(np, "phys"))
> return tegra_pcie_phys_get_legacy(pcie);
>
> list_for_each_entry(port, &pcie->ports, list) {
> @@ -1944,7 +1944,7 @@ static bool of_regulator_bulk_available(struct device_node *np,
> for (i = 0; i < num_supplies; i++) {
> snprintf(property, 32, "%s-supply", supplies[i].supply);
>
> - if (of_find_property(np, property, NULL) == NULL)
> + if (!of_property_present(np, property))
> return false;
> }
>
> diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> index ae5ad05ddc1d..31de7a29192c 100644
> --- a/drivers/pci/controller/pcie-mediatek.c
> +++ b/drivers/pci/controller/pcie-mediatek.c
> @@ -643,7 +643,7 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port,
> return err;
> }
>
> - if (of_find_property(dev->of_node, "interrupt-names", NULL))
> + if (of_property_present(dev->of_node, "interrupt-names"))
> port->irq = platform_get_irq_byname(pdev, "pcie_irq");
> else
> port->irq = platform_get_irq(pdev, port->slot);
> diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
> index 491986197c47..2316de0fd198 100644
> --- a/drivers/pci/hotplug/rpaphp_core.c
> +++ b/drivers/pci/hotplug/rpaphp_core.c
> @@ -278,7 +278,7 @@ int rpaphp_check_drc_props(struct device_node *dn, char *drc_name,
> return -EINVAL;
> }
>
> - if (of_find_property(dn->parent, "ibm,drc-info", NULL))
> + if (of_property_present(dn->parent, "ibm,drc-info"))
> return rpaphp_check_drc_props_v2(dn, drc_name, drc_type,
> be32_to_cpu(*my_index));
> else
> @@ -440,7 +440,7 @@ int rpaphp_add_slot(struct device_node *dn)
> if (!of_node_name_eq(dn, "pci"))
> return 0;
>
> - if (of_find_property(dn, "ibm,drc-info", NULL))
> + if (of_property_present(dn, "ibm,drc-info"))
> return rpaphp_drc_info_add_slot(dn);
> else
> return rpaphp_drc_add_slot(dn);
> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
> index 196834ed44fe..e085f2eca372 100644
> --- a/drivers/pci/of.c
> +++ b/drivers/pci/of.c
> @@ -447,7 +447,7 @@ static int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *
> return -ENODEV;
>
> /* Local interrupt-map in the device node? Use it! */
> - if (of_get_property(dn, "interrupt-map", NULL)) {
> + if (of_property_present(dn, "interrupt-map")) {
> pin = pci_swizzle_interrupt_pin(pdev, pin);
> ppnode = dn;
> }
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: Use of_property_present() for testing DT property presence
2023-03-10 14:47 [PATCH] PCI: Use of_property_present() for testing DT property presence Rob Herring
2023-03-13 8:43 ` AngeloGioacchino Del Regno
2023-04-18 16:27 ` Rob Herring
@ 2023-04-18 21:03 ` Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2023-04-18 21:03 UTC (permalink / raw)
To: Rob Herring
Cc: Thierry Reding, Lorenzo Pieralisi, Krzysztof Wilczyński,
Bjorn Helgaas, Jonathan Hunter, Ryder Lee, Jianjun Wang,
Tyrel Datwyler, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Matthias Brugger, AngeloGioacchino Del Regno,
devicetree, linux-tegra, linux-pci, linux-kernel, linux-mediatek,
linuxppc-dev, linux-arm-kernel
On Fri, Mar 10, 2023 at 08:47:19AM -0600, Rob Herring wrote:
> It is preferred to use typed property access functions (i.e.
> of_property_read_<type> functions) rather than low-level
> of_get_property/of_find_property functions for reading properties. As
> part of this, convert of_get_property/of_find_property calls to the
> recently added of_property_present() helper when we just want to test
> for presence of a property and nothing more.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
Applied with AngeloGioacchino's reviewed-by to pci/enumeration for
v6.4, thanks!
> ---
> drivers/pci/controller/pci-tegra.c | 4 ++--
> drivers/pci/controller/pcie-mediatek.c | 2 +-
> drivers/pci/hotplug/rpaphp_core.c | 4 ++--
> drivers/pci/of.c | 2 +-
> 4 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
> index 74c109f14ff0..79630885b9c8 100644
> --- a/drivers/pci/controller/pci-tegra.c
> +++ b/drivers/pci/controller/pci-tegra.c
> @@ -1375,7 +1375,7 @@ static int tegra_pcie_phys_get(struct tegra_pcie *pcie)
> struct tegra_pcie_port *port;
> int err;
>
> - if (!soc->has_gen2 || of_find_property(np, "phys", NULL) != NULL)
> + if (!soc->has_gen2 || of_property_present(np, "phys"))
> return tegra_pcie_phys_get_legacy(pcie);
>
> list_for_each_entry(port, &pcie->ports, list) {
> @@ -1944,7 +1944,7 @@ static bool of_regulator_bulk_available(struct device_node *np,
> for (i = 0; i < num_supplies; i++) {
> snprintf(property, 32, "%s-supply", supplies[i].supply);
>
> - if (of_find_property(np, property, NULL) == NULL)
> + if (!of_property_present(np, property))
> return false;
> }
>
> diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> index ae5ad05ddc1d..31de7a29192c 100644
> --- a/drivers/pci/controller/pcie-mediatek.c
> +++ b/drivers/pci/controller/pcie-mediatek.c
> @@ -643,7 +643,7 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port,
> return err;
> }
>
> - if (of_find_property(dev->of_node, "interrupt-names", NULL))
> + if (of_property_present(dev->of_node, "interrupt-names"))
> port->irq = platform_get_irq_byname(pdev, "pcie_irq");
> else
> port->irq = platform_get_irq(pdev, port->slot);
> diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
> index 491986197c47..2316de0fd198 100644
> --- a/drivers/pci/hotplug/rpaphp_core.c
> +++ b/drivers/pci/hotplug/rpaphp_core.c
> @@ -278,7 +278,7 @@ int rpaphp_check_drc_props(struct device_node *dn, char *drc_name,
> return -EINVAL;
> }
>
> - if (of_find_property(dn->parent, "ibm,drc-info", NULL))
> + if (of_property_present(dn->parent, "ibm,drc-info"))
> return rpaphp_check_drc_props_v2(dn, drc_name, drc_type,
> be32_to_cpu(*my_index));
> else
> @@ -440,7 +440,7 @@ int rpaphp_add_slot(struct device_node *dn)
> if (!of_node_name_eq(dn, "pci"))
> return 0;
>
> - if (of_find_property(dn, "ibm,drc-info", NULL))
> + if (of_property_present(dn, "ibm,drc-info"))
> return rpaphp_drc_info_add_slot(dn);
> else
> return rpaphp_drc_add_slot(dn);
> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
> index 196834ed44fe..e085f2eca372 100644
> --- a/drivers/pci/of.c
> +++ b/drivers/pci/of.c
> @@ -447,7 +447,7 @@ static int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *
> return -ENODEV;
>
> /* Local interrupt-map in the device node? Use it! */
> - if (of_get_property(dn, "interrupt-map", NULL)) {
> + if (of_property_present(dn, "interrupt-map")) {
> pin = pci_swizzle_interrupt_pin(pdev, pin);
> ppnode = dn;
> }
> --
> 2.39.2
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-18 21:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10 14:47 [PATCH] PCI: Use of_property_present() for testing DT property presence Rob Herring
2023-03-13 8:43 ` AngeloGioacchino Del Regno
2023-04-18 16:27 ` Rob Herring
2023-04-18 21:03 ` Bjorn Helgaas
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).