Commit 9195ee1a authored by Rob Herring's avatar Rob Herring Committed by Bjorn Helgaas

PCI: Use of_property_present() for testing DT property presence

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.

Link: https://lore.kernel.org/r/20230310144719.1544443-1-robh@kernel.orgSigned-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>  # pcie-mediatek
parent fe15c26e
...@@ -1375,7 +1375,7 @@ static int tegra_pcie_phys_get(struct tegra_pcie *pcie) ...@@ -1375,7 +1375,7 @@ static int tegra_pcie_phys_get(struct tegra_pcie *pcie)
struct tegra_pcie_port *port; struct tegra_pcie_port *port;
int err; 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); return tegra_pcie_phys_get_legacy(pcie);
list_for_each_entry(port, &pcie->ports, list) { list_for_each_entry(port, &pcie->ports, list) {
...@@ -1944,7 +1944,7 @@ static bool of_regulator_bulk_available(struct device_node *np, ...@@ -1944,7 +1944,7 @@ static bool of_regulator_bulk_available(struct device_node *np,
for (i = 0; i < num_supplies; i++) { for (i = 0; i < num_supplies; i++) {
snprintf(property, 32, "%s-supply", supplies[i].supply); snprintf(property, 32, "%s-supply", supplies[i].supply);
if (of_find_property(np, property, NULL) == NULL) if (!of_property_present(np, property))
return false; return false;
} }
......
...@@ -643,7 +643,7 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port, ...@@ -643,7 +643,7 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port,
return err; 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"); port->irq = platform_get_irq_byname(pdev, "pcie_irq");
else else
port->irq = platform_get_irq(pdev, port->slot); port->irq = platform_get_irq(pdev, port->slot);
......
...@@ -278,7 +278,7 @@ int rpaphp_check_drc_props(struct device_node *dn, char *drc_name, ...@@ -278,7 +278,7 @@ int rpaphp_check_drc_props(struct device_node *dn, char *drc_name,
return -EINVAL; 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, return rpaphp_check_drc_props_v2(dn, drc_name, drc_type,
be32_to_cpu(*my_index)); be32_to_cpu(*my_index));
else else
...@@ -440,7 +440,7 @@ int rpaphp_add_slot(struct device_node *dn) ...@@ -440,7 +440,7 @@ int rpaphp_add_slot(struct device_node *dn)
if (!of_node_name_eq(dn, "pci")) if (!of_node_name_eq(dn, "pci"))
return 0; 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); return rpaphp_drc_info_add_slot(dn);
else else
return rpaphp_drc_add_slot(dn); return rpaphp_drc_add_slot(dn);
......
...@@ -447,7 +447,7 @@ static int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args * ...@@ -447,7 +447,7 @@ static int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *
return -ENODEV; return -ENODEV;
/* Local interrupt-map in the device node? Use it! */ /* 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); pin = pci_swizzle_interrupt_pin(pdev, pin);
ppnode = dn; ppnode = dn;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment