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: 16047 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3492A238FF for ; Thu, 11 Apr 2013 18:32:15 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id hi18sf1064157wib.11 for ; Thu, 11 Apr 2013 11:31:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding; bh=ClTNJG3RCA9hBfkJphMpRJrpPi4+TZCswdKMEK7O6Fk=; b=nkxR2He0+grVoQseZuh8HXM8ryf4dijaIfR7ejaQ7A8vnibkieIJwwUIuY9uGabMyt GUe5MOi0n7XzDVe5e0nPlb4rvCSALRz4W2AD4T1bI3ylMPCnYwsTvn00Dmt/7jDHoduV N7J+7JLDRoJpjb+ELdTRymMJjBDm76qbv+g/tLAv/lgIcoNYJHmi+KGiaFKHUGlgHXx0 kubrcqsxuBuzU1fnqeWArGzRS7K9QclKdVch0iMmVEi4no7/LAahBQoEFZoM2qAT7mkA xf8uRr7jlixwwEXsPRFzLx9Xwn8mqfn6BGWLPNp+qX1TVgvLOU/qpnIUVGXrsm9nAqb7 JWeg== X-Received: by 10.180.106.161 with SMTP id gv1mr2610180wib.4.1365705112427; Thu, 11 Apr 2013 11:31:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.149.179 with SMTP id ub19ls316274wib.7.gmail; Thu, 11 Apr 2013 11:31:52 -0700 (PDT) X-Received: by 10.194.109.136 with SMTP id hs8mr12838428wjb.8.1365705112355; Thu, 11 Apr 2013 11:31:52 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id fz4si1961100wjb.249.2013.04.11.11.31.52 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Apr 2013 11:31:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id d10so1740212vea.28 for ; Thu, 11 Apr 2013 11:31:51 -0700 (PDT) X-Received: by 10.52.93.235 with SMTP id cx11mr4943350vdb.51.1365705111195; Thu, 11 Apr 2013 11:31:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp33594veb; Thu, 11 Apr 2013 11:31:50 -0700 (PDT) X-Received: by 10.68.170.35 with SMTP id aj3mr10313939pbc.204.1365705110091; Thu, 11 Apr 2013 11:31:50 -0700 (PDT) Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by mx.google.com with ESMTPS id te10si5429128pbc.115.2013.04.11.11.31.49 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Apr 2013 11:31:50 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.51 is neither permitted nor denied by best guess record for domain of mturquette@linaro.org) client-ip=209.85.220.51; Received: by mail-pa0-f51.google.com with SMTP id jh10so1039595pab.10 for ; Thu, 11 Apr 2013 11:31:49 -0700 (PDT) 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?= Cc: Maxime Ripard , Prashant Gaikwad , Gregory CLEMENT , linux-arm-kernel@lists.infradead.org, patches@linaro.org, Mike Turquette 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: ALoCoQk2DqXUkbtZX/6iMaw8fe+IEGOttMRaG1wakGoQ5ICuQrrEDsCR0ZOUpT0JeQmP0MbPXaV3 X-Original-Sender: mturquette@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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) {