From patchwork Wed Mar 18 13:32:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 6039391 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BD2AB9F314 for ; Wed, 18 Mar 2015 13:40:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E4FB420502 for ; Wed, 18 Mar 2015 13:40:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EDC74204EC for ; Wed, 18 Mar 2015 13:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932888AbbCRNkW (ORCPT ); Wed, 18 Mar 2015 09:40:22 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:34235 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932249AbbCRNcD (ORCPT ); Wed, 18 Mar 2015 09:32:03 -0400 Received: by wibg7 with SMTP id g7so64011146wib.1 for ; Wed, 18 Mar 2015 06:32:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JvNPEYzJX0CKd/cRu7BY8HC3v+ZQ/cO+5GqOUezh6Sc=; b=fOXQTSZ8b2YfJUTacurfI/WINPVErJCZAMAsmOyTG7VEvF4fejLtzmfsaHUBWkoEjd ZvSm/PkaEsxcCRy/lmkWMarG9mWRPjujo89Qikb4YhuTyWa6E4csXULepWiF2oxlcRoZ 2QeaoAmMGZa7RQQsh48ZO8Vi2Nna/gFZ7X/DAtbi4a9pcX4XtTsSdiuMa2X3R/kloDdS t3q4NkYZy/q2u+/x7ake0cLFDxlHAxa6UIfgC1G9BG/Rs97UvUVun3rTBtKo8n7D/LWD 3969icGIFFIdpZTf5XZ7m5ttmshJN6RjIdTX0EVlnnvvfjayQvkSY2tjGzb4hivGOEVb S/Sw== X-Gm-Message-State: ALoCoQn1yQWYCutI4AecJKit1iMyvoVdAvPsi+cv2wCvj5nLqkOZ//+aBGREHBkiHcGAZ7YJo1yr X-Received: by 10.180.97.106 with SMTP id dz10mr6821502wib.33.1426685522571; Wed, 18 Mar 2015 06:32:02 -0700 (PDT) Received: from mms.wifi.mm-sol.com ([37.157.136.206]) by mx.google.com with ESMTPSA id cf12sm24531838wjb.10.2015.03.18.06.32.01 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 18 Mar 2015 06:32:01 -0700 (PDT) From: Georgi Djakov To: sboyd@codeaurora.org, mturquette@linaro.org Cc: galak@codeaurora.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v1 1/9] clk: qcom: Fix clk_get_parent function return value Date: Wed, 18 Mar 2015 15:32:07 +0200 Message-Id: <1426685535-25071-2-git-send-email-georgi.djakov@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1426685535-25071-1-git-send-email-georgi.djakov@linaro.org> References: <1426685535-25071-1-git-send-email-georgi.djakov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to the common clock framework API, the clk_get_parent() function should return u8. Currently we are returning negative values on error. Fix this and use the default parent in case of an error. Signed-off-by: Georgi Djakov --- drivers/clk/qcom/clk-rcg.c | 26 +++++++++++++++++++------- drivers/clk/qcom/clk-rcg2.c | 7 +++++-- 2 files changed, 24 insertions(+), 9 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/clk/qcom/clk-rcg.c b/drivers/clk/qcom/clk-rcg.c index 466f30ca65c2..59a093e56366 100644 --- a/drivers/clk/qcom/clk-rcg.c +++ b/drivers/clk/qcom/clk-rcg.c @@ -47,15 +47,20 @@ static u8 clk_rcg_get_parent(struct clk_hw *hw) struct clk_rcg *rcg = to_clk_rcg(hw); int num_parents = __clk_get_num_parents(hw->clk); u32 ns; - int i; + int i, ret; - regmap_read(rcg->clkr.regmap, rcg->ns_reg, &ns); + ret = regmap_read(rcg->clkr.regmap, rcg->ns_reg, &ns); + if (ret) + goto err; ns = ns_to_src(&rcg->s, ns); for (i = 0; i < num_parents; i++) if (ns == rcg->s.parent_map[i]) return i; - return -EINVAL; +err: + pr_debug("%s: Clock %s has invalid parent, using default.\n", + __func__, __clk_get_name(hw->clk)); + return 0; } static int reg_to_bank(struct clk_dyn_rcg *rcg, u32 bank) @@ -70,21 +75,28 @@ static u8 clk_dyn_rcg_get_parent(struct clk_hw *hw) int num_parents = __clk_get_num_parents(hw->clk); u32 ns, reg; int bank; - int i; + int i, ret; struct src_sel *s; - regmap_read(rcg->clkr.regmap, rcg->bank_reg, ®); + ret = regmap_read(rcg->clkr.regmap, rcg->bank_reg, ®); + if (ret) + goto err; bank = reg_to_bank(rcg, reg); s = &rcg->s[bank]; - regmap_read(rcg->clkr.regmap, rcg->ns_reg[bank], &ns); + ret = regmap_read(rcg->clkr.regmap, rcg->ns_reg[bank], &ns); + if (ret) + goto err; ns = ns_to_src(s, ns); for (i = 0; i < num_parents; i++) if (ns == s->parent_map[i]) return i; - return -EINVAL; +err: + pr_debug("%s: Clock %s has invalid parent, using default.\n", + __func__, __clk_get_name(hw->clk)); + return 0; } static int clk_rcg_set_parent(struct clk_hw *hw, u8 index) diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index 742acfa18d63..6f27c5c614cc 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c @@ -69,7 +69,7 @@ static u8 clk_rcg2_get_parent(struct clk_hw *hw) ret = regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG, &cfg); if (ret) - return ret; + goto err; cfg &= CFG_SRC_SEL_MASK; cfg >>= CFG_SRC_SEL_SHIFT; @@ -78,7 +78,10 @@ static u8 clk_rcg2_get_parent(struct clk_hw *hw) if (cfg == rcg->parent_map[i]) return i; - return -EINVAL; +err: + pr_debug("%s: Clock %s has invalid parent, using default.\n", + __func__, __clk_get_name(hw->clk)); + return 0; } static int update_config(struct clk_rcg2 *rcg)