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: 45951 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9CD9F2153C for ; Wed, 18 Mar 2015 13:40:32 +0000 (UTC) Received: by wesk11 with SMTP id k11sf2616505wes.3 for ; Wed, 18 Mar 2015 06:40:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=7jpJwd4yLWvP7sUI+8GWfQZznGagYq7zHsMY3M9qbmA=; b=Rc7G8ClP30rNWvk0g7qci5gYEJfKhCk72SGKgtyhkZFst1VUFjP8nOFVl05C1GZV8D dUgSN7RTfXa74hl/VAlKYxtnl3dgC4+l8X+mG8zuus0CfIQm2KSTqpwmcCyYWuv7+cLU I7nefy1bm+UXGChSk14mQg0RTlsO7WFWEap4MQzYEy0DYuv8bTqcBHio63S8KqTQqBwE nZF33a/jE3TB3/iXZfEekGNjWH0p6SDdVYTjcDRs935Lhh6nMuVpcrh1bP36LZKhRXoS GrQDocWVH+NB5rXkmlauiYzkdOj8eBIvvJA2SL+nsenogI3m0Pex8KdlCHbbcP6vpeoh 5z3A== X-Gm-Message-State: ALoCoQl8Y01DGM3s2oOzqBIvrSa95ZKh5sQhLx/Crrcp8PHYskayFFIWNJLxnf/IUtVCK/S77yku X-Received: by 10.194.178.67 with SMTP id cw3mr6759834wjc.2.1426686031928; Wed, 18 Mar 2015 06:40:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.236 with SMTP id uh12ls159940lac.54.gmail; Wed, 18 Mar 2015 06:40:31 -0700 (PDT) X-Received: by 10.152.87.144 with SMTP id ay16mr8960720lab.10.1426686031511; Wed, 18 Mar 2015 06:40:31 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id n6si12921698laf.170.2015.03.18.06.40.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 06:40:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lamx15 with SMTP id x15so36297832lam.3 for ; Wed, 18 Mar 2015 06:40:31 -0700 (PDT) X-Received: by 10.152.22.67 with SMTP id b3mr63244530laf.117.1426686031288; Wed, 18 Mar 2015 06:40:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1163743lbj; Wed, 18 Mar 2015 06:40:30 -0700 (PDT) X-Received: by 10.66.217.198 with SMTP id pa6mr163805625pac.49.1426686028703; Wed, 18 Mar 2015 06:40:28 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ck1si27668934pdb.247.2015.03.18.06.40.27; Wed, 18 Mar 2015 06:40:28 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964791AbbCRNkX (ORCPT + 27 others); Wed, 18 Mar 2015 09:40:23 -0400 Received: from mail-wg0-f54.google.com ([74.125.82.54]:35049 "EHLO mail-wg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932506AbbCRNcD (ORCPT ); Wed, 18 Mar 2015 09:32:03 -0400 Received: by wgdm6 with SMTP id m6so35427142wgd.2 for ; Wed, 18 Mar 2015 06:32:02 -0700 (PDT) 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-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: georgi.djakov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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-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/ 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)