clk_prepare_lock();
+ /* bail early if nothing to do */
+ if (degrees == clk->core->phase)
+ goto out;
+
trace_clk_set_phase(clk->core, degrees);
if (clk->core->ops->set_phase)
if (!ret)
clk->core->phase = degrees;
+out:
clk_prepare_unlock();
return ret;
*
* Dynamically removes a clk and all its child nodes from the
* debugfs clk directory if clk->dentry points to debugfs created by
- * clk_debug_register in __clk_init.
+ * clk_debug_register in __clk_core_init.
*/
static void clk_debug_unregister(struct clk_core *core)
{
}
#endif
-/**
- * __clk_is_ancestor - check if a clk_core is a possible ancestor of another
- * @core: clock core
- * @ancestor: ancestor clock core
- *
- * Returns true if there is a possibility that @ancestor can be an ancestor
- * of @core, false otherwise.
- *
- * This function can be used against @core or @ancestor that has not been
- * registered yet.
- */
-static bool __clk_is_ancestor(struct clk_core *core, struct clk_core *ancestor)
-{
- struct clk_core *parent;
- int i;
-
- for (i = 0; i < core->num_parents; i++) {
- parent = clk_core_get_parent_by_index(core, i);
- /*
- * If ancestor has not been added to clk_{root,orphan}_list
- * yet, clk_core_lookup() cannot find it. If parent is NULL,
- * compare the name strings, too.
- */
- if ((parent && (parent == ancestor ||
- __clk_is_ancestor(parent, ancestor))) ||
- (!parent && !strcmp(core->parent_names[i], ancestor->name)))
- return true;
- }
-
- return false;
-}
-
/**
* __clk_core_init - initialize the data structures in a struct clk_core
* @core: clk_core being initialized
"%s: invalid NULL in %s's .parent_names\n",
__func__, core->name);
- /* If core is an ancestor of itself, it would make a loop. */
- if (__clk_is_ancestor(core, core)) {
- pr_err("%s: %s would create circular parent\n", __func__,
- core->name);
- ret = -EINVAL;
- goto out;
- }
-
core->parent = __clk_init_parent(core);
/*
- * Populate core->parent if parent has already been __clk_init'd. If
- * parent has not yet been __clk_init'd then place clk in the orphan
+ * Populate core->parent if parent has already been clk_core_init'd. If
+ * parent has not yet been clk_core_init'd then place clk in the orphan
* list. If clk doesn't have any parents then place it in the root
* clk list.
*
}
EXPORT_SYMBOL_GPL(of_clk_get_from_provider);
-int of_clk_get_parent_count(struct device_node *np)
+/**
+ * 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)
{
- return of_count_phandle_with_args(np, "clocks", "#clock-cells");
+ 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);
for_each_matching_node_and_match(np, matches, &match) {
struct clock_provider *parent;
+ if (!of_device_is_available(np))
+ continue;
+
parent = kzalloc(sizeof(*parent), GFP_KERNEL);
if (!parent) {
list_for_each_entry_safe(clk_provider, next,