diff mbox

[3/7] clk: sunxi: avoid double DT matching

Message ID 1399940993-1773-4-git-send-email-robherring2@gmail.com
State New
Headers show

Commit Message

Rob Herring May 13, 2014, 12:29 a.m. UTC
From: Rob Herring <robh@kernel.org>

Use for_each_matching_node_and_match instead of for_each_matching_node plus
of_match_node to avoid searching the DT twice for each node.

The sunxi DT scanning code should really be re-worked rather than have
its own private matching infrastructure. It is working around needing a
function pointer and a data pointer for each compatible match.

Signed-off-by: Rob Herring <robh@kernel.org>
Cc: "Emilio López" <emilio@elopez.com.ar>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 drivers/clk/sunxi/clk-sunxi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Rob Herring May 13, 2014, 3:12 p.m. UTC | #1
On Mon, May 12, 2014 at 7:29 PM, Rob Herring <robherring2@gmail.com> wrote:
> From: Rob Herring <robh@kernel.org>
>
> Use for_each_matching_node_and_match instead of for_each_matching_node plus
> of_match_node to avoid searching the DT twice for each node.
>
> The sunxi DT scanning code should really be re-worked rather than have
> its own private matching infrastructure. It is working around needing a
> function pointer and a data pointer for each compatible match.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> Cc: "Emilio López" <emilio@elopez.com.ar>
> Cc: Mike Turquette <mturquette@linaro.org>
> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  drivers/clk/sunxi/clk-sunxi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
> index bd7dc73..7977106 100644
> --- a/drivers/clk/sunxi/clk-sunxi.c
> +++ b/drivers/clk/sunxi/clk-sunxi.c
> @@ -1278,8 +1278,7 @@ static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_mat
>         const struct of_device_id *match;
>         void (*setup_function)(struct device_node *, const void *) = function;
>
> -       for_each_matching_node(np, clk_match) {
> -               match = of_match_node(clk_match, np);
> +       for_each_matching_node_and_match(np, clk_match, match) {

I missed folding in a fix and this should be &match instead of match.

Rob

>                 data = match->data;
>                 setup_function(np, data);
>         }
> --
> 1.9.1
>
Emilio López May 13, 2014, 4:57 p.m. UTC | #2
Hi Rob,

For 3/7 (with the mentioned fix) and 4/7 my Cubietruck still boots, so

Acked-by: Emilio López <emilio@elopez.com.ar>
Tested-by: Emilio López <emilio@elopez.com.ar>

El 13/05/14 12:12, Rob Herring escribió:
> On Mon, May 12, 2014 at 7:29 PM, Rob Herring <robherring2@gmail.com> wrote:
>> From: Rob Herring <robh@kernel.org>
>>
>> Use for_each_matching_node_and_match instead of for_each_matching_node plus
>> of_match_node to avoid searching the DT twice for each node.
>>
>> The sunxi DT scanning code should really be re-worked rather than have
>> its own private matching infrastructure. It is working around needing a
>> function pointer and a data pointer for each compatible match.
>>
>> Signed-off-by: Rob Herring <robh@kernel.org>
>> Cc: "Emilio López" <emilio@elopez.com.ar>
>> Cc: Mike Turquette <mturquette@linaro.org>
>> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>

Cheers,

Emilio
diff mbox

Patch

diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index bd7dc73..7977106 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -1278,8 +1278,7 @@  static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_mat
 	const struct of_device_id *match;
 	void (*setup_function)(struct device_node *, const void *) = function;
 
-	for_each_matching_node(np, clk_match) {
-		match = of_match_node(clk_match, np);
+	for_each_matching_node_and_match(np, clk_match, match) {
 		data = match->data;
 		setup_function(np, data);
 	}