clk: Use of_property_present() for testing DT property presence
Subsystems (2)
PATCH 1/1 clk: 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.
--- drivers/clk/clk.c | 4 ++-- drivers/clk/sprd/common.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/clk/clk.c +2 -2
@@ -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;
drivers/clk/sprd/common.c +1 -1
@@ -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__);
Signature · 1 line
2.39.2
Quoted 8 lines · Rob Herring
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.
Quoted 4 lines
Signed-off-by Rob Herring <[email protected]>--- drivers/clk/clk.c | 4 ++-- drivers/clk/sprd/common.c | 2 +-
For sprd clk:
Thanks,
Chunyan
Quoted 33 lines
2 files changed, 3 insertions(+), 3 deletions(-)drivers/clk/clk.c +2
-2@@ -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;drivers/clk/sprd/common.c +1
-2@@ -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__); --2.39.2
Quoting Rob Herring (2023-03-10 06:47:01)
Quoted 9 lines
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 <[email protected]>---
Applied to clk-next