Skip to content

Commit

Permalink
clk: Use of_property_present() for testing DT property presence
Browse files Browse the repository at this point in the history
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>
Link: https://lore.kernel.org/r/20230310144701.1541504-1-robh@kernel.org
Acked-by: Chunyan Zhang <zhang.lyra@gmail.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
Rob Herring authored and Stephen Boyd committed Mar 15, 2023
1 parent fe15c26 commit d02fddf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4880,8 +4880,8 @@ static struct device_node *get_clk_provider_node(struct device *dev)
np = dev->of_node;
parent_np = dev->parent ? dev->parent->of_node : NULL;

if (!of_find_property(np, "#clock-cells", NULL))
if (of_find_property(parent_np, "#clock-cells", NULL))
if (!of_property_present(np, "#clock-cells"))
if (of_property_present(parent_np, "#clock-cells"))
np = parent_np;

return np;
Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/sprd/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int sprd_clk_regmap_init(struct platform_device *pdev,
struct device_node *node = dev->of_node, *np;
struct regmap *regmap;

if (of_find_property(node, "sprd,syscon", NULL)) {
if (of_property_present(node, "sprd,syscon")) {
regmap = syscon_regmap_lookup_by_phandle(node, "sprd,syscon");
if (IS_ERR(regmap)) {
pr_err("%s: failed to get syscon regmap\n", __func__);
Expand Down

0 comments on commit d02fddf

Please sign in to comment.