clk: Port two helper functions from Linux
Port of_clk_get_parent_count() and of_clk_parent_fill() from Linux. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
da1752b370
commit
b5ea2c6acc
|
@ -452,6 +452,24 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec)
|
|||
return clk;
|
||||
}
|
||||
|
||||
/**
|
||||
* of_clk_get_parent_count() - Count the number of clocks a device node has
|
||||
* @np: device node to count
|
||||
*
|
||||
* Returns: The number of clocks that are possible parents of this node
|
||||
*/
|
||||
unsigned int of_clk_get_parent_count(struct device_node *np)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = of_count_phandle_with_args(np, "clocks", "#clock-cells");
|
||||
if (count < 0)
|
||||
return 0;
|
||||
|
||||
return count;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_clk_get_parent_count);
|
||||
|
||||
char *of_clk_get_parent_name(struct device_node *np, unsigned int index)
|
||||
{
|
||||
struct of_phandle_args clkspec;
|
||||
|
@ -472,6 +490,27 @@ char *of_clk_get_parent_name(struct device_node *np, unsigned int index)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
|
||||
|
||||
/**
|
||||
* of_clk_parent_fill() - Fill @parents with names of @np's parents and return
|
||||
* number of parents
|
||||
* @np: Device node pointer associated with clock provider
|
||||
* @parents: pointer to char array that hold the parents' names
|
||||
* @size: size of the @parents array
|
||||
*
|
||||
* Return: number of parents for the clock node.
|
||||
*/
|
||||
int of_clk_parent_fill(struct device_node *np, const char **parents,
|
||||
unsigned int size)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
while (i < size && (parents[i] = of_clk_get_parent_name(np, i)) != NULL)
|
||||
i++;
|
||||
|
||||
return i;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_clk_parent_fill);
|
||||
|
||||
struct clock_provider {
|
||||
of_clk_init_cb_t clk_init_cb;
|
||||
struct device_node *np;
|
||||
|
|
|
@ -348,7 +348,10 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, void *data);
|
|||
struct clk *of_clk_get(struct device_node *np, int index);
|
||||
struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
|
||||
struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
|
||||
unsigned int of_clk_get_parent_count(struct device_node *np);
|
||||
char *of_clk_get_parent_name(struct device_node *np, unsigned int index);
|
||||
int of_clk_parent_fill(struct device_node *np, const char **parents,
|
||||
unsigned int size);
|
||||
int of_clk_init(struct device_node *root, const struct of_device_id *matches);
|
||||
#else
|
||||
static inline struct clk *of_clk_get(struct device_node *np, int index)
|
||||
|
|
Loading…
Reference in New Issue