Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965288AbbBBWLa (ORCPT ); Mon, 2 Feb 2015 17:11:30 -0500 Received: from smtp.codeaurora.org ([198.145.11.231]:49869 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965219AbbBBWL1 (ORCPT ); Mon, 2 Feb 2015 17:11:27 -0500 From: Stephen Boyd To: Mike Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, Philipp Zabel Subject: [PATCH] clk: clk_set_parent() with current parent shouldn't fail Date: Mon, 2 Feb 2015 14:11:25 -0800 Message-Id: <1422915085-29302-1-git-send-email-sboyd@codeaurora.org> X-Mailer: git-send-email 2.3.0.rc1.33.g42e4583 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1721 Lines: 52 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. Cc: Philipp Zabel Signed-off-by: Stephen Boyd --- Based on clk-next drivers/clk/clk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b82714a84f5e..670c8c86ce9f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -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; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/