From patchwork Wed Apr 10 22:02:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 2423571 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 4E00B3FD8C for ; Wed, 10 Apr 2013 22:04:18 +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 1UQ37N-0002kB-U1; Wed, 10 Apr 2013 22:03:50 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UQ37B-0008Dc-2f; Wed, 10 Apr 2013 22:03:37 +0000 Received: from mail-da0-x232.google.com ([2607:f8b0:400e:c00::232]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UQ36q-0008BD-7v for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2013 22:03:17 +0000 Received: by mail-da0-f50.google.com with SMTP id t1so393236dae.37 for ; Wed, 10 Apr 2013 15:03:13 -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=kaFhCNNlEoWdlGOW2egmUh9nq+2NcXGDHRUdfoG+HZw=; b=pQuFKMbZepdmg5xQKcjjlSqS2etOxmX5UjV4pf8Kzu+ZZGaLs3VohT/9wzkq1QIziL nI765o2x44HKPvE8u6B+vonjb4r00z6xzRdJP+eh9nBrsnUzagjwNDasJPTIkHheUSGo vRGV4waBQsUv2KyhCJQARnxlquk19qngzAIV/83is6FAhFGvEWHVs3i8rVah26sfbpJv XMQGkKqWtosOr1L+oEIrrfVjkckWpq8jr+T+K8sUHutyPLl0G8BXNfO77njPktpuYQ83 9abUmbqIi/ED7PVL3YjGJv7/mXKxT5kP5g8k6P0Ih5f4aiBpOo4wFucyBv6nymat9SXk z1rQ== X-Received: by 10.66.163.129 with SMTP id yi1mr5964958pab.93.1365631393813; Wed, 10 Apr 2013 15:03:13 -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 z8sm1394888pbt.23.2013.04.10.15.03.11 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Apr 2013 15:03:12 -0700 (PDT) From: Mike Turquette To: Emilio Lopez Subject: [PATCH 2/3] clk: composite: allow fixed rates & fixed dividers Date: Wed, 10 Apr 2013 15:02:56 -0700 Message-Id: <1365631378-16103-3-git-send-email-mturquette@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1365631378-16103-1-git-send-email-mturquette@linaro.org> References: <1365515284-32061-2-git-send-email-emilio@elopez.com.ar> <1365631378-16103-1-git-send-email-mturquette@linaro.org> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQnbOZwNs/Si3kn6KwTQCpdzYNIJLzFU79JzNUCdXcdaGiiXHJ07S3djkySrrThcqe/IfgU2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130410_180316_422958_DA16438A X-CRM114-Status: GOOD ( 10.81 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Gregory CLEMENT , Maxime Ripard , Prashant Gaikwad , Mike Turquette , 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 Cc: Emilio López Cc: Gregory CLEMENT --- drivers/clk/clk-composite.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c index 6f4728c..2779fb3 100644 --- a/drivers/clk/clk-composite.c +++ b/drivers/clk/clk-composite.c @@ -150,17 +150,22 @@ 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; + } + } + 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) {