linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: Use of_property_present() for testing DT property presence
@ 2023-03-10 14:47 Rob Herring
  2023-03-13  2:26 ` Chunyan Zhang
  2023-03-15  0:39 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Rob Herring @ 2023-03-10 14:47 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Orson Zhai, Baolin Wang, Chunyan Zhang
  Cc: devicetree, linux-clk, linux-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/clk/clk.c         | 4 ++--
 drivers/clk/sprd/common.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ae07685c7588..f7528d7f8256 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -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;
diff --git a/drivers/clk/sprd/common.c b/drivers/clk/sprd/common.c
index ce81e4087a8f..1a3795a61f81 100644
--- a/drivers/clk/sprd/common.c
+++ b/drivers/clk/sprd/common.c
@@ -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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: Use of_property_present() for testing DT property presence
  2023-03-10 14:47 [PATCH] clk: Use of_property_present() for testing DT property presence Rob Herring
@ 2023-03-13  2:26 ` Chunyan Zhang
  2023-03-15  0:39 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Chunyan Zhang @ 2023-03-13  2:26 UTC (permalink / raw)
  To: Rob Herring
  Cc: Michael Turquette, Stephen Boyd, Orson Zhai, Baolin Wang,
	devicetree, linux-clk, linux-kernel

On Fri, 10 Mar 2023 at 22:47, Rob Herring <robh@kernel.org> 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/clk/clk.c         | 4 ++--
>  drivers/clk/sprd/common.c | 2 +-

For sprd clk:
Acked-by: Chunyan Zhang <zhang.lyra@gmail.com>

Thanks,
Chunyan

>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index ae07685c7588..f7528d7f8256 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -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;
> diff --git a/drivers/clk/sprd/common.c b/drivers/clk/sprd/common.c
> index ce81e4087a8f..1a3795a61f81 100644
> --- a/drivers/clk/sprd/common.c
> +++ b/drivers/clk/sprd/common.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: Use of_property_present() for testing DT property presence
  2023-03-10 14:47 [PATCH] clk: Use of_property_present() for testing DT property presence Rob Herring
  2023-03-13  2:26 ` Chunyan Zhang
@ 2023-03-15  0:39 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2023-03-15  0:39 UTC (permalink / raw)
  To: Baolin Wang, Chunyan Zhang, Michael Turquette, Orson Zhai, Rob Herring
  Cc: devicetree, linux-clk, linux-kernel

Quoting Rob Herring (2023-03-10 06:47:01)
> 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 to clk-next

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-15  0:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 14:47 [PATCH] clk: Use of_property_present() for testing DT property presence Rob Herring
2023-03-13  2:26 ` Chunyan Zhang
2023-03-15  0:39 ` Stephen Boyd

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).