From patchwork Thu Apr 11 18:31:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 2429961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id A7030DF230 for ; Thu, 11 Apr 2013 18:32:35 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UQMI9-0000kF-8o; Thu, 11 Apr 2013 18:32:13 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UQMI0-0001eL-8u; Thu, 11 Apr 2013 18:32:04 +0000 Received: from mail-pa0-f47.google.com ([209.85.220.47]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UQMHm-0001dS-Uj for linux-arm-kernel@lists.infradead.org; Thu, 11 Apr 2013 18:31:52 +0000 Received: by mail-pa0-f47.google.com with SMTP id bj3so1044484pad.20 for ; Thu, 11 Apr 2013 11:31:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=ClTNJG3RCA9hBfkJphMpRJrpPi4+TZCswdKMEK7O6Fk=; b=US/peE+j+GEX7S263IGLL06pjmbwv8ZwDvRPqf21zU5IEaOfuLF2qlVLFE0xbOv7QI /P52KdXAg66oDYDVjPR7J1HoCKYIzQGW9Q1ymKOQ1JD/vRUN6wjAJpgGOz+R5nP/T8Ik 0/ejCHVpsi0K5rXCfX0Y585EVK+PtDf3bVqBSieNnBZgJ0iqzJZ/gMk5MZGpfrDoKKrH 5CLhFRX44dtk9BM3+WsP9aD1E6vCEzPMT/Km/mxkj+hYZM9ht02trZnX+yRvxo+nDl1g VBevnwX9CO0wdArxOEZlaxjJ31V7Riok6ctFGBcvNJ6ZYMSgpe2YKqTRw9QAO0P+CQda nQ9w== X-Received: by 10.66.174.143 with SMTP id bs15mr11243765pac.17.1365705109704; Thu, 11 Apr 2013 11:31:49 -0700 (PDT) Received: from quantum.gateway.2wire.net (adsl-69-228-93-79.dsl.pltn13.pacbell.net. [69.228.93.79]) by mx.google.com with ESMTPS id t1sm5940416pab.12.2013.04.11.11.31.46 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Apr 2013 11:31:48 -0700 (PDT) From: Mike Turquette To: =?UTF-8?q?Emilio=20L=C3=B3pez?= Subject: [PATCH v2 2/2] clk: composite: allow fixed rates & fixed dividers Date: Thu, 11 Apr 2013 11:31:37 -0700 Message-Id: <1365705097-18899-2-git-send-email-mturquette@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1365705097-18899-1-git-send-email-mturquette@linaro.org> References: <1365631378-16103-1-git-send-email-mturquette@linaro.org> <1365705097-18899-1-git-send-email-mturquette@linaro.org> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlhmG74Ztdw674eEi7eAsef25HZeB6VVOhrHgpg+K27emzxsmN3vG3rGUfTRE9c2KATly4F X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130411_143151_135614_80671187 X-CRM114-Status: GOOD ( 12.42 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.47 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Prashant Gaikwad , Mike Turquette , patches@linaro.org, Gregory CLEMENT , Maxime Ripard , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The composite clock assumes that any clock implementing the .recalc_rate callback will also implement .round_rate and .set_rate. This is not always true; the basic fixed-rate clock will only implement .recalc_rate and a fixed-divider clock may choose to implement .recalc_rate and .round_rate but not .set_rate. Fix this by conditionally registering .round_rate and .set_rate callbacks based on the rate_ops passed in to clk_composite_register. Signed-off-by: Mike Turquette Cc: Prashant Gaikwad Tested-by: Emilio López Cc: Gregory CLEMENT --- Changes since v1: * added WARN if set_rate is present without round_rate drivers/clk/clk-composite.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c index 6f4728c..a33f46f 100644 --- a/drivers/clk/clk-composite.c +++ b/drivers/clk/clk-composite.c @@ -150,17 +150,26 @@ struct clk *clk_register_composite(struct device *dev, const char *name, } if (rate_hw && rate_ops) { - if (!rate_ops->recalc_rate || !rate_ops->round_rate || - !rate_ops->set_rate) { + if (!rate_ops->recalc_rate) { clk = ERR_PTR(-EINVAL); goto err; } + /* .round_rate is a prerequisite for .set_rate */ + if (rate_ops->round_rate) { + clk_composite_ops->round_rate = clk_composite_round_rate; + if (rate_ops->set_rate) { + clk_composite_ops->set_rate = clk_composite_set_rate; + } + } else { + WARN(rate_ops->set_rate, + "%s: missing round_rate op is required\n", + __func__); + } + composite->rate_hw = rate_hw; composite->rate_ops = rate_ops; clk_composite_ops->recalc_rate = clk_composite_recalc_rate; - clk_composite_ops->round_rate = clk_composite_round_rate; - clk_composite_ops->set_rate = clk_composite_set_rate; } if (gate_hw && gate_ops) {