Skip to contentSkip to conversation

clk: clk_set_parent() with current parent shouldn't fail

PATCH Applied Stephen Boyd 3 participants 3 messages Feb 2, 2015 – Feb 25, 2015 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: clk_set_parent() with current parent shouldn't fail

If a driver calls clk_set_parent(clk, parent) and parent is the current parent of clk we shouldn't fail in any case. Unfortunately if clk is a read-only mux we return -ENOSYS because we think we can't change the parent, except for in this special case where we don't actually need to change the parent at all. Return 0 in such a situation.

---

Based on clk-next

 drivers/clk/clk.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/clk/clk.c +6 -4
index b82714a84f5e..670c8c86ce9f 100644
@@ -1969,16 +1969,18 @@ static int clk_core_set_parent(struct clk_core *clk, struct clk_core *parent)
 	if (!clk)
 		return 0;
 
-	/* verify ops for for multi-parent clks */
-	if ((clk->num_parents > 1) && (!clk->ops->set_parent))
-		return -ENOSYS;
-
 	/* prevent racing with updates to the clock topology */
 	clk_prepare_lock();
 
 	if (clk->parent == parent)
 		goto out;
 
+	/* verify ops for for multi-parent clks */
+	if ((clk->num_parents > 1) && (!clk->ops->set_parent)) {
+		ret = -ENOSYS;
+		goto out;
+	}
+
 	/* check that we are allowed to re-parent if the clock is in use */
 	if ((clk->flags & CLK_SET_PARENT_GATE) && clk->prepare_count) {
 		ret = -EBUSY;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Acked-by on v1 1/1
#1 lore raw

Am Montag, den 02.02.2015, 14:11 -0800 schrieb Stephen Boyd:

Quoted 9 lines

If a driver calls clk_set_parent(clk, parent) and parent is the current parent of clk we shouldn't fail in any case. Unfortunately if clk is a read-only mux we return -ENOSYS because we think we can't change the parent, except for in this special case where we don't actually need to change the parent at all. Return 0 in such a situation.

regards
Philipp

#2 lore raw

Quoting Philipp Zabel (2015-02-03 01:42:34)

Quoted 8 lines

Am Montag, den 02.02.2015, 14:11 -0800 schrieb Stephen Boyd:

Quoted 7 lines

If a driver calls clk_set_parent(clk, parent) and parent is the current parent of clk we shouldn't fail in any case. Unfortunately if clk is a read-only mux we return -ENOSYS because we think we can't change the parent, except for in this special case where we don't actually need to change the parent at all. Return 0 in such a situation.

Quoted 4 lines
Quoted 2 lines

Applied to clk-next.

Regards,
Mike

Quoted 4 lines

regards
Philipp