Subject: [PATCH 5/7] dt/clock: add a simple provider get function

From: [email-masked] (Grant Likely)
Date: Fri, 06 Apr 2012 22:26:01 -0600

On Tue, 13 Mar 2012 18:22:25 -0500, Rob Herring <[email-masked]> wrote:
> From: Rob Herring <[email-masked]>
> 
> For simple cases, the clock provider data can simply be the struct clk ptr.
> 
> Signed-off-by: Rob Herring <[email-masked]>
> ---
>  drivers/of/clock.c |   18 +++++++++++-------
>  1 files changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/of/clock.c b/drivers/of/clock.c
> index 06fd5ad..f4a0965 100644
> --- a/drivers/of/clock.c
> +++ b/drivers/of/clock.c
> @@ -33,6 +33,12 @@ struct of_clk_provider {
>  static LIST_HEAD(of_clk_providers);
>  static DEFINE_MUTEX(of_clk_lock);
>  
> +static struct clk *of_clk_simple_get(struct of_phandle_args *clkspec,
> +				     void *data)
> +{
> +	return data;
> +}
> +
>  /**
>   * of_clk_add_provider() - Register a clock provider for a node
>   * @np: Device node pointer associated with clock provider
> @@ -52,7 +58,10 @@ int of_clk_add_provider(struct device_node *np,
>  
>  	cp->node = of_node_get(np);
>  	cp->data = data;
> -	cp->get = clk_src_get;
> +	if (clk_src_get)
> +		cp->get = clk_src_get;
> +	else
> +		cp->get = of_clk_simple_get;

Personally, I would prefer callers to be explicit about the
translation functions they need, but it isn't a big enough concern for
me to make a big deal about it.

Acked-by: Grant Likely <[email-masked]>

>  
>  	mutex_lock(&of_clk_lock);
>  	list_add(&cp->link, &of_clk_providers);
> @@ -183,11 +192,6 @@ void __init of_clk_init(const struct of_device_id *matches)
>  	}
>  }
>  
> -static struct clk *of_fixed_clk_get(struct of_phandle_args *a, void *data)
> -{
> -	return data;
> -}
> -
>  /**
>   * of_fixed_clk_setup() - Setup function for simple fixed rate clock
>   */
> @@ -204,5 +208,5 @@ void __init of_fixed_clk_setup(struct device_node *node)
>  
>  	clk = clk_register_fixed_rate(NULL, clk_name, NULL, CLK_IS_ROOT, rate);
>  	if (clk)
> -		of_clk_add_provider(node, of_fixed_clk_get, clk);
> +		of_clk_add_provider(node, NULL, clk);
>  }
> -- 
> 1.7.5.4
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.